This is an archive of the discontinued LLVM Phabricator instance.

Support: Provide a function to get the home directory of an arbitrary user
AbandonedPublic

Authored by zturner on Jul 31 2014, 5:42 PM.

Details

Reviewers
rnk
Summary

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

Diff Detail

Event Timeline

zturner updated this revision to Diff 12089.Jul 31 2014, 5:42 PM
zturner retitled this revision from to Support: Provide a function to get the home directory of an arbitrary user.
zturner updated this object.
zturner edited the test plan for this revision. (Show Details)
zturner added a reviewer: rnk.
zturner set the repository for this revision to rL LLVM.
zturner added a subscriber: Unknown Object (MLST).
rnk added inline comments.Jul 31 2014, 6:07 PM
lib/Support/Unix/Path.inc
683

StringRef doesn't have a c_str() method, but you can do .str().c_str() to convert to std::string first. *yawn*, excessive copies in C++. :(

lib/Support/Windows/Path.inc
880–882

I'd sink these declarations to the point of first use.

886

there's a bunch of micro 80cols stuff that clang-format can fix here.

905

Can we avoid the copy by resizing result directly and passing it into the query?

majnemer added inline comments.
lib/Support/Unix/Path.inc
683

This doesn't follow LLVM's coding style.

Variables should be CamelCase and there is no space between the identifier and the parenthesis.

lib/Support/Windows/Path.inc
873

Pointers on the right side.

890

Can we get away with using reserve instead of resize?

zturner updated this revision to Diff 12109.Aug 1 2014, 9:41 AM

Updated with review changes.

zturner updated this revision to Diff 12111.Aug 1 2014, 10:13 AM

Ran clang-format over the patch.

rnk accepted this revision.Aug 1 2014, 10:19 AM
rnk edited edge metadata.

lgtm

lib/Support/Unix/Path.inc
683

Yeah, but we're in the sys::filesystem API. The STL-like function names usually come with hacker_style_underscore variable names. This is consistent with the code around it, too.

lib/Support/Windows/Path.inc
887–888

I guess this can be .reserve() instead of .resize() and .data() instead of &result[0].

890

+1

907

ditto

This revision is now accepted and ready to land.Aug 1 2014, 10:19 AM
zturner abandoned this revision.Aug 12 2014, 1:11 PM