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

View file

@ -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();

View file

@ -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&]