From 3cfaec88a8ec167cb345de086b65e47900112bf3 Mon Sep 17 00:00:00 2001 From: Zdenek Prikryl Date: Tue, 11 Aug 2009 18:35:26 +0200 Subject: new function for gettings user's home directory --- lib/Utils/xfuncs.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/Utils/xfuncs.cpp') diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp index 60c2eb4..c8aee37 100644 --- a/lib/Utils/xfuncs.cpp +++ b/lib/Utils/xfuncs.cpp @@ -246,3 +246,9 @@ void xstat(const char *name, struct stat *stat_buf) if (stat(name, stat_buf)) perror_msg_and_die("can't stat '%s'", name); } + +std::string get_home_dir(int uid) +{ + struct passwd* pw = getpwuid(uid); + return pw ? pw->pw_dir : ""; +} -- cgit