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/macros.h" | 16 #include "base/move.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 |
57 public: | 59 public: |
58 // FLAG_(OPEN|CREATE).* are mutually exclusive. You should specify exactly one | 60 // FLAG_(OPEN|CREATE).* are mutually exclusive. You should specify exactly one |
59 // of the five (possibly combining with other flags) when opening or creating | 61 // of the five (possibly combining with other flags) when opening or creating |
60 // a file. | 62 // a file. |
61 // FLAG_(WRITE|APPEND) are mutually exclusive. This is so that APPEND behavior | 63 // FLAG_(WRITE|APPEND) are mutually exclusive. This is so that APPEND behavior |
62 // will be consistent with O_APPEND on POSIX. | 64 // will be consistent with O_APPEND on POSIX. |
63 // FLAG_EXCLUSIVE_(READ|WRITE) only grant exclusive access to the file on | 65 // FLAG_EXCLUSIVE_(READ|WRITE) only grant exclusive access to the file on |
64 // creation on POSIX; for existing files, consider using Lock(). | 66 // creation on POSIX; for existing files, consider using Lock(). |
65 enum Flags { | 67 enum Flags { |
66 FLAG_OPEN = 1 << 0, // Opens a file, only if it exists. | 68 FLAG_OPEN = 1 << 0, // Opens a file, only if it exists. |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // A path to use for tracing purposes. Set if file tracing is enabled during | 327 // A path to use for tracing purposes. Set if file tracing is enabled during |
326 // |Initialize()|. | 328 // |Initialize()|. |
327 FilePath tracing_path_; | 329 FilePath tracing_path_; |
328 | 330 |
329 // Object tied to the lifetime of |this| that enables/disables tracing. | 331 // Object tied to the lifetime of |this| that enables/disables tracing. |
330 FileTracing::ScopedEnabler trace_enabler_; | 332 FileTracing::ScopedEnabler trace_enabler_; |
331 | 333 |
332 Error error_details_; | 334 Error error_details_; |
333 bool created_; | 335 bool created_; |
334 bool async_; | 336 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 |