OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // |contents| may be NULL, in which case this function is useful for its | 172 // |contents| may be NULL, in which case this function is useful for its |
173 // side effect of priming the disk cache. | 173 // side effect of priming the disk cache. |
174 // Useful for unit tests. | 174 // Useful for unit tests. |
175 bool ReadFileToString(const FilePath& path, std::string* contents); | 175 bool ReadFileToString(const FilePath& path, std::string* contents); |
176 | 176 |
177 #if defined(OS_POSIX) | 177 #if defined(OS_POSIX) |
178 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result | 178 // Read exactly |bytes| bytes from file descriptor |fd|, storing the result |
179 // in |buffer|. This function is protected against EINTR and partial reads. | 179 // in |buffer|. This function is protected against EINTR and partial reads. |
180 // Returns true iff |bytes| bytes have been successfuly read from |fd|. | 180 // Returns true iff |bytes| bytes have been successfuly read from |fd|. |
181 bool ReadFromFD(int fd, char* buffer, size_t bytes); | 181 bool ReadFromFD(int fd, char* buffer, size_t bytes); |
| 182 |
| 183 // Creates a symbolic link at |symlink| pointing to |target|. Returns |
| 184 // false on failure. |
| 185 bool CreateSymbolicLink(const FilePath& target, const FilePath& symlink); |
| 186 |
| 187 // Reads the given |symlink| and returns where it points to in |target|. |
| 188 // Returns false upon failure. |
| 189 bool ReadSymbolicLink(const FilePath& symlink, FilePath* target); |
182 #endif // defined(OS_POSIX) | 190 #endif // defined(OS_POSIX) |
183 | 191 |
184 #if defined(OS_WIN) | 192 #if defined(OS_WIN) |
185 // Resolve Windows shortcut (.LNK file) | 193 // Resolve Windows shortcut (.LNK file) |
186 // This methods tries to resolve a shortcut .LNK file. If the |path| is valid | 194 // This methods tries to resolve a shortcut .LNK file. If the |path| is valid |
187 // returns true and puts the target into the |path|, otherwise returns | 195 // returns true and puts the target into the |path|, otherwise returns |
188 // false leaving the path as it is. | 196 // false leaving the path as it is. |
189 bool ResolveShortcut(FilePath* path); | 197 bool ResolveShortcut(FilePath* path); |
190 | 198 |
191 // Create a Windows shortcut (.LNK file) | 199 // Create a Windows shortcut (.LNK file) |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 bool GetFileSystemType(const FilePath& path, FileSystemType* type); | 624 bool GetFileSystemType(const FilePath& path, FileSystemType* type); |
617 #endif | 625 #endif |
618 | 626 |
619 } // namespace file_util | 627 } // namespace file_util |
620 | 628 |
621 // Deprecated functions have been moved to this separate header file, | 629 // Deprecated functions have been moved to this separate header file, |
622 // which must be included last after all the above definitions. | 630 // which must be included last after all the above definitions. |
623 #include "base/file_util_deprecated.h" | 631 #include "base/file_util_deprecated.h" |
624 | 632 |
625 #endif // BASE_FILE_UTIL_H_ | 633 #endif // BASE_FILE_UTIL_H_ |
OLD | NEW |