Coming back to this thread, I'm having trouble with relative/absolute paths to files.
I recently added the ability to play the level the user is editing in my level editor by running the game's executable (which is in a different folder than the editor) via ShellExecute:
Code:
ShellExecute(GetDesktopWindow(), TEXT("open"),
to_wstring(hex_fn).c_str(), NULL, NULL, SW_SHOWNORMAL);
While I haven't got to the stage of replacing strings with a proper "Path" class (mainly because I couldn't figure out how to install Boost.Filesystem and didn't want to try and implement such a system myself), I have made sure that all resources are loaded using the absolute path of the resource:
Code:
SDL_Surface* Surface_Cache::Load_Surface(const std::string& file_name,
bool is_colour_key, Opt_SDL_Colour colour_key)
{
std::string fn = Directory::abs_path(file_name);
// ...
return optimized;
}
However, since I am using ShellExecute, the calls to Directory::abs_path seem to indicate that the executable directory is where ShellExecute was called from, instead of the directory of the executable that was called.
Is there a way to get around this issue (besides using Boost.Filesystem which I failed miserably at trying to install)?
Cheers.