summaryrefslogtreecommitdiffstats
path: root/base/base_paths_mac.mm
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 21:03:44 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-16 21:03:44 +0000
commit405a64b63ae9a6869923aa5b80cc77acf66e71bf (patch)
tree7881c66b26cc96095a454585a5ae40d3b5863c39 /base/base_paths_mac.mm
parent3fcec6daa921d2cf2ecdfa69740ad095700f9ddd (diff)
downloadchromium_src-405a64b63ae9a6869923aa5b80cc77acf66e71bf.zip
chromium_src-405a64b63ae9a6869923aa5b80cc77acf66e71bf.tar.gz
chromium_src-405a64b63ae9a6869923aa5b80cc77acf66e71bf.tar.bz2
Set OS X cache directory to ~/Library/Caches/[app name]/[profile name]
- Added implementation of GetUserCacheDirectory() for OS X. - Added FilePath::GetRelativePath(). - Implemented per-profile cache directories for OS X. Patch by Fred Akalin <akalin@gmail.com> Code review URL: http://codereview.chromium.org/174053 Review URL: http://codereview.chromium.org/204043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26387 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/base_paths_mac.mm')
-rw-r--r--base/base_paths_mac.mm24
1 files changed, 24 insertions, 0 deletions
diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm
index 965d9d3..7549827 100644
--- a/base/base_paths_mac.mm
+++ b/base/base_paths_mac.mm
@@ -15,6 +15,26 @@
namespace base {
+namespace {
+
+// TODO(akalin): Export this function somewhere and use it in
+// chrome_paths_mac.mm and mac_util.mm. This is tricky because
+// NSSearchPathDirectory is declared in an Objective C header so we
+// cannot put it in one of the usual locations (where pure C++ files
+// would include them).
+bool GetUserDirectory(NSSearchPathDirectory directory, FilePath* result) {
+ NSArray* dirs =
+ NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES);
+ if ([dirs count] < 1) {
+ return false;
+ }
+ NSString* path = [dirs objectAtIndex:0];
+ *result = FilePath([path fileSystemRepresentation]);
+ return true;
+}
+
+} // namespace
+
bool PathProviderMac(int key, FilePath* result) {
std::string cur;
switch (key) {
@@ -27,6 +47,10 @@ bool PathProviderMac(int key, FilePath* result) {
cur = [path fileSystemRepresentation];
break;
}
+ case base::DIR_CACHE:
+ return GetUserDirectory(NSCachesDirectory, result);
+ case base::DIR_APP_DATA:
+ return GetUserDirectory(NSApplicationSupportDirectory, result);
case base::DIR_SOURCE_ROOT: {
FilePath path;
PathService::Get(base::DIR_EXE, &path);