void base_to_uppercase ( string& str ) {  for(string::reverse_iterator X = str.rbegin(); X != str.rend(); ++X) {  if (*X == '/' || *X == '\\' || *X == ':') break; #if (defined(BEOS) || defined(OPENBSD) || defined(CYGWIN)) if ((*X >= 'a') && (*X <= 'z')) *X -= 32; #else *X = std::toupper(*X); #endif } }
static void switch_slashes(string & name);// Ugly hack for supporting different pathsstatic std::map<string, string> path_map;void add_system_path(const string& key, const string& value){	path_map[key] = value;}/* *  Convert an exult path (e.g. "<DATA>/exult.flx") into a system path */string get_system_path(const string &path){	string new_path;	string::size_type pos;		pos = path.find('/');	// If there is no separator, return the path as is	if(pos == string::npos)		new_path = path;	else	{		// See if we can translate this prefix		string new_prefix(path_map[path.substr(0, pos).c_str()]);		// If the prefix path is not recognised, return the path as is		if(new_prefix.empty())			new_path = path;		else			new_path = new_prefix + path.substr(pos);	}	switch_slashes(new_path);	return new_path;}/* *	Convert a buffer to upper-case. * *	Output: ->original buffer, changed to upper case. */void to_uppercase	(	string &str	){	for(string::iterator X = str.begin(); X != str.end(); ++X)	{#if (defined(BEOS) || defined(OPENBSD) || defined(CYGWIN))		if ((*X >= 'a') && (*X <= 'z')) *X -= 32;#else		*X = std::toupper(*X);#endif         	}}static void switch_slashes(	string & name	){#ifdef WIN32	for(string::iterator X = name.begin(); X != name.end(); ++X)	{		if(*X == '/' )			*X =  '\\';	}#elif defined(MACOS)	// We use a component-wise algorithm (suggested by Yorick)	// Basically, split the path along the "/" seperators	// If a component is empty or '.', remove it. If it's '..', replace it	// with the empty string. convert all / to :	string::size_type	begIdx, endIdx;;	string	component;	string	new_name;		if( name.at(0) != '/' )		new_name = ":";		begIdx = name.find_first_not_of('/');	while( begIdx != string::npos )	{		endIdx = name.find_first_of('/', begIdx);		if( endIdx == std::string::npos )			component = name.substr(begIdx);		else			component = name.substr(begIdx, endIdx-begIdx);		if( component == ".." )			new_name += ":";		else if( !component.empty() && component != "." )		{			new_name += component;			if( endIdx != std::string::npos )				new_name += ":";		}		begIdx = name.find_first_not_of('/', endIdx);	}	name = new_name;#else	// do nothing#endif}