You need to sign in or sign up before continuing.
Commit ae255821 authored by Denis Krjuchkov's avatar Denis Krjuchkov

ConfigPath: use standard directory API

parent 5d857921
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "fs/AllocatedPath.hxx" #include "fs/AllocatedPath.hxx"
#include "fs/Traits.hxx" #include "fs/Traits.hxx"
#include "fs/Domain.hxx" #include "fs/Domain.hxx"
#include "fs/StandardDirectory.hxx"
#include "util/Error.hxx" #include "util/Error.hxx"
#include "ConfigGlobal.hxx" #include "ConfigGlobal.hxx"
...@@ -39,14 +40,14 @@ ...@@ -39,14 +40,14 @@
static AllocatedPath static AllocatedPath
GetHome(const char *user, Error &error) GetHome(const char *user, Error &error)
{ {
passwd *pw = getpwnam(user); AllocatedPath result = GetHomeDir(user);
if (pw == nullptr) { if (result.IsNull()) {
error.Format(path_domain, error.Format(path_domain,
"no such user: %s", user); "no such user: %s", user);
return AllocatedPath::Null(); return AllocatedPath::Null();
} }
return AllocatedPath::FromFS(pw->pw_dir); return result;
} }
/** /**
...@@ -55,14 +56,14 @@ GetHome(const char *user, Error &error) ...@@ -55,14 +56,14 @@ GetHome(const char *user, Error &error)
static AllocatedPath static AllocatedPath
GetHome(Error &error) GetHome(Error &error)
{ {
const char *home = g_get_home_dir(); AllocatedPath result = GetHomeDir();
if (home == nullptr) { if (result.IsNull()) {
error.Set(path_domain, error.Set(path_domain,
"problems getting home for current user"); "problems getting home for current user");
return AllocatedPath::Null(); return AllocatedPath::Null();
} }
return AllocatedPath::FromUTF8(home, error); return result;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment