Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #include "base/base_paths.h" |
michael@0 | 6 | |
michael@0 | 7 | #include "base/file_util.h" |
michael@0 | 8 | #include "base/files/file_path.h" |
michael@0 | 9 | #include "base/path_service.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace base { |
michael@0 | 12 | |
michael@0 | 13 | bool PathProvider(int key, FilePath* result) { |
michael@0 | 14 | // NOTE: DIR_CURRENT is a special case in PathService::Get |
michael@0 | 15 | |
michael@0 | 16 | FilePath cur; |
michael@0 | 17 | switch (key) { |
michael@0 | 18 | case DIR_EXE: |
michael@0 | 19 | PathService::Get(FILE_EXE, &cur); |
michael@0 | 20 | cur = cur.DirName(); |
michael@0 | 21 | break; |
michael@0 | 22 | case DIR_MODULE: |
michael@0 | 23 | PathService::Get(FILE_MODULE, &cur); |
michael@0 | 24 | cur = cur.DirName(); |
michael@0 | 25 | break; |
michael@0 | 26 | case DIR_TEMP: |
michael@0 | 27 | if (!file_util::GetTempDir(&cur)) |
michael@0 | 28 | return false; |
michael@0 | 29 | break; |
michael@0 | 30 | case DIR_TEST_DATA: |
michael@0 | 31 | if (!PathService::Get(DIR_SOURCE_ROOT, &cur)) |
michael@0 | 32 | return false; |
michael@0 | 33 | cur = cur.Append(FILE_PATH_LITERAL("base")); |
michael@0 | 34 | cur = cur.Append(FILE_PATH_LITERAL("test")); |
michael@0 | 35 | cur = cur.Append(FILE_PATH_LITERAL("data")); |
michael@0 | 36 | if (!base::PathExists(cur)) // We don't want to create this. |
michael@0 | 37 | return false; |
michael@0 | 38 | break; |
michael@0 | 39 | default: |
michael@0 | 40 | return false; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | *result = cur; |
michael@0 | 44 | return true; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | } // namespace base |