diff --git a/uppsrc/Core/App.cpp b/uppsrc/Core/App.cpp index 21d49cc55..698201df2 100644 --- a/uppsrc/Core/App.cpp +++ b/uppsrc/Core/App.cpp @@ -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) { diff --git a/uppsrc/Core/App.h b/uppsrc/Core/App.h index 8b60c98cb..0b6fb4948 100644 --- a/uppsrc/Core/App.h +++ b/uppsrc/Core/App.h @@ -8,12 +8,8 @@ String GetExeDirFile(const char *fp); String GetHomeDirFile(const char *fp); String GetHomeDirectory(); -#ifdef PLATFORM_POSIX - void SetHomeDirectory(const char *dir); -#endif - void UseHomeDirectoryConfig(bool b = true); String GetConfigFolder(); diff --git a/uppsrc/Core/src.tpp/AppEnv$en-us.tpp b/uppsrc/Core/src.tpp/AppEnv$en-us.tpp index 9de73e7e8..8848049b3 100644 --- a/uppsrc/Core/src.tpp/AppEnv$en-us.tpp +++ b/uppsrc/Core/src.tpp/AppEnv$en-us.tpp @@ -159,7 +159,6 @@ URL that will be opened in the browser&] [s4; &] [s5;:SetHomeDirectory`(const char`*`): [@(0.0.255) void]_[* SetHomeDirectory]([@(0.0.255) c onst]_[@(0.0.255) char]_`*[*@3 dir])&] -[s2; [*@3 POSIX specific]&] [s2;%% Sets the current user`'s home folder.&] [s2;%% [*@(129.0.0) dir]................................................the URL that will be opened in the browser&]