Fix emulator build error
[platform/framework/web/chromium-efl.git] / base / base_paths.cc
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.
4
5 #include "base/base_paths.h"
6
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"
11
12 namespace base {
13
14 bool PathProvider(int key, FilePath* result) {
15   // NOTE: DIR_CURRENT is a special case in PathService::Get
16
17   switch (key) {
18     case DIR_EXE:
19       if (!PathService::Get(FILE_EXE, result))
20         return false;
21       *result = result->DirName();
22       return true;
23 #if !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
24     case DIR_MODULE:
25       if (!PathService::Get(FILE_MODULE, result))
26         return false;
27       *result = result->DirName();
28       return true;
29     case DIR_ASSETS:
30       return PathService::Get(DIR_MODULE, result);
31 #endif  // !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_IOS)
32     case DIR_TEMP:
33       return GetTempDir(result);
34     case DIR_HOME:
35       *result = GetHomeDir();
36       return true;
37     case base::DIR_SRC_TEST_DATA_ROOT:
38       // This is only used by tests and overridden by each platform.
39       NOTREACHED();
40       return false;
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)) {
49         return false;
50       }
51       *result = result->Append(FILE_PATH_LITERAL("gen"));
52       return true;
53     case DIR_TEST_DATA: {
54       FilePath test_data_path;
55       if (!PathService::Get(DIR_SRC_TEST_DATA_ROOT, &test_data_path)) {
56         return false;
57       }
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.
62         return false;
63       *result = test_data_path;
64       return true;
65     }
66   }
67
68   return false;
69 }
70
71 }  // namespace base