Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: base/base_paths_linux.cc

Issue 11252: Move more code to using FilePath. (Closed)
Patch Set: rebased Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/base_paths.cc ('k') | base/base_paths_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/base_paths_linux.h" 5 #include "base/base_paths_linux.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/string_piece.h" 13 #include "base/string_piece.h"
14 #include "base/sys_string_conversions.h" 14 #include "base/sys_string_conversions.h"
15 15
16 namespace base { 16 namespace base {
17 17
18 bool PathProviderLinux(int key, std::wstring* result) { 18 bool PathProviderLinux(int key, FilePath* result) {
19 FilePath path; 19 FilePath path;
20 switch (key) { 20 switch (key) {
21 case base::FILE_EXE: 21 case base::FILE_EXE:
22 case base::FILE_MODULE: { // TODO(evanm): is this correct? 22 case base::FILE_MODULE: { // TODO(evanm): is this correct?
23 char bin_dir[PATH_MAX + 1]; 23 char bin_dir[PATH_MAX + 1];
24 int bin_dir_size = readlink("/proc/self/exe", bin_dir, PATH_MAX); 24 int bin_dir_size = readlink("/proc/self/exe", bin_dir, PATH_MAX);
25 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) { 25 if (bin_dir_size < 0 || bin_dir_size > PATH_MAX) {
26 NOTREACHED() << "Unable to resolve /proc/self/exe."; 26 NOTREACHED() << "Unable to resolve /proc/self/exe.";
27 return false; 27 return false;
28 } 28 }
29 bin_dir[bin_dir_size] = 0; 29 bin_dir[bin_dir_size] = 0;
30 *result = base::SysNativeMBToWide(bin_dir); 30 *result = FilePath(bin_dir);
31 return true; 31 return true;
32 } 32 }
33 case base::DIR_SOURCE_ROOT: 33 case base::DIR_SOURCE_ROOT:
34 // On linux, unit tests execute two levels deep from the source root. 34 // On linux, unit tests execute two levels deep from the source root.
35 // For example: chrome/{Debug|Hammer}/net_unittest 35 // For example: chrome/{Debug|Hammer}/net_unittest
36 if (!PathService::Get(base::DIR_EXE, &path)) 36 if (!PathService::Get(base::DIR_EXE, &path))
37 return false; 37 return false;
38 path = path.Append(FilePath::kParentDirectory) 38 path = path.Append(FilePath::kParentDirectory)
39 .Append(FilePath::kParentDirectory); 39 .Append(FilePath::kParentDirectory);
40 *result = path.ToWStringHack(); 40 *result = path;
41 return true; 41 return true;
42 } 42 }
43 return false; 43 return false;
44 } 44 }
45 45
46 } // namespace base 46 } // namespace base
47 47
OLDNEW
« no previous file with comments | « base/base_paths.cc ('k') | base/base_paths_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698