/*******************************************************************************/ /* */ /* GetHomeDirectory - this function will return the home directory of the user */ /* Check HOME first! */ /* */ /* returns a pointer to the home directory */ /* */ /*******************************************************************************/ #include /* for getenv */ #include #include #if !defined (__MINGW32__) && !defined (__MSVCRT__) #include /* for uname */ #include #endif #include char *GetHomeDirectory () { #if !defined (__MINGW32__) && !defined (__MSVCRT__) struct passwd *pw; #endif char *home_dir; home_dir = getenv ("HOME"); #if !defined (__MINGW32__) && !defined (__MSVCRT__) if (!home_dir) { pw = getpwuid (getuid ()); if (pw) home_dir = pw->pw_dir; } #endif return home_dir; }