blob: e3f322e72a97814b6091dfade98ae25b2e17353b [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:
Sergey Ulanovd5ae68e2018-02-07 20:14:2118 if (!PathService::Get(FILE_EXE, result))
19 return false;
[email protected]ffaee18e2014-02-19 20:34:2320 *result = result->DirName();
21 return true;
[email protected]c4803e432013-03-28 00:40:0422 case DIR_MODULE:
Sergey Ulanovd5ae68e2018-02-07 20:14:2123 if (!PathService::Get(FILE_MODULE, result))
24 return false;
[email protected]ffaee18e2014-02-19 20:34:2325 *result = result->DirName();
26 return true;
Sergey Ulanovd5ae68e2018-02-07 20:14:2127 case DIR_ASSETS:
28 return PathService::Get(DIR_MODULE, result);
[email protected]c4803e432013-03-28 00:40:0429 case DIR_TEMP:
Sergey Ulanovd5ae68e2018-02-07 20:14:2130 return GetTempDir(result);
[email protected]ffaee18e2014-02-19 20:34:2331 case base::DIR_HOME:
32 *result = GetHomeDir();
33 return true;
maniscalco6e147812015-12-11 18:23:1334 case DIR_TEST_DATA: {
35 FilePath test_data_path;
36 if (!PathService::Get(DIR_SOURCE_ROOT, &test_data_path))
[email protected]c4803e432013-03-28 00:40:0437 return false;
maniscalco6e147812015-12-11 18:23:1338 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.
[email protected]c4803e432013-03-28 00:40:0442 return false;
maniscalco6e147812015-12-11 18:23:1343 *result = test_data_path;
[email protected]ffaee18e2014-02-19 20:34:2344 return true;
maniscalco6e147812015-12-11 18:23:1345 }
initial.commitd7cae122008-07-26 21:49:3846 default:
47 return false;
48 }
initial.commitd7cae122008-07-26 21:49:3849}
50
51} // namespace base