Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

GetAppPath vs. DetermineExecutablePath

(1/8) > >>

afb:
app#GetAppPath vs. configmanager#DetermineExecutablePath
Why do both these square wheels exist ? Should I just copy/paste ?

And unfortunately wxStandardPathsBase::Get().GetDataDir() seems
to return the wrong result in wx 2.6.3, might bug-report it for 2.8.0.

afb:
If we want to go the copy-and-paste route, here is a patch for wxMac:
http://www.algonet.se/~afb/wx/codeblocks-configmanagermac.patch

We might want to look into using/upgrading BinReloc for Linux, or not ?
http://autopackage.org/docs/binreloc/ (prefix.cpp/h is an old version)

thomas:

--- Quote ---app#GetAppPath vs. configmanager#DetermineExecutablePath
Why do both these square wheels exist ? Should I just copy/paste ?
--- End quote ---
They both exist because I did not remove the one in CodeBlocksApp hastily (not knowing where it might be used). If no other code depends on it (plugins?), we could remove/replace it, but let's not be hasty.

Formerly, the application used to set app_path at some time during startup. Before this, the value returned by ConfigManager was undefined. That was ugly, but not a big issue because we made sure we didn't use it earlier.
Now, ConfigManager makes user paths dependent on where the config file was found. That means that it does all that path initialising a lot earlier (the first time any ConfigManager function is called) and consequently needs to know app_path a lot earlier too (and perferrably not depending on the state of startup).

The Linux code in CodeBlocksApp was not very good anyway, it never really determined a path, but simply assumed ".", which may accidentially work, but often does not.
The new version tries to read /proc/self/exe (and falls back to ".") which is not perfect, but a bit better. If you know of a yet better method, please step forward. :)


--- Quote ---And unfortunately wxStandardPathsBase::Get().GetDataDir() seems
to return the wrong result in wx 2.6.3, might bug-report it for 2.8.0.
--- End quote ---
It's exactly what was used before too, though. Only now we have if(...) return and before we had return wxPathList.FindValid(...).
Where does it return a wrong value, MacOS? Works under Windows. Have not tested under Linux myself, but nobody complained during the last 6 weeks...?  :)

afb:

--- Quote from: thomas on November 21, 2006, 09:04:27 am ---The Linux code in CodeBlocksApp was not very good anyway, it never really determined a path, but simply assumed ".", which may accidentially work, but often does not.
--- End quote ---

The code that I saw used APP_PREFIX, and if that wasn't available it used BinReloc instead. Unfortunately it used the application path instead of the application prefix, so it was still broken but I fixed that in the latest revision (appended a "/.." to it)


--- Quote ---The new version tries to read /proc/self/exe (and falls back to ".") which is not perfect, but a bit better. If you know of a yet better method, please step forward. :)
--- End quote ---

BinReloc.


--- Quote ---
--- Quote ---And unfortunately wxStandardPathsBase::Get().GetDataDir() seems
to return the wrong result in wx 2.6.3, might bug-report it for 2.8.0.
--- End quote ---
It's exactly what was used before too, though. Only now we have if(...) return and before we had return wxPathList.FindValid(...).
Where does it return a wrong value, MacOS? Works under Windows. Have not tested under Linux myself, but nobody complained during the last 6 weeks...?  :)

--- End quote ---

(yes - wrong in wxMac, sorry for the lack of context)

It returns SharedSupport, which is not absolutely wrong (although intended for templates and such non-mandatory) material but we have decided on using Resources instead partly since Mandrav wanted to use share/codeblocks on all platforms...

i.e. if you ask wxWidgets it would use CodeBlocks.app/Contents/SharedSupport for resources and CodeBlocks.app/Contents/PlugIns for plugins, but we want it to use CodeBlocks.app/Contents/Resources/share/codeblocks[/plugins]

afb:

--- Quote from: thomas on November 21, 2006, 09:04:27 am ---
--- Quote ---Why do both these square wheels exist ? Should I just copy/paste ?
--- End quote ---
They both exist because I did not remove the one in CodeBlocksApp hastily (not knowing where it might be used). If no other code depends on it (plugins?), we could remove/replace it, but let's not be hasty.
--- End quote ---

I just wanted to refactor them into one single nice solution instead...

The canonical application path retriever would use:

* GetModuleFileName for Windows
* br_find_exe for Linux (BinReloc)
* _NSGetExecutablePath for Mac OS X

Navigation

[0] Message Index

[#] Next page

Go to full version