blob: 31bc55401af4a8087b3319ba4f35d796e918c376 [file] [log] [blame]
license.botbf09a502008-08-24 00:55:551// 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.
initial.commitd7cae122008-07-26 21:49:384
5#include "base/base_paths.h"
6
[email protected]57999812013-02-24 05:40:527#include "base/files/file_path.h"
[email protected]e3177dd52014-08-13 20:22:148#include "base/files/file_util.h"
initial.commitd7cae122008-07-26 21:49:389#include "base/path_service.h"
10
initial.commitd7cae122008-07-26 21:49:3811namespace base {
12
[email protected]4792a262008-11-19 16:50:0313bool PathProvider(int key, FilePath* result) {
[email protected]dea1d7d2012-09-20 16:24:5214 // NOTE: DIR_CURRENT is a special case in PathService::Get
initial.commitd7cae122008-07-26 21:49:3815
initial.commitd7cae122008-07-26 21:49:3816 switch (key) {
[email protected]c4803e432013-03-28 00:40:0417 case DIR_EXE:
[email protected]ffaee18e2014-02-19 20:34:2318 PathService::Get(FILE_EXE, result);
19 *result = result->DirName();
20 return true;
[email protected]c4803e432013-03-28 00:40:0421 case DIR_MODULE:
[email protected]ffaee18e2014-02-19 20:34:2322 PathService::Get(FILE_MODULE, result);
23 *result = result->DirName();
24 return true;
[email protected]c4803e432013-03-28 00:40:0425 case DIR_TEMP:
[email protected]ffaee18e2014-02-19 20:34:2326 if (!GetTempDir(result))
initial.commitd7cae122008-07-26 21:49:3827 return false;
[email protected]ffaee18e2014-02-19 20:34:2328 return true;
29 case base::DIR_HOME:
30 *result = GetHomeDir();
31 return true;
maniscalco6e147812015-12-11 18:23:1332 case DIR_TEST_DATA: {
33 FilePath test_data_path;
34 if (!PathService::Get(DIR_SOURCE_ROOT, &test_data_path))
[email protected]c4803e432013-03-28 00:40:0435 return false;
maniscalco6e147812015-12-11 18:23:1336 test_data_path = test_data_path.Append(FILE_PATH_LITERAL("base"));
37 test_data_path = test_data_path.Append(FILE_PATH_LITERAL("test"));
38 test_data_path = test_data_path.Append(FILE_PATH_LITERAL("data"));
39 if (!PathExists(test_data_path)) // We don't want to create this.
[email protected]c4803e432013-03-28 00:40:0440 return false;
maniscalco6e147812015-12-11 18:23:1341 *result = test_data_path;
[email protected]ffaee18e2014-02-19 20:34:2342 return true;
maniscalco6e147812015-12-11 18:23:1343 }
initial.commitd7cae122008-07-26 21:49:3844 default:
45 return false;
46 }
initial.commitd7cae122008-07-26 21:49:3847}
48
49} // namespace base