From 92e44ae0ad94910984b79979ad47d6b32b534c57 Mon Sep 17 00:00:00 2001 From: "thorogood@chromium.org" Date: Mon, 23 Jul 2012 08:22:44 +0000 Subject: Prettify output from chrome.fileSystem.getDisplayPath for POSIX profile directories This duplicates review 10693089, except for POSIX. Modifies e.g. "/home/sam/foo" to "~/foo". As a dependency, adds DIR_HOME to PathService for retrieving POSIX home directory. BUG=135690 TEST= Review URL: https://chromiumcodereview.appspot.com/10700136 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147833 0039d316-1c4b-4281-b951-d872f2087c98 --- base/base_paths.h | 1 + base/base_paths_mac.mm | 4 ++++ base/base_paths_posix.cc | 7 ++++++- base/file_util_posix.cc | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) (limited to 'base') diff --git a/base/base_paths.h b/base/base_paths.h index ea62a8b..3875fb4 100644 --- a/base/base_paths.h +++ b/base/base_paths.h @@ -40,6 +40,7 @@ enum BasePathKey { // browser cache can be a subdirectory. // This is $XDG_CACHE_HOME on Linux and // ~/Library/Caches on Mac. + DIR_HOME, // $HOME on POSIX-like systems. #endif PATH_END diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm index 56f3ecb..e46fd1e 100644 --- a/base/base_paths_mac.mm +++ b/base/base_paths_mac.mm @@ -83,6 +83,10 @@ bool PathProviderMac(int key, FilePath* result) { #endif return true; } + case base::DIR_HOME: { + *result = base::mac::NSStringToFilePath(NSHomeDirectory()); + return true; + } default: return false; } diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc index d8d5ae6..743f77a 100644 --- a/base/base_paths_posix.cc +++ b/base/base_paths_posix.cc @@ -85,12 +85,17 @@ bool PathProviderPosix(int key, FilePath* result) { << "Try running from your chromium/src directory."; return false; } - case base::DIR_CACHE: + case base::DIR_CACHE: { scoped_ptr env(base::Environment::Create()); FilePath cache_dir(base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", ".cache")); *result = cache_dir; return true; + } + case base::DIR_HOME: { + *result = file_util::GetHomeDir(); + return true; + } } return false; } diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index f198f44..0dc4f33 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -1085,7 +1085,7 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path) { return result; } -#endif // defined(OS_MACOSX) +#endif // !defined(OS_MACOSX) bool VerifyPathControlledByUser(const FilePath& base, const FilePath& path, -- cgit v1.1