| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/base_export.h" | 12 #include "base/base_export.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/files/file_tracing.h" | 14 #include "base/files/file_tracing.h" |
| 15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
| 16 #include "base/move.h" | 16 #include "base/macros.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 | 19 |
| 20 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 21 #include <windows.h> | 21 #include <windows.h> |
| 22 #include "base/win/scoped_handle.h" | 22 #include "base/win/scoped_handle.h" |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 #if defined(OS_POSIX) | 25 #if defined(OS_POSIX) |
| 26 #include <sys/stat.h> | 26 #include <sys/stat.h> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 47 // Note that this class does not provide any support for asynchronous IO, other | 47 // Note that this class does not provide any support for asynchronous IO, other |
| 48 // than the ability to create asynchronous handles on Windows. | 48 // than the ability to create asynchronous handles on Windows. |
| 49 // | 49 // |
| 50 // Note about const: this class does not attempt to determine if the underlying | 50 // Note about const: this class does not attempt to determine if the underlying |
| 51 // file system object is affected by a particular method in order to consider | 51 // file system object is affected by a particular method in order to consider |
| 52 // that method const or not. Only methods that deal with member variables in an | 52 // that method const or not. Only methods that deal with member variables in an |
| 53 // obvious non-modifying way are marked as const. Any method that forward calls | 53 // obvious non-modifying way are marked as const. Any method that forward calls |
| 54 // to the OS is not considered const, even if there is no apparent change to | 54 // to the OS is not considered const, even if there is no apparent change to |
| 55 // member variables. | 55 // member variables. |
| 56 class BASE_EXPORT File { | 56 class BASE_EXPORT File { |
| 57 MOVE_ONLY_TYPE_FOR_CPP_03(File) | |
| 58 | |
| 59 public: | 57 public: |
| 60 // FLAG_(OPEN|CREATE).* are mutually exclusive. You should specify exactly one | 58 // FLAG_(OPEN|CREATE).* are mutually exclusive. You should specify exactly one |
| 61 // of the five (possibly combining with other flags) when opening or creating | 59 // of the five (possibly combining with other flags) when opening or creating |
| 62 // a file. | 60 // a file. |
| 63 // FLAG_(WRITE|APPEND) are mutually exclusive. This is so that APPEND behavior | 61 // FLAG_(WRITE|APPEND) are mutually exclusive. This is so that APPEND behavior |
| 64 // will be consistent with O_APPEND on POSIX. | 62 // will be consistent with O_APPEND on POSIX. |
| 65 // FLAG_EXCLUSIVE_(READ|WRITE) only grant exclusive access to the file on | 63 // FLAG_EXCLUSIVE_(READ|WRITE) only grant exclusive access to the file on |
| 66 // creation on POSIX; for existing files, consider using Lock(). | 64 // creation on POSIX; for existing files, consider using Lock(). |
| 67 enum Flags { | 65 enum Flags { |
| 68 FLAG_OPEN = 1 << 0, // Opens a file, only if it exists. | 66 FLAG_OPEN = 1 << 0, // Opens a file, only if it exists. |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 // A path to use for tracing purposes. Set if file tracing is enabled during | 325 // A path to use for tracing purposes. Set if file tracing is enabled during |
| 328 // |Initialize()|. | 326 // |Initialize()|. |
| 329 FilePath tracing_path_; | 327 FilePath tracing_path_; |
| 330 | 328 |
| 331 // Object tied to the lifetime of |this| that enables/disables tracing. | 329 // Object tied to the lifetime of |this| that enables/disables tracing. |
| 332 FileTracing::ScopedEnabler trace_enabler_; | 330 FileTracing::ScopedEnabler trace_enabler_; |
| 333 | 331 |
| 334 Error error_details_; | 332 Error error_details_; |
| 335 bool created_; | 333 bool created_; |
| 336 bool async_; | 334 bool async_; |
| 335 |
| 336 DISALLOW_COPY_AND_ASSIGN(File); |
| 337 }; | 337 }; |
| 338 | 338 |
| 339 } // namespace base | 339 } // namespace base |
| 340 | 340 |
| 341 #endif // BASE_FILES_FILE_H_ | 341 #endif // BASE_FILES_FILE_H_ |
| 342 | 342 |
| OLD | NEW |