2019-05-25 20:58:22 -03:00
|
|
|
#include "CUserInfo.h"
|
2019-05-28 06:53:16 -03:00
|
|
|
#include <pwd.h>
|
2019-05-25 20:58:22 -03:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2019-08-03 03:32:07 -03:00
|
|
|
String get_current_user_home_path()
|
2019-05-26 14:14:03 -03:00
|
|
|
{
|
|
|
|
|
if (auto* home_env = getenv("HOME"))
|
2019-05-25 20:58:22 -03:00
|
|
|
return home_env;
|
2019-05-26 14:14:03 -03:00
|
|
|
|
2019-08-03 03:32:07 -03:00
|
|
|
auto* pwd = getpwuid(getuid());
|
|
|
|
|
String path = pwd ? pwd->pw_dir : "/";
|
|
|
|
|
endpwent();
|
|
|
|
|
return path;
|
2019-05-25 20:58:22 -03:00
|
|
|
}
|