diff --git a/src/Android/ProgramPath.cpp b/src/Android/ProgramPath.cpp index d87a548..9ea2217 100644 --- a/src/Android/ProgramPath.cpp +++ b/src/Android/ProgramPath.cpp @@ -17,9 +17,10 @@ namespace hgl strcpy(files_dir,HGL_MAX_PATH,fn); } - void GetLocalAppdataPath(char fn[HGL_MAX_PATH]) + bool GetLocalAppdataPath(OSString &result) { - strcpy(fn,HGL_MAX_PATH,files_dir); + result=files_dir; + return(true); } /** diff --git a/src/Apple/ProgramPath.mm b/src/Apple/ProgramPath.mm index ae6bfec..c77e82e 100644 --- a/src/Apple/ProgramPath.mm +++ b/src/Apple/ProgramPath.mm @@ -5,13 +5,14 @@ namespace hgl { namespace filesystem { - void GetLocalAppdataPath(char fn[HGL_MAX_PATH]) + bool GetLocalAppdataPath(OSString &result) { NSFileManager *dfm=[NSFileManager defaultManager]; const char *str=[[[dfm homeDirectoryForCurrentUser] path] cStringUsingEncoding:NSUTF8StringEncoding]; - hgl::strcpy(fn,HGL_MAX_PATH,str,strlen(str)); + result=str; + return(true); } /** diff --git a/src/UNIX/ProgramPath.cpp b/src/UNIX/ProgramPath.cpp index 34f0328..e84f267 100644 --- a/src/UNIX/ProgramPath.cpp +++ b/src/UNIX/ProgramPath.cpp @@ -7,7 +7,7 @@ namespace hgl { namespace filesystem { - void GetLocalAppdataPath(os_char fn[HGL_MAX_PATH]) + bool GetLocalAppdataPath(OSString &result) { struct passwd pwd; struct passwd *result; @@ -21,9 +21,10 @@ namespace hgl getpwuid_r(getuid(),&pwd,buf,bufsize,&result); - strcpy(fn,HGL_MAX_PATH,pwd.pw_dir); + result=pwd.pw_dir; free(buf); + return(true); } /** diff --git a/src/Win/ProgramPath.cpp b/src/Win/ProgramPath.cpp index f7d08b3..a73f828 100644 --- a/src/Win/ProgramPath.cpp +++ b/src/Win/ProgramPath.cpp @@ -6,9 +6,15 @@ namespace hgl { namespace filesystem { - void GetLocalAppdataPath(os_char fn[HGL_MAX_PATH]) + bool GetLocalAppdataPath(OSString &result) { - SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, fn); + os_char fn[HGL_MAX_PATH]; + + if(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, 0, fn)!=S_OK) + return(false); + + result=fn; + return(true); } /**