michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #include "base/base_paths.h" michael@0: michael@0: #include "base/file_util.h" michael@0: #include "base/files/file_path.h" michael@0: #include "base/path_service.h" michael@0: michael@0: namespace base { michael@0: michael@0: bool PathProvider(int key, FilePath* result) { michael@0: // NOTE: DIR_CURRENT is a special case in PathService::Get michael@0: michael@0: FilePath cur; michael@0: switch (key) { michael@0: case DIR_EXE: michael@0: PathService::Get(FILE_EXE, &cur); michael@0: cur = cur.DirName(); michael@0: break; michael@0: case DIR_MODULE: michael@0: PathService::Get(FILE_MODULE, &cur); michael@0: cur = cur.DirName(); michael@0: break; michael@0: case DIR_TEMP: michael@0: if (!file_util::GetTempDir(&cur)) michael@0: return false; michael@0: break; michael@0: case DIR_TEST_DATA: michael@0: if (!PathService::Get(DIR_SOURCE_ROOT, &cur)) michael@0: return false; michael@0: cur = cur.Append(FILE_PATH_LITERAL("base")); michael@0: cur = cur.Append(FILE_PATH_LITERAL("test")); michael@0: cur = cur.Append(FILE_PATH_LITERAL("data")); michael@0: if (!base::PathExists(cur)) // We don't want to create this. michael@0: return false; michael@0: break; michael@0: default: michael@0: return false; michael@0: } michael@0: michael@0: *result = cur; michael@0: return true; michael@0: } michael@0: michael@0: } // namespace base