CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    [RESOLVED] Another path issue

    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.
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

  2. #2
    Join Date
    Nov 2006
    Location
    Australia
    Posts
    1,569

    Re: Another path issue

    Oh... I should have read the docs better... there is an lpDirectory parameter that specifies the working directory for the exectuable. :s
    Good judgment is gained from experience. Experience is gained from bad judgment.
    Cosy Little Game | SDL | GM script | VLD | Syntax Hlt | Can you help me with my homework assignment?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured