Chromium Code Reviews| 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 // This file contains utility functions for dealing with the local | 5 // This file contains utility functions for dealing with the local |
| 6 // filesystem. | 6 // filesystem. |
| 7 | 7 |
| 8 #ifndef BASE_FILES_FILE_UTIL_H_ | 8 #ifndef BASE_FILES_FILE_UTIL_H_ |
| 9 #define BASE_FILES_FILE_UTIL_H_ | 9 #define BASE_FILES_FILE_UTIL_H_ |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 #if defined(OS_POSIX) | 32 #if defined(OS_POSIX) |
| 33 #include "base/file_descriptor_posix.h" | 33 #include "base/file_descriptor_posix.h" |
| 34 #include "base/logging.h" | 34 #include "base/logging.h" |
| 35 #include "base/posix/eintr_wrapper.h" | 35 #include "base/posix/eintr_wrapper.h" |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 namespace base { | 38 namespace base { |
| 39 | 39 |
| 40 class Time; | 40 class Time; |
| 41 class Environment; | |
|
Lei Zhang
2016/06/23 19:17:06
nit: alphabetical order
Tom (Use chromium acct)
2016/06/23 21:55:12
Done.
| |
| 41 | 42 |
| 42 //----------------------------------------------------------------------------- | 43 //----------------------------------------------------------------------------- |
| 43 // Functions that involve filesystem access or modification: | 44 // Functions that involve filesystem access or modification: |
| 44 | 45 |
| 45 // Returns an absolute version of a relative path. Returns an empty path on | 46 // Returns an absolute version of a relative path. Returns an empty path on |
| 46 // error. On POSIX, this function fails if the path does not exist. This | 47 // error. On POSIX, this function fails if the path does not exist. This |
| 47 // function can result in I/O so it can be slow. | 48 // function can result in I/O so it can be slow. |
| 48 BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); | 49 BASE_EXPORT FilePath MakeAbsoluteFilePath(const FilePath& input); |
| 49 | 50 |
| 50 // Returns the total number of bytes used by all the files under |root_path|. | 51 // Returns the total number of bytes used by all the files under |root_path|. |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 }; | 193 }; |
| 193 | 194 |
| 194 // Reads the permission of the given |path|, storing the file permission | 195 // Reads the permission of the given |path|, storing the file permission |
| 195 // bits in |mode|. If |path| is symbolic link, |mode| is the permission of | 196 // bits in |mode|. If |path| is symbolic link, |mode| is the permission of |
| 196 // a file which the symlink points to. | 197 // a file which the symlink points to. |
| 197 BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path, int* mode); | 198 BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path, int* mode); |
| 198 // Sets the permission of the given |path|. If |path| is symbolic link, sets | 199 // Sets the permission of the given |path|. If |path| is symbolic link, sets |
| 199 // the permission of a file which the symlink points to. | 200 // the permission of a file which the symlink points to. |
| 200 BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, int mode); | 201 BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, int mode); |
| 201 | 202 |
| 203 // Returns true iff |executable| can be found in any directory specified by the | |
| 204 // $PATH environment variable. | |
|
Lei Zhang
2016/06/23 19:17:06
... environment variable in |env|.
Tom (Use chromium acct)
2016/06/23 21:55:12
Done.
| |
| 205 BASE_EXPORT bool ExecutableExistsInPath(Environment* env, | |
| 206 const FilePath::StringType& executable); | |
| 207 | |
| 202 #endif // OS_POSIX | 208 #endif // OS_POSIX |
| 203 | 209 |
| 204 // Returns true if the given directory is empty | 210 // Returns true if the given directory is empty |
| 205 BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path); | 211 BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path); |
| 206 | 212 |
| 207 // Get the temporary directory provided by the system. | 213 // Get the temporary directory provided by the system. |
| 208 // | 214 // |
| 209 // WARNING: In general, you should use CreateTemporaryFile variants below | 215 // WARNING: In general, you should use CreateTemporaryFile variants below |
| 210 // instead of this function. Those variants will ensure that the proper | 216 // instead of this function. Those variants will ensure that the proper |
| 211 // permissions are set so that other users on the system can't edit them while | 217 // permissions are set so that other users on the system can't edit them while |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 // This function simulates Move(), but unlike Move() it works across volumes. | 441 // This function simulates Move(), but unlike Move() it works across volumes. |
| 436 // This function is not transactional. | 442 // This function is not transactional. |
| 437 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, | 443 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, |
| 438 const FilePath& to_path); | 444 const FilePath& to_path); |
| 439 #endif // defined(OS_WIN) | 445 #endif // defined(OS_WIN) |
| 440 | 446 |
| 441 } // namespace internal | 447 } // namespace internal |
| 442 } // namespace base | 448 } // namespace base |
| 443 | 449 |
| 444 #endif // BASE_FILES_FILE_UTIL_H_ | 450 #endif // BASE_FILES_FILE_UTIL_H_ |
| OLD | NEW |