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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // POSIX-specific semantics: | 281 // POSIX-specific semantics: |
282 // * Locks are advisory only. | 282 // * Locks are advisory only. |
283 // * Within a process, locking the same file (by the same or new handle) | 283 // * Within a process, locking the same file (by the same or new handle) |
284 // will succeed. | 284 // will succeed. |
285 // * Closing any descriptor on a given file releases the lock. | 285 // * Closing any descriptor on a given file releases the lock. |
286 Error Lock(); | 286 Error Lock(); |
287 | 287 |
288 // Unlock a file previously locked. | 288 // Unlock a file previously locked. |
289 Error Unlock(); | 289 Error Unlock(); |
290 | 290 |
| 291 // Returns a new object referencing this file for use within the current |
| 292 // process. Handling of FLAG_DELETE_ON_CLOSE varies by OS. On POSIX, the File |
| 293 // object that was created or initialized with this flag will have unlinked |
| 294 // the underlying file when it was created or opened. On Windows, the |
| 295 // underlying file is deleted when the last handle to it is closed. |
| 296 File Duplicate(); |
| 297 |
291 bool async() const { return async_; } | 298 bool async() const { return async_; } |
292 | 299 |
293 #if defined(OS_WIN) | 300 #if defined(OS_WIN) |
294 static Error OSErrorToFileError(DWORD last_error); | 301 static Error OSErrorToFileError(DWORD last_error); |
295 #elif defined(OS_POSIX) | 302 #elif defined(OS_POSIX) |
296 static Error OSErrorToFileError(int saved_errno); | 303 static Error OSErrorToFileError(int saved_errno); |
297 #endif | 304 #endif |
298 | 305 |
299 // Converts an error value to a human-readable form. Used for logging. | 306 // Converts an error value to a human-readable form. Used for logging. |
300 static std::string ErrorToString(Error error); | 307 static std::string ErrorToString(Error error); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 #endif | 363 #endif |
357 | 364 |
358 Error error_details_; | 365 Error error_details_; |
359 bool created_; | 366 bool created_; |
360 bool async_; | 367 bool async_; |
361 }; | 368 }; |
362 | 369 |
363 } // namespace base | 370 } // namespace base |
364 | 371 |
365 #endif // BASE_FILES_FILE_H_ | 372 #endif // BASE_FILES_FILE_H_ |
OLD | NEW |