| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Defines base::PathProviderPosix, default path provider on POSIX OSes that | 5 // Defines base::PathProviderPosix, default path provider on POSIX OSes that | 
| 6 // don't have their own base_paths_OS.cc implementation (i.e. all but Mac and | 6 // don't have their own base_paths_OS.cc implementation (i.e. all but Mac and | 
| 7 // Android). | 7 // Android). | 
| 8 | 8 | 
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" | 
| 10 | 10 | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 52       size_t length = sizeof(bin_dir); | 52       size_t length = sizeof(bin_dir); | 
| 53       // Upon return, |length| is the number of bytes written to |bin_dir| | 53       // Upon return, |length| is the number of bytes written to |bin_dir| | 
| 54       // including the string terminator. | 54       // including the string terminator. | 
| 55       int error = sysctl(name, 4, bin_dir, &length, NULL, 0); | 55       int error = sysctl(name, 4, bin_dir, &length, NULL, 0); | 
| 56       if (error < 0 || length <= 1) { | 56       if (error < 0 || length <= 1) { | 
| 57         NOTREACHED() << "Unable to resolve path."; | 57         NOTREACHED() << "Unable to resolve path."; | 
| 58         return false; | 58         return false; | 
| 59       } | 59       } | 
| 60       *result = FilePath(FilePath::StringType(bin_dir, length - 1)); | 60       *result = FilePath(FilePath::StringType(bin_dir, length - 1)); | 
| 61       return true; | 61       return true; | 
|  | 62 #elif defined(OS_FUCHSIA) | 
|  | 63       // TODO(scottmg): Port: There isn't any obvious way to get this before | 
|  | 64       // main() at the moment. | 
|  | 65       *result = FilePath("/system/chrome"); | 
|  | 66       return true; | 
| 62 #elif defined(OS_SOLARIS) | 67 #elif defined(OS_SOLARIS) | 
| 63       char bin_dir[PATH_MAX + 1]; | 68       char bin_dir[PATH_MAX + 1]; | 
| 64       if (realpath(getexecname(), bin_dir) == NULL) { | 69       if (realpath(getexecname(), bin_dir) == NULL) { | 
| 65         NOTREACHED() << "Unable to resolve " << getexecname() << "."; | 70         NOTREACHED() << "Unable to resolve " << getexecname() << "."; | 
| 66         return false; | 71         return false; | 
| 67       } | 72       } | 
| 68       *result = FilePath(bin_dir); | 73       *result = FilePath(bin_dir); | 
| 69       return true; | 74       return true; | 
| 70 #elif defined(OS_OPENBSD) | 75 #elif defined(OS_OPENBSD) | 
| 71       // There is currently no way to get the executable path on OpenBSD | 76       // There is currently no way to get the executable path on OpenBSD | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 95       // For example:  out/{Debug|Release}/net_unittest | 100       // For example:  out/{Debug|Release}/net_unittest | 
| 96       if (PathService::Get(DIR_EXE, &path)) { | 101       if (PathService::Get(DIR_EXE, &path)) { | 
| 97         *result = path.DirName().DirName(); | 102         *result = path.DirName().DirName(); | 
| 98         return true; | 103         return true; | 
| 99       } | 104       } | 
| 100 | 105 | 
| 101       DLOG(ERROR) << "Couldn't find your source root.  " | 106       DLOG(ERROR) << "Couldn't find your source root.  " | 
| 102                   << "Try running from your chromium/src directory."; | 107                   << "Try running from your chromium/src directory."; | 
| 103       return false; | 108       return false; | 
| 104     } | 109     } | 
|  | 110 #if !defined(OS_FUCHSIA) | 
| 105     case DIR_USER_DESKTOP: | 111     case DIR_USER_DESKTOP: | 
| 106       *result = nix::GetXDGUserDirectory("DESKTOP", "Desktop"); | 112       *result = nix::GetXDGUserDirectory("DESKTOP", "Desktop"); | 
| 107       return true; | 113       return true; | 
| 108     case DIR_CACHE: { | 114     case DIR_CACHE: { | 
| 109       std::unique_ptr<Environment> env(Environment::Create()); | 115       std::unique_ptr<Environment> env(Environment::Create()); | 
| 110       FilePath cache_dir( | 116       FilePath cache_dir( | 
| 111           nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", ".cache")); | 117           nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", ".cache")); | 
| 112       *result = cache_dir; | 118       *result = cache_dir; | 
| 113       return true; | 119       return true; | 
| 114     } | 120     } | 
|  | 121 #endif  // !OS_FUCHSIA | 
| 115   } | 122   } | 
| 116   return false; | 123   return false; | 
| 117 } | 124 } | 
| 118 | 125 | 
| 119 }  // namespace base | 126 }  // namespace base | 
| OLD | NEW | 
|---|