• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "base/base_paths.h"
6 
7 #include "base/file_util.h"
8 #include "base/files/file_path.h"
9 #include "base/path_service.h"
10 
11 namespace base {
12 
PathProvider(int key,FilePath * result)13 bool PathProvider(int key, FilePath* result) {
14   // NOTE: DIR_CURRENT is a special case in PathService::Get
15 
16   switch (key) {
17     case DIR_EXE:
18       PathService::Get(FILE_EXE, result);
19       *result = result->DirName();
20       return true;
21     case DIR_MODULE:
22       PathService::Get(FILE_MODULE, result);
23       *result = result->DirName();
24       return true;
25     case DIR_TEMP:
26       if (!GetTempDir(result))
27         return false;
28       return true;
29     case base::DIR_HOME:
30       *result = GetHomeDir();
31       return true;
32     case DIR_TEST_DATA:
33       if (!PathService::Get(DIR_SOURCE_ROOT, result))
34         return false;
35       *result = result->Append(FILE_PATH_LITERAL("base"));
36       *result = result->Append(FILE_PATH_LITERAL("test"));
37       *result = result->Append(FILE_PATH_LITERAL("data"));
38       if (!PathExists(*result))  // We don't want to create this.
39         return false;
40       return true;
41     default:
42       return false;
43   }
44 }
45 
46 }  // namespace base
47