mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 09:30:25 +08:00
fixed #286
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include "rtabmap/utilite/UStl.h"
|
||||
@@ -367,7 +368,22 @@ std::string UDirectory::homeDir()
|
||||
path = profilePath;
|
||||
#endif
|
||||
#else
|
||||
path = getenv("HOME");
|
||||
char * pathstr = getenv("HOME");
|
||||
if(pathstr)
|
||||
{
|
||||
path = pathstr;
|
||||
}
|
||||
if(path.empty())
|
||||
{
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
if(pw) {
|
||||
path = pw->pw_dir;
|
||||
}
|
||||
if(path.empty())
|
||||
{
|
||||
UFATAL("Environment variable HOME is not set, cannot get home directory! Please set HOME environment variable to a valid directory.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user