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: |
Sergey Ulanov | d5ae68e | 2018-02-07 20:14:21 | [diff] [blame] | 18 | if (!PathService::Get(FILE_EXE, result)) |
19 | return false; | ||||
[email protected] | ffaee18e | 2014-02-19 20:34:23 | [diff] [blame] | 20 | *result = result->DirName(); |
21 | return true; | ||||
[email protected] | c4803e43 | 2013-03-28 00:40:04 | [diff] [blame] | 22 | case DIR_MODULE: |
Sergey Ulanov | d5ae68e | 2018-02-07 20:14:21 | [diff] [blame] | 23 | if (!PathService::Get(FILE_MODULE, result)) |
24 | return false; | ||||
[email protected] | ffaee18e | 2014-02-19 20:34:23 | [diff] [blame] | 25 | *result = result->DirName(); |
26 | return true; | ||||
Sergey Ulanov | d5ae68e | 2018-02-07 20:14:21 | [diff] [blame] | 27 | case DIR_ASSETS: |
28 | return PathService::Get(DIR_MODULE, result); | ||||
[email protected] | c4803e43 | 2013-03-28 00:40:04 | [diff] [blame] | 29 | case DIR_TEMP: |
Sergey Ulanov | d5ae68e | 2018-02-07 20:14:21 | [diff] [blame] | 30 | return GetTempDir(result); |
[email protected] | ffaee18e | 2014-02-19 20:34:23 | [diff] [blame] | 31 | case base::DIR_HOME: |
32 | *result = GetHomeDir(); | ||||
33 | return true; | ||||
maniscalco | 6e14781 | 2015-12-11 18:23:13 | [diff] [blame] | 34 | case DIR_TEST_DATA: { |
35 | FilePath test_data_path; | ||||
36 | if (!PathService::Get(DIR_SOURCE_ROOT, &test_data_path)) | ||||
[email protected] | c4803e43 | 2013-03-28 00:40:04 | [diff] [blame] | 37 | return false; |
maniscalco | 6e14781 | 2015-12-11 18:23:13 | [diff] [blame] | 38 | test_data_path = test_data_path.Append(FILE_PATH_LITERAL("base")); |
39 | test_data_path = test_data_path.Append(FILE_PATH_LITERAL("test")); | ||||
40 | test_data_path = test_data_path.Append(FILE_PATH_LITERAL("data")); | ||||
41 | if (!PathExists(test_data_path)) // We don't want to create this. | ||||
[email protected] | c4803e43 | 2013-03-28 00:40:04 | [diff] [blame] | 42 | return false; |
maniscalco | 6e14781 | 2015-12-11 18:23:13 | [diff] [blame] | 43 | *result = test_data_path; |
[email protected] | ffaee18e | 2014-02-19 20:34:23 | [diff] [blame] | 44 | return true; |
maniscalco | 6e14781 | 2015-12-11 18:23:13 | [diff] [blame] | 45 | } |
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 46 | default: |
47 | return false; | ||||
48 | } | ||||
initial.commit | d7cae12 | 2008-07-26 21:49:38 | [diff] [blame] | 49 | } |
50 | |||||
51 | } // namespace base |