|
|
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Core - App.cpp - GetDataFile
Core - App.cpp - GetDataFile [message #3172] |
Tue, 09 May 2006 21:48 |
3togo
Messages: 83 Registered: May 2006 Location: Hong Kong SAR
|
Member |
|
|
I think that no matter exec program is running under posix or windows, GetDataFile should always get the current working directory(getcwd) and concat with *filename.
However, the present release behaves differently on these two different systems.
I suggest replace GetHomeDirectory() below with GetCWD()
String& GetCWD() {
char buffer[100];
int size = 100;
getcwd(buffer,size);
static String ss;
ss.Cat(buffer);
return ss;
}
Regards,
3togo
************************************************************
App.cpp
************************************************************ *
String GetDataFile(const char *filename)
{
String s = Environment().Get("UPP_MAIN__",
#ifdef PLATFORM_WIN32
GetFileFolder(GetExeFilePath())
#endif
#ifdef PLATFORM_POSIX
GetHomeDirectory()
#endif
);
return AppendFileName(s, filename);
}
[Updated on: Tue, 09 May 2006 22:03] Report message to a moderator
|
|
|
|
|
|
Re: Core - App.cpp - GetDataFile [message #3193 is a reply to message #3174] |
Thu, 11 May 2006 13:24 |
guido
Messages: 169 Registered: April 2006
|
Experienced Member |
|
|
The POSIX convention is ../share/<appname> relativ to the executable. But as the exe could be symlinked, you need to call realpath() to resolve the symlink:
http://www.opengroup.org/onlinepubs/7990989775/xsh/realpath. html
Both Gnome and KDE have an API for resource location.
In the case of KDE you can add the datadir to the KDEDIRS env variable (in an startup script), to make the app relocatable.
Most Gnome apps are sadly not relocatable at all. Even though Gnome has an API for that, most programmers don't bother and simply hardcode the pathes through the standard autotools mechanism (DATADIR, LOCALEDIR...).
|
|
|
Goto Forum:
Current Time: Fri Apr 19 13:28:29 CEST 2024
Total time taken to generate the page: 0.03836 seconds
|
|
|