Extra fallback for the unlikely case that $HOME isn't set on a unix
system (fixes 493). git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1243 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+3
-1
@@ -1,5 +1,7 @@
|
||||
Changes towards version 0.4:
|
||||
- Accept spaces in --contentdir argument. - SvdB
|
||||
- Extra fallback for the unlikely situation that $HOME isn't set on a
|
||||
unix system. (#493) - SvdB
|
||||
- Accept spaces in --contentdir argument (#492) - SvdB
|
||||
- Separated and abstracted sound buffer-tagging and trackplayer
|
||||
clip/subtitle chaining -Alex
|
||||
- Abstracted the recursive mutexes in MixSDL and DCQ code -Michael
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#ifdef WIN32
|
||||
# include <direct.h>
|
||||
# include <ctype.h>
|
||||
#else
|
||||
# include <pwd.h>
|
||||
#endif
|
||||
|
||||
/* Try to find a suitable value for %APPDATA% if it isn't defined on
|
||||
@@ -158,11 +160,27 @@ mkdirhier (const char *path)
|
||||
}
|
||||
|
||||
// Get the user's home dir
|
||||
// returns a pointer to a static buffer
|
||||
// returns a pointer to a static buffer from either getenv() or getpwuid().
|
||||
const char *
|
||||
getHomeDir (void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return getenv ("HOME");
|
||||
#else
|
||||
const char *home;
|
||||
struct passwd *pw;
|
||||
|
||||
home = getenv ("HOME");
|
||||
if (home != NULL)
|
||||
return home;
|
||||
|
||||
pw = getpwuid (getuid ());
|
||||
if (pw == NULL)
|
||||
return NULL;
|
||||
// NB: pw points to a static buffer.
|
||||
|
||||
return pw->pw_name;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Expand ~/ in a path, and replaces \ by / on Windows.
|
||||
|
||||
Reference in New Issue
Block a user