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