OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/filesystem/file_system_app.h" | 5 #include "components/filesystem/file_system_app.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "mojo/shell/public/cpp/connection.h" | 10 #include "mojo/shell/public/cpp/connection.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 //static | 58 //static |
59 base::FilePath FileSystemApp::GetUserDataDir() { | 59 base::FilePath FileSystemApp::GetUserDataDir() { |
60 base::FilePath path; | 60 base::FilePath path; |
61 | 61 |
62 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 62 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
63 if (command_line->HasSwitch(kUserDataDir)) { | 63 if (command_line->HasSwitch(kUserDataDir)) { |
64 path = command_line->GetSwitchValuePath(kUserDataDir); | 64 path = command_line->GetSwitchValuePath(kUserDataDir); |
65 } else { | 65 } else { |
66 #if defined(OS_WIN) | 66 #if defined(OS_WIN) |
67 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path)); | 67 CHECK(PathService::Get(base::DIR_LOCAL_APP_DATA, &path)); |
68 path = path.Append(FILE_PATH_LITERAL("mandoline")); | 68 #elif defined(OS_MACOSX) |
| 69 CHECK(PathService::Get(base::DIR_APP_DATA, &path)); |
| 70 #elif defined(OS_ANDROID) |
| 71 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &path)); |
69 #elif defined(OS_LINUX) | 72 #elif defined(OS_LINUX) |
70 scoped_ptr<base::Environment> env(base::Environment::Create()); | 73 scoped_ptr<base::Environment> env(base::Environment::Create()); |
71 base::FilePath config_dir( | 74 path = base::nix::GetXDGDirectory(env.get(), |
72 base::nix::GetXDGDirectory(env.get(), | 75 base::nix::kXdgConfigHomeEnvVar, |
73 base::nix::kXdgConfigHomeEnvVar, | 76 base::nix::kDotConfigDir); |
74 base::nix::kDotConfigDir)); | |
75 path = config_dir.Append("mandoline"); | |
76 #elif defined(OS_MACOSX) | |
77 CHECK(PathService::Get(base::DIR_APP_DATA, &path)); | |
78 path = path.Append("Mandoline Shell"); | |
79 #elif defined(OS_ANDROID) | |
80 CHECK(PathService::Get(base::DIR_ANDROID_APP_DATA, &path)); | |
81 path = path.Append(FILE_PATH_LITERAL("mandoline")); | |
82 #else | 77 #else |
83 NOTIMPLEMENTED(); | 78 NOTIMPLEMENTED(); |
84 #endif | 79 #endif |
| 80 path = path.Append(FILE_PATH_LITERAL("filesystem")); |
85 } | 81 } |
86 | 82 |
87 if (!base::PathExists(path)) | 83 if (!base::PathExists(path)) |
88 base::CreateDirectory(path); | 84 base::CreateDirectory(path); |
89 | 85 |
90 return path; | 86 return path; |
91 } | 87 } |
92 | 88 |
93 } // namespace filesystem | 89 } // namespace filesystem |
OLD | NEW |