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_FILES_FILE_H_ | 5 #ifndef BASE_FILES_FILE_H_ |
6 #define BASE_FILES_FILE_H_ | 6 #define BASE_FILES_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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // components. Use only with extreme care. | 164 // components. Use only with extreme care. |
165 void InitializeUnsafe(const FilePath& name, uint32 flags); | 165 void InitializeUnsafe(const FilePath& name, uint32 flags); |
166 | 166 |
167 bool IsValid() const; | 167 bool IsValid() const; |
168 | 168 |
169 // Returns true if a new file was created (or an old one truncated to zero | 169 // Returns true if a new file was created (or an old one truncated to zero |
170 // length to simulate a new file, which can happen with | 170 // length to simulate a new file, which can happen with |
171 // FLAG_CREATE_ALWAYS), and false otherwise. | 171 // FLAG_CREATE_ALWAYS), and false otherwise. |
172 bool created() const { return created_; } | 172 bool created() const { return created_; } |
173 | 173 |
174 // Returns the OS result of opening this file. | 174 // Returns the OS result of opening this file. Note that the way to verify |
| 175 // the success of the operation is to use IsValid(), not this method: |
| 176 // File file(name, flags); |
| 177 // if (!file.IsValid()) |
| 178 // return; |
175 Error error_details() const { return error_details_; } | 179 Error error_details() const { return error_details_; } |
176 | 180 |
177 PlatformFile GetPlatformFile() const { return file_; } | 181 PlatformFile GetPlatformFile() const { return file_; } |
178 PlatformFile TakePlatformFile(); | 182 PlatformFile TakePlatformFile(); |
179 | 183 |
180 // Destroying this object closes the file automatically. | 184 // Destroying this object closes the file automatically. |
181 void Close(); | 185 void Close(); |
182 | 186 |
183 // Changes current position in the file to an |offset| relative to an origin | 187 // Changes current position in the file to an |offset| relative to an origin |
184 // defined by |whence|. Returns the resultant current position in the file | 188 // defined by |whence|. Returns the resultant current position in the file |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 #endif | 281 #endif |
278 | 282 |
279 Error error_details_; | 283 Error error_details_; |
280 bool created_; | 284 bool created_; |
281 bool async_; | 285 bool async_; |
282 }; | 286 }; |
283 | 287 |
284 } // namespace base | 288 } // namespace base |
285 | 289 |
286 #endif // BASE_FILES_FILE_H_ | 290 #endif // BASE_FILES_FILE_H_ |
OLD | NEW |