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 | |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 7 | #include "base/file_util.h" |
brettw@chromium.org | 59eef1f | 2013-02-24 14:40:52 +0900 | [diff] [blame] | 8 | #include "base/files/file_path.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 | |
evanm@google.com | 874d167 | 2008-10-31 08:54:04 +0900 | [diff] [blame] | 16 | FilePath cur; |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 17 | switch (key) { |
tfarina@chromium.org | e659804 | 2013-03-28 09:40:04 +0900 | [diff] [blame] | 18 | case DIR_EXE: |
| 19 | PathService::Get(FILE_EXE, &cur); |
evanm@google.com | 874d167 | 2008-10-31 08:54:04 +0900 | [diff] [blame] | 20 | cur = cur.DirName(); |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 21 | break; |
tfarina@chromium.org | e659804 | 2013-03-28 09:40:04 +0900 | [diff] [blame] | 22 | case DIR_MODULE: |
| 23 | PathService::Get(FILE_MODULE, &cur); |
evanm@google.com | 874d167 | 2008-10-31 08:54:04 +0900 | [diff] [blame] | 24 | cur = cur.DirName(); |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 25 | break; |
tfarina@chromium.org | e659804 | 2013-03-28 09:40:04 +0900 | [diff] [blame] | 26 | case DIR_TEMP: |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 27 | if (!file_util::GetTempDir(&cur)) |
| 28 | return false; |
| 29 | break; |
tfarina@chromium.org | e659804 | 2013-03-28 09:40:04 +0900 | [diff] [blame] | 30 | case DIR_TEST_DATA: |
| 31 | if (!PathService::Get(DIR_SOURCE_ROOT, &cur)) |
| 32 | return false; |
| 33 | cur = cur.Append(FILE_PATH_LITERAL("base")); |
| 34 | cur = cur.Append(FILE_PATH_LITERAL("test")); |
| 35 | cur = cur.Append(FILE_PATH_LITERAL("data")); |
| 36 | if (!file_util::PathExists(cur)) // We don't want to create this. |
| 37 | return false; |
| 38 | break; |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 39 | default: |
| 40 | return false; |
| 41 | } |
| 42 | |
evanm@google.com | 3e9d5d7 | 2008-11-20 01:50:03 +0900 | [diff] [blame] | 43 | *result = cur; |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 44 | return true; |
| 45 | } |
| 46 | |
| 47 | } // namespace base |