Author Topic: Prefix finding code still broken  (Read 6765 times)

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Prefix finding code still broken
« on: November 07, 2006, 11:03:30 am »
Switched the Mac code to use the new GetAppPath implemenation, but it still doesn't work...

Seems like it's picking the wrong level and missing a ".." ? Wonder why SELFPATH doesn't ?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Prefix finding code still broken
« Reply #1 on: November 07, 2006, 11:06:04 am »
(I would post the real output here, if forum wouldn't barf ?)

But it is looking in /usr/ local/ bin/ share/ codeblocks
Without the spaces of course, had to add those to post...

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Re: Prefix finding code still broken
« Reply #2 on: November 07, 2006, 12:32:18 pm »
Quote
Wonder why SELFPATH doesn't ?

Have you had a quick glance in src/prefix.cpp? Maybe it's missing a define for Mac or something?
Be patient!
This bug will be fixed soon...

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Prefix finding code still broken
« Reply #3 on: November 07, 2006, 01:33:09 pm »
BINRELOC is only for Linux, so I did my own implementation.
But I have must have missed what it was supposed to return.

i.e. currently I return the path to the application in GetAppPath,
but apparently it is expecting the prefix to be returned instead ?  :o

Code
    #ifdef APP_PREFIX
        wxString data = wxT(APP_PREFIX); // under linux, get the preprocessor value
    #else
        wxString data = GetAppPath();
    #endif

Will fix it when I move to the "share/codeblocks" subdirectory.
Just wondered if there was a bug with the other code path too ?

i.e. shouldn't the above instead be: GetAppPath() + _T("/..") ?

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Prefix finding code still broken
« Reply #4 on: November 07, 2006, 02:02:50 pm »
BTW; We will use a "share/codeblocks" dir on Win/Mac too, I think ?
(the nightly build for Windows seem to use share/CodeBlocks, but...)

Rather than the "standard" system path (from wxStandardPathsBase):
Code
    // return the location of the applications global, i.e. not user-specific,
    // data files
    //
    // prefix/share/appname under Unix, c:\Program Files\appname under Windows,
    // appname.app/Contents/SharedSupport app bundle directory under Mac
    virtual wxString GetDataDir() const = 0;
Which doesn't even look to be all that correct for Windows and Mac OS X.
(SharedSupport is supposed to contain examples and templates and such)

so it will look in: CodeBlocks.app/Contents/Resources/share/codeblocks dir,
and if that doesn't exist it will look in $PREFIX/share/codeblocks like above.
« Last Edit: November 07, 2006, 02:06:15 pm by afb »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Prefix finding code still broken
« Reply #5 on: November 07, 2006, 02:40:54 pm »
Quote
and if that doesn't exist it will look in $PREFIX/share/codeblocks like above.

Thank you for that.

When developing I'd like to keep my mac file structure as close to linux structure as possible. Jumping around in the forest of mac hidden files wastes a lot of time.

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Prefix finding code still broken
« Reply #6 on: November 07, 2006, 02:59:22 pm »
Actually it will first ask for the Resources directory of the bundle, and it if isn't a bundle that will return something useless like "codeblocks" (without the path) and then it will revert to plan B which is calling GetAppPath that in returns uses the Mach-O binary path. The idea is to return the directory that corresponds to the program that is being run...

For the preferences wxMac will "only" look in ~/Library/Application\ Support/CodeBlocks, though. wxGTK will instead use the $HOME/.codeblocks directory on Mac OS X too I think.
« Last Edit: November 07, 2006, 03:03:48 pm by afb »

Offline afb

  • Developer
  • Lives here!
  • *****
  • Posts: 884
Re: Prefix finding code still broken
« Reply #7 on: November 20, 2006, 12:43:27 am »
Code
    #ifdef APP_PREFIX
        wxString data = wxT(APP_PREFIX); // under linux, get the preprocessor value
    #else
        wxString data = GetAppPath();
    #endif

Will fix it when I move to the "share/codeblocks" subdirectory.
Just wondered if there was a bug with the other code path too ?

i.e. shouldn't the above instead be: GetAppPath() + _T("/..") ?

Changed it to use app path + "..", which should be something like:
/usr/local/bin/../share/codeblocks, which should be working ?

Also fixed a bug on Mac OS X, I mistakenly assumed that just because
you pass the length by pointer it would actually return something useful.