license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 4 | |
| 5 | #include "base/base_paths.h" |
| 6 | |
brettw@chromium.org | 59eef1f | 2013-02-24 14:40:52 +0900 | [diff] [blame] | 7 | #include "base/files/file_path.h" |
brettw@chromium.org | 01f3da4 | 2014-08-14 05:22:14 +0900 | [diff] [blame] | 8 | #include "base/files/file_util.h" |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 9 | #include "base/path_service.h" |
| 10 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 11 | namespace base { |
| 12 | |
evanm@google.com | 3e9d5d7 | 2008-11-20 01:50:03 +0900 | [diff] [blame] | 13 | bool PathProvider(int key, FilePath* result) { |
gab@chromium.org | 97fc1e6 | 2012-09-21 01:24:52 +0900 | [diff] [blame] | 14 | // NOTE: DIR_CURRENT is a special case in PathService::Get |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 15 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 16 | switch (key) { |
tfarina@chromium.org | e659804 | 2013-03-28 09:40:04 +0900 | [diff] [blame] | 17 | case DIR_EXE: |
brettw@chromium.org | 49de1af | 2014-02-20 05:34:23 +0900 | [diff] [blame] | 18 | PathService::Get(FILE_EXE, result); |
| 19 | *result = result->DirName(); |
| 20 | return true; |
tfarina@chromium.org | e659804 | 2013-03-28 09:40:04 +0900 | [diff] [blame] | 21 | case DIR_MODULE: |
brettw@chromium.org | 49de1af | 2014-02-20 05:34:23 +0900 | [diff] [blame] | 22 | PathService::Get(FILE_MODULE, result); |
| 23 | *result = result->DirName(); |
| 24 | return true; |
tfarina@chromium.org | e659804 | 2013-03-28 09:40:04 +0900 | [diff] [blame] | 25 | case DIR_TEMP: |
brettw@chromium.org | 49de1af | 2014-02-20 05:34:23 +0900 | [diff] [blame] | 26 | if (!GetTempDir(result)) |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 27 | return false; |
brettw@chromium.org | 49de1af | 2014-02-20 05:34:23 +0900 | [diff] [blame] | 28 | return true; |
| 29 | case base::DIR_HOME: |
| 30 | *result = GetHomeDir(); |
| 31 | return true; |
maniscalco | 33f2880 | 2015-12-12 03:23:13 +0900 | [diff] [blame] | 32 | case DIR_TEST_DATA: { |
| 33 | FilePath test_data_path; |
| 34 | if (!PathService::Get(DIR_SOURCE_ROOT, &test_data_path)) |
tfarina@chromium.org | e659804 | 2013-03-28 09:40:04 +0900 | [diff] [blame] | 35 | return false; |
maniscalco | 33f2880 | 2015-12-12 03:23:13 +0900 | [diff] [blame] | 36 | test_data_path = test_data_path.Append(FILE_PATH_LITERAL("base")); |
| 37 | test_data_path = test_data_path.Append(FILE_PATH_LITERAL("test")); |
| 38 | test_data_path = test_data_path.Append(FILE_PATH_LITERAL("data")); |
| 39 | if (!PathExists(test_data_path)) // We don't want to create this. |
tfarina@chromium.org | e659804 | 2013-03-28 09:40:04 +0900 | [diff] [blame] | 40 | return false; |
maniscalco | 33f2880 | 2015-12-12 03:23:13 +0900 | [diff] [blame] | 41 | *result = test_data_path; |
brettw@chromium.org | 49de1af | 2014-02-20 05:34:23 +0900 | [diff] [blame] | 42 | return true; |
maniscalco | 33f2880 | 2015-12-12 03:23:13 +0900 | [diff] [blame] | 43 | } |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 44 | default: |
| 45 | return false; |
| 46 | } |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | } // namespace base |