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:
cxl 2017-05-26 07:21:58 +00:00
parent 8ea326aeb9
commit aae24f1b8f
3 changed files with 23 additions and 23 deletions

View file

@ -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) {