license.bot | bf09a50 | 2008-08-24 00:55:55 | [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 | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 4 | |
5 | #include "base/base_paths.h" | ||||
6 | |||||
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 7 | #include "base/files/file_path.h" |
[email protected] | e3177dd5 | 2014-08-13 20:22:14 | [diff] [blame] | 8 | #include "base/files/file_util.h" |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 9 | #include "base/path_service.h" |
10 | |||||
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 11 | namespace base { |
12 | |||||
[email protected] | 4792a26 | 2008-11-19 16:50:03 | [diff] [blame] | 13 | bool PathProvider(int key, FilePath* result) { |
[email protected] | dea1d7d | 2012-09-20 16:24:52 | [diff] [blame] | 14 | // NOTE: DIR_CURRENT is a special case in PathService::Get |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 15 | |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 16 | switch (key) { |
[email protected] | c4803e43 | 2013-03-28 00:40:04 | [diff] [blame] | 17 | case DIR_EXE: |
[email protected] | ffaee18e | 2014-02-19 20:34:23 | [diff] [blame] | 18 | PathService::Get(FILE_EXE, result); |
19 | *result = result->DirName(); | ||||
20 | return true; | ||||
[email protected] | c4803e43 | 2013-03-28 00:40:04 | [diff] [blame] | 21 | case DIR_MODULE: |
[email protected] | ffaee18e | 2014-02-19 20:34:23 | [diff] [blame] | 22 | PathService::Get(FILE_MODULE, result); |
23 | *result = result->DirName(); | ||||
24 | return true; | ||||
[email protected] | c4803e43 | 2013-03-28 00:40:04 | [diff] [blame] | 25 | case DIR_TEMP: |
[email protected] | ffaee18e | 2014-02-19 20:34:23 | [diff] [blame] | 26 | if (!GetTempDir(result)) |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 27 | return false; |
[email protected] | ffaee18e | 2014-02-19 20:34:23 | [diff] [blame] | 28 | return true; |
29 | case base::DIR_HOME: | ||||
30 | *result = GetHomeDir(); | ||||
31 | return true; | ||||
maniscalco | 6e14781 | 2015-12-11 18:23:13 | [diff] [blame] | 32 | case DIR_TEST_DATA: { |
33 | FilePath test_data_path; | ||||
34 | if (!PathService::Get(DIR_SOURCE_ROOT, &test_data_path)) | ||||
[email protected] | c4803e43 | 2013-03-28 00:40:04 | [diff] [blame] | 35 | return false; |
maniscalco | 6e14781 | 2015-12-11 18:23:13 | [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. | ||||
[email protected] | c4803e43 | 2013-03-28 00:40:04 | [diff] [blame] | 40 | return false; |
maniscalco | 6e14781 | 2015-12-11 18:23:13 | [diff] [blame] | 41 | *result = test_data_path; |
[email protected] | ffaee18e | 2014-02-19 20:34:23 | [diff] [blame] | 42 | return true; |
maniscalco | 6e14781 | 2015-12-11 18:23:13 | [diff] [blame] | 43 | } |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 44 | default: |
45 | return false; | ||||
46 | } | ||||
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 47 | } |
48 | |||||
49 | } // namespace base |