| 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 #ifndef BASE_PLATFORM_FILE_H_ | 5 #ifndef BASE_PLATFORM_FILE_H_ |
| 6 #define BASE_PLATFORM_FILE_H_ | 6 #define BASE_PLATFORM_FILE_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // The last accessed time of a file. | 112 // The last accessed time of a file. |
| 113 base::Time last_accessed; | 113 base::Time last_accessed; |
| 114 | 114 |
| 115 // The creation time of a file. | 115 // The creation time of a file. |
| 116 base::Time creation_time; | 116 base::Time creation_time; |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 // Creates or opens the given file. If |created| is provided, it will be set to | 119 // Creates or opens the given file. If |created| is provided, it will be set to |
| 120 // true if a new file was created [or an old one truncated to zero length to | 120 // true if a new file was created [or an old one truncated to zero length to |
| 121 // simulate a new file, which can happen with PLATFORM_FILE_CREATE_ALWAYS], and | 121 // simulate a new file, which can happen with PLATFORM_FILE_CREATE_ALWAYS], and |
| 122 // false otherwise. |error_code| can be NULL. | 122 // false otherwise. |error| can be NULL. |
| 123 // |
| 124 // This function fails with 'access denied' if the |name| contains path |
| 125 // traversal components. |
| 123 BASE_EXPORT PlatformFile CreatePlatformFile(const FilePath& name, | 126 BASE_EXPORT PlatformFile CreatePlatformFile(const FilePath& name, |
| 124 int flags, | 127 int flags, |
| 125 bool* created, | 128 bool* created, |
| 126 PlatformFileError* error_code); | 129 PlatformFileError* error); |
| 130 |
| 131 // Same as CreatePlatformFile but allows paths with traversal (like \..\) |
| 132 // components. Use only with extreme care. |
| 133 BASE_EXPORT PlatformFile CreatePlatformFileUnsafe(const FilePath& name, |
| 134 int flags, |
| 135 bool* created, |
| 136 PlatformFileError* error); |
| 127 | 137 |
| 128 // Closes a file handle. Returns |true| on success and |false| otherwise. | 138 // Closes a file handle. Returns |true| on success and |false| otherwise. |
| 129 BASE_EXPORT bool ClosePlatformFile(PlatformFile file); | 139 BASE_EXPORT bool ClosePlatformFile(PlatformFile file); |
| 130 | 140 |
| 131 // Changes current position in the file to an |offset| relative to an origin | 141 // Changes current position in the file to an |offset| relative to an origin |
| 132 // defined by |whence|. Returns the resultant current position in the file | 142 // defined by |whence|. Returns the resultant current position in the file |
| 133 // (relative to the start) or -1 in case of error. | 143 // (relative to the start) or -1 in case of error. |
| 134 BASE_EXPORT int64 SeekPlatformFile(PlatformFile file, | 144 BASE_EXPORT int64 SeekPlatformFile(PlatformFile file, |
| 135 PlatformFileWhence whence, | 145 PlatformFileWhence whence, |
| 136 int64 offset); | 146 int64 offset); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 return temp; | 233 return temp; |
| 224 } | 234 } |
| 225 | 235 |
| 226 private: | 236 private: |
| 227 PlatformFile* value_; | 237 PlatformFile* value_; |
| 228 }; | 238 }; |
| 229 | 239 |
| 230 } // namespace base | 240 } // namespace base |
| 231 | 241 |
| 232 #endif // BASE_PLATFORM_FILE_H_ | 242 #endif // BASE_PLATFORM_FILE_H_ |
| OLD | NEW |