mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-11 12:29:50 +08:00
fixed #286
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <pwd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "rtabmap/utilite/UStl.h"
|
#include "rtabmap/utilite/UStl.h"
|
||||||
@@ -367,7 +368,22 @@ std::string UDirectory::homeDir()
|
|||||||
path = profilePath;
|
path = profilePath;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#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
|
#endif
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user