1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/sandbox/chromium/base/base_paths.cc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,47 @@ 1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#include "base/base_paths.h" 1.9 + 1.10 +#include "base/file_util.h" 1.11 +#include "base/files/file_path.h" 1.12 +#include "base/path_service.h" 1.13 + 1.14 +namespace base { 1.15 + 1.16 +bool PathProvider(int key, FilePath* result) { 1.17 + // NOTE: DIR_CURRENT is a special case in PathService::Get 1.18 + 1.19 + FilePath cur; 1.20 + switch (key) { 1.21 + case DIR_EXE: 1.22 + PathService::Get(FILE_EXE, &cur); 1.23 + cur = cur.DirName(); 1.24 + break; 1.25 + case DIR_MODULE: 1.26 + PathService::Get(FILE_MODULE, &cur); 1.27 + cur = cur.DirName(); 1.28 + break; 1.29 + case DIR_TEMP: 1.30 + if (!file_util::GetTempDir(&cur)) 1.31 + return false; 1.32 + break; 1.33 + case DIR_TEST_DATA: 1.34 + if (!PathService::Get(DIR_SOURCE_ROOT, &cur)) 1.35 + return false; 1.36 + cur = cur.Append(FILE_PATH_LITERAL("base")); 1.37 + cur = cur.Append(FILE_PATH_LITERAL("test")); 1.38 + cur = cur.Append(FILE_PATH_LITERAL("data")); 1.39 + if (!base::PathExists(cur)) // We don't want to create this. 1.40 + return false; 1.41 + break; 1.42 + default: 1.43 + return false; 1.44 + } 1.45 + 1.46 + *result = cur; 1.47 + return true; 1.48 +} 1.49 + 1.50 +} // namespace base