diff --git a/src/lib/arch/IArchFile.h b/src/lib/arch/IArchFile.h index 941dc1ac3..bea99f68d 100644 --- a/src/lib/arch/IArchFile.h +++ b/src/lib/arch/IArchFile.h @@ -27,13 +27,6 @@ public: */ virtual const char *getBasename(const char *pathname) = 0; - //! Get user's home directory - /*! - Returns the user's home directory. Returns the empty string if - this cannot be determined. - */ - virtual std::string getUserDirectory() = 0; - //! Get installed directory /*! Returns the directory in which Deskflow is installed. diff --git a/src/lib/arch/unix/ArchFileUnix.cpp b/src/lib/arch/unix/ArchFileUnix.cpp index d0916dbd4..ddb4cff27 100644 --- a/src/lib/arch/unix/ArchFileUnix.cpp +++ b/src/lib/arch/unix/ArchFileUnix.cpp @@ -43,33 +43,6 @@ const char *ArchFileUnix::getBasename(const char *pathname) } } -std::string ArchFileUnix::getUserDirectory() -{ - char *buffer = NULL; - std::string dir; -#if HAVE_GETPWUID_R - struct passwd pwent; - struct passwd *pwentp{}; -#if defined(_SC_GETPW_R_SIZE_MAX) - long size = sysconf(_SC_GETPW_R_SIZE_MAX); - if (size == -1) { - size = BUFSIZ; - } -#else - long size = BUFSIZ; -#endif - buffer = new char[size]; - getpwuid_r(getuid(), &pwent, buffer, size, &pwentp); -#else - struct passwd *pwentp = getpwuid(getuid()); -#endif - if (pwentp != NULL && pwentp->pw_dir != NULL) { - dir = pwentp->pw_dir; - } - delete[] buffer; - return dir; -} - std::string ArchFileUnix::getInstalledDirectory() { #if WINAPI_XWINDOWS diff --git a/src/lib/arch/unix/ArchFileUnix.h b/src/lib/arch/unix/ArchFileUnix.h index 7cc1247df..17499e114 100644 --- a/src/lib/arch/unix/ArchFileUnix.h +++ b/src/lib/arch/unix/ArchFileUnix.h @@ -20,7 +20,6 @@ public: // IArchFile overrides virtual const char *getBasename(const char *pathname); - virtual std::string getUserDirectory(); virtual std::string getInstalledDirectory(); virtual std::string concatPath(const std::string &prefix, const std::string &suffix); }; diff --git a/src/lib/arch/win32/ArchFileWindows.cpp b/src/lib/arch/win32/ArchFileWindows.cpp index bd969fc78..37f4c4a9c 100644 --- a/src/lib/arch/win32/ArchFileWindows.cpp +++ b/src/lib/arch/win32/ArchFileWindows.cpp @@ -50,47 +50,6 @@ const char *ArchFileWindows::getBasename(const char *pathname) return basename; } -std::string ArchFileWindows::getUserDirectory() -{ - // try %HOMEPATH% - TCHAR dir[MAX_PATH]; - DWORD size = sizeof(dir) / sizeof(TCHAR); - DWORD result = GetEnvironmentVariable(_T("HOMEPATH"), dir, size); - if (result != 0 && result <= size) { - // sanity check -- if dir doesn't appear to start with a - // drive letter and isn't a UNC name then don't use it - // FIXME -- allow UNC names - if (dir[0] != '\0' && (dir[1] == ':' || ((dir[0] == '\\' || dir[0] == '/') && (dir[1] == '\\' || dir[1] == '/')))) { - return dir; - } - } - - // get the location of the personal files. that's as close to - // a home directory as we're likely to find. - ITEMIDLIST *idl; - if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &idl))) { - TCHAR *path = NULL; - if (SHGetPathFromIDList(idl, dir)) { - DWORD attr = GetFileAttributes(dir); - if (attr != 0xffffffff && (attr & FILE_ATTRIBUTE_DIRECTORY) != 0) - path = dir; - } - - IMalloc *shalloc; - if (SUCCEEDED(SHGetMalloc(&shalloc))) { - shalloc->Free(idl); - shalloc->Release(); - } - - if (path != NULL) { - return path; - } - } - - // use root of C drive as a default - return "C:"; -} - std::string ArchFileWindows::getInstalledDirectory() { char fileNameBuffer[MAX_PATH]; diff --git a/src/lib/arch/win32/ArchFileWindows.h b/src/lib/arch/win32/ArchFileWindows.h index 36cd5bfab..5c233196b 100644 --- a/src/lib/arch/win32/ArchFileWindows.h +++ b/src/lib/arch/win32/ArchFileWindows.h @@ -20,7 +20,6 @@ public: // IArchFile overrides virtual const char *getBasename(const char *pathname); - virtual std::string getUserDirectory(); virtual std::string getInstalledDirectory(); virtual std::string concatPath(const std::string &prefix, const std::string &suffix); };