| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_FILE_UTIL_H_ | 8 #ifndef BASE_FILE_UTIL_H_ |
| 9 #define BASE_FILE_UTIL_H_ | 9 #define BASE_FILE_UTIL_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // Read the file at |path| into |contents|, returning true on success. | 173 // Read the file at |path| into |contents|, returning true on success. |
| 174 // |contents| may be NULL, in which case this function is useful for its | 174 // |contents| may be NULL, in which case this function is useful for its |
| 175 // side effect of priming the disk cache. | 175 // side effect of priming the disk cache. |
| 176 // Useful for unit tests. | 176 // Useful for unit tests. |
| 177 BASE_API bool ReadFileToString(const FilePath& path, std::string* contents); | 177 BASE_API bool ReadFileToString(const FilePath& path, std::string* contents); |
| 178 | 178 |
| 179 #if defined(OS_POSIX) | 179 #if defined(OS_POSIX) |
| 180 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result | 180 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result |
| 181 // in |buffer|. This function is protected against EINTR and partial reads. | 181 // in |buffer|. This function is protected against EINTR and partial reads. |
| 182 // Returns true iff |bytes| bytes have been successfuly read from |fd|. | 182 // Returns true iff |bytes| bytes have been successfuly read from |fd|. |
| 183 bool ReadFromFD(int fd, char* buffer, size_t bytes); | 183 BASE_API bool ReadFromFD(int fd, char* buffer, size_t bytes); |
| 184 | 184 |
| 185 // Creates a symbolic link at |symlink| pointing to |target|. Returns | 185 // Creates a symbolic link at |symlink| pointing to |target|. Returns |
| 186 // false on failure. | 186 // false on failure. |
| 187 bool CreateSymbolicLink(const FilePath& target, const FilePath& symlink); | 187 BASE_API bool CreateSymbolicLink(const FilePath& target, |
| 188 const FilePath& symlink); |
| 188 | 189 |
| 189 // Reads the given |symlink| and returns where it points to in |target|. | 190 // Reads the given |symlink| and returns where it points to in |target|. |
| 190 // Returns false upon failure. | 191 // Returns false upon failure. |
| 191 bool ReadSymbolicLink(const FilePath& symlink, FilePath* target); | 192 BASE_API bool ReadSymbolicLink(const FilePath& symlink, FilePath* target); |
| 192 #endif // defined(OS_POSIX) | 193 #endif // defined(OS_POSIX) |
| 193 | 194 |
| 194 #if defined(OS_WIN) | 195 #if defined(OS_WIN) |
| 195 // Resolve Windows shortcut (.LNK file) | 196 // Resolve Windows shortcut (.LNK file) |
| 196 // This methods tries to resolve a shortcut .LNK file. If the |path| is valid | 197 // This methods tries to resolve a shortcut .LNK file. If the |path| is valid |
| 197 // returns true and puts the target into the |path|, otherwise returns | 198 // returns true and puts the target into the |path|, otherwise returns |
| 198 // false leaving the path as it is. | 199 // false leaving the path as it is. |
| 199 BASE_API bool ResolveShortcut(FilePath* path); | 200 BASE_API bool ResolveShortcut(FilePath* path); |
| 200 | 201 |
| 201 // Create a Windows shortcut (.LNK file) | 202 // Create a Windows shortcut (.LNK file) |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 651 bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
| 651 #endif | 652 #endif |
| 652 | 653 |
| 653 } // namespace file_util | 654 } // namespace file_util |
| 654 | 655 |
| 655 // Deprecated functions have been moved to this separate header file, | 656 // Deprecated functions have been moved to this separate header file, |
| 656 // which must be included last after all the above definitions. | 657 // which must be included last after all the above definitions. |
| 657 #include "base/file_util_deprecated.h" | 658 #include "base/file_util_deprecated.h" |
| 658 | 659 |
| 659 #endif // BASE_FILE_UTIL_H_ | 660 #endif // BASE_FILE_UTIL_H_ |
| OLD | NEW |