blob: b90efba0fffb440a02ddeaf3cf05f229574d14ad [file] [log] [blame]
license.botf003cfe2008-08-24 09:55:55 +09001// 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.commit3f4a7322008-07-27 06:49:38 +09004
5#include "base/base_paths.h"
6
initial.commit3f4a7322008-07-27 06:49:38 +09007#include "base/file_util.h"
brettw@chromium.org59eef1f2013-02-24 14:40:52 +09008#include "base/files/file_path.h"
initial.commit3f4a7322008-07-27 06:49:38 +09009#include "base/path_service.h"
10
initial.commit3f4a7322008-07-27 06:49:38 +090011namespace base {
12
evanm@google.com3e9d5d72008-11-20 01:50:03 +090013bool PathProvider(int key, FilePath* result) {
gab@chromium.org97fc1e62012-09-21 01:24:52 +090014 // NOTE: DIR_CURRENT is a special case in PathService::Get
initial.commit3f4a7322008-07-27 06:49:38 +090015
evanm@google.com874d1672008-10-31 08:54:04 +090016 FilePath cur;
initial.commit3f4a7322008-07-27 06:49:38 +090017 switch (key) {
tfarina@chromium.orge6598042013-03-28 09:40:04 +090018 case DIR_EXE:
19 PathService::Get(FILE_EXE, &cur);
evanm@google.com874d1672008-10-31 08:54:04 +090020 cur = cur.DirName();
initial.commit3f4a7322008-07-27 06:49:38 +090021 break;
tfarina@chromium.orge6598042013-03-28 09:40:04 +090022 case DIR_MODULE:
23 PathService::Get(FILE_MODULE, &cur);
evanm@google.com874d1672008-10-31 08:54:04 +090024 cur = cur.DirName();
initial.commit3f4a7322008-07-27 06:49:38 +090025 break;
tfarina@chromium.orge6598042013-03-28 09:40:04 +090026 case DIR_TEMP:
initial.commit3f4a7322008-07-27 06:49:38 +090027 if (!file_util::GetTempDir(&cur))
28 return false;
29 break;
tfarina@chromium.orge6598042013-03-28 09:40:04 +090030 case DIR_TEST_DATA:
31 if (!PathService::Get(DIR_SOURCE_ROOT, &cur))
32 return false;
33 cur = cur.Append(FILE_PATH_LITERAL("base"));
34 cur = cur.Append(FILE_PATH_LITERAL("test"));
35 cur = cur.Append(FILE_PATH_LITERAL("data"));
36 if (!file_util::PathExists(cur)) // We don't want to create this.
37 return false;
38 break;
initial.commit3f4a7322008-07-27 06:49:38 +090039 default:
40 return false;
41 }
42
evanm@google.com3e9d5d72008-11-20 01:50:03 +090043 *result = cur;
initial.commit3f4a7322008-07-27 06:49:38 +090044 return true;
45}
46
47} // namespace base