mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-18 06:06:01 -06:00
Core: SetHomeDirectory now available in Win32 too
git-svn-id: svn://ultimatepp.org/upp/trunk@11121 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
8ea326aeb9
commit
aae24f1b8f
3 changed files with 23 additions and 23 deletions
|
|
@ -21,8 +21,21 @@
|
|||
|
||||
namespace Upp {
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
static StaticCriticalSection sHlock;
|
||||
|
||||
String& sHomeDir() {
|
||||
static String s;
|
||||
return s;
|
||||
}
|
||||
|
||||
void SetHomeDirectory(const char *dir)
|
||||
{
|
||||
INTERLOCKED_(sHlock) {
|
||||
sHomeDir() = dir;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
|
||||
String GetEnv(const char *id)
|
||||
{
|
||||
|
|
@ -35,7 +48,14 @@ String GetExeFilePath()
|
|||
}
|
||||
|
||||
String GetHomeDirectory() {
|
||||
return GetEnv("HOMEDRIVE") + GetEnv("HOMEPATH");
|
||||
String r;
|
||||
INTERLOCKED_(sHlock) {
|
||||
String& s = sHomeDir();
|
||||
if(s.IsEmpty())
|
||||
s = GetEnv("HOMEDRIVE") + GetEnv("HOMEPATH");
|
||||
r = s;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -120,32 +140,17 @@ String GetExeTitle()
|
|||
|
||||
#ifdef PLATFORM_POSIX
|
||||
|
||||
static StaticCriticalSection sHlock;
|
||||
|
||||
String& sHomeDir() {
|
||||
static String s;
|
||||
return s;
|
||||
}
|
||||
|
||||
String GetHomeDirectory() {
|
||||
String r;
|
||||
INTERLOCKED_(sHlock) {
|
||||
String& s = sHomeDir();
|
||||
if(s.IsEmpty()) {
|
||||
if(s.IsEmpty())
|
||||
s = Nvl(GetEnv("HOME"), "/root");
|
||||
}
|
||||
r = s;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void SetHomeDirectory(const char *dir)
|
||||
{
|
||||
INTERLOCKED_(sHlock) {
|
||||
sHomeDir() = dir;
|
||||
}
|
||||
}
|
||||
|
||||
#endif//PLATFORM_POSIX
|
||||
|
||||
String GetHomeDirFile(const char *fp) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue