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/files/file_path.h" 8 #include "base/files/file_util.h" 9 #include "base/path_service.h" 10 11 namespace base { 12 PathProvider(int key,FilePath * result)13bool 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 if (!PathService::Get(FILE_EXE, result)) 19 return false; 20 *result = result->DirName(); 21 return true; 22 case DIR_MODULE: 23 if (!PathService::Get(FILE_MODULE, result)) 24 return false; 25 *result = result->DirName(); 26 return true; 27 case DIR_ASSETS: 28 return PathService::Get(DIR_MODULE, result); 29 case DIR_TEMP: 30 return GetTempDir(result); 31 case base::DIR_HOME: 32 *result = GetHomeDir(); 33 return true; 34 case DIR_TEST_DATA: { 35 FilePath test_data_path; 36 if (!PathService::Get(DIR_SOURCE_ROOT, &test_data_path)) 37 return false; 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. 42 return false; 43 *result = test_data_path; 44 return true; 45 } 46 default: 47 return false; 48 } 49 } 50 51 } // namespace base 52