[PATCH] Support: Provide a function to get the home directory of an arbitrary user

Aaron Ballman aaron at aaronballman.com
Fri Aug 1 10:33:03 PDT 2014


On Thu, Jul 31, 2014 at 8:42 PM, Zachary Turner <zturner at google.com> wrote:
> Hi rnk,
>
> llvm::sys::path already provides a function home_directory() which returns the current user's home directory.
>
> This patch extends this by implementing a function which returns the home directory of an arbitrary user.  This satisfies a use case in LLDB where we need to resolve paths of the form ~username/path, and since it is similar in nature to the existing home_directory() function, seems generally useful for llvm
>
> http://reviews.llvm.org/D4749
>
> Files:
>   include/llvm/Support/Path.h
>   lib/Support/Unix/Path.inc
>   lib/Support/Windows/Path.inc

Instead of trawling the registry (which is fragile and subject to
change), I would feel *way* more comfortable using the designated API
for this sort of thing (SHGetKnownFolderPath). It accepts a token
which you can use to impersonate a particular user.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188.aspx

~Aaron




More information about the llvm-commits mailing list