1 // Copyright 2006-2008 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/base_paths.h"
7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h"
9 #include "base/path_service.h"
10 #include "build/build_config.h"
14 bool PathProvider(int key, FilePath* result) {
15 // NOTE: DIR_CURRENT is a special case in PathService::Get
19 if (!PathService::Get(FILE_EXE, result))
21 *result = result->DirName();
23 #if !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
25 if (!PathService::Get(FILE_MODULE, result))
27 *result = result->DirName();
30 return PathService::Get(DIR_MODULE, result);
31 #endif // !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
33 return GetTempDir(result);
35 *result = GetHomeDir();
37 case base::DIR_SRC_TEST_DATA_ROOT:
38 // This is only used by tests and overridden by each platform.
41 #if !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
42 case DIR_OUT_TEST_DATA_ROOT:
43 // On most platforms test binaries are run directly from the build-output
44 // directory, so return the directory containing the executable.
45 return PathService::Get(DIR_MODULE, result);
46 #endif // !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
47 case DIR_GEN_TEST_DATA_ROOT:
48 if (!PathService::Get(DIR_OUT_TEST_DATA_ROOT, result)) {
51 *result = result->Append(FILE_PATH_LITERAL("gen"));
54 FilePath test_data_path;
55 if (!PathService::Get(DIR_SRC_TEST_DATA_ROOT, &test_data_path)) {
58 test_data_path = test_data_path.Append(FILE_PATH_LITERAL("base"));
59 test_data_path = test_data_path.Append(FILE_PATH_LITERAL("test"));
60 test_data_path = test_data_path.Append(FILE_PATH_LITERAL("data"));
61 if (!PathExists(test_data_path)) // We don't want to create this.
63 *result = test_data_path;