| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // Note that this class does not provide any support for asynchronous IO, other | 46 // Note that this class does not provide any support for asynchronous IO, other |
| 47 // than the ability to create asynchronous handles on Windows. | 47 // than the ability to create asynchronous handles on Windows. |
| 48 // | 48 // |
| 49 // Note about const: this class does not attempt to determine if the underlying | 49 // Note about const: this class does not attempt to determine if the underlying |
| 50 // file system object is affected by a particular method in order to consider | 50 // file system object is affected by a particular method in order to consider |
| 51 // that method const or not. Only methods that deal with member variables in an | 51 // that method const or not. Only methods that deal with member variables in an |
| 52 // obvious non-modifying way are marked as const. Any method that forward calls | 52 // obvious non-modifying way are marked as const. Any method that forward calls |
| 53 // to the OS is not considered const, even if there is no apparent change to | 53 // to the OS is not considered const, even if there is no apparent change to |
| 54 // member variables. | 54 // member variables. |
| 55 class BASE_EXPORT File { | 55 class BASE_EXPORT File { |
| 56 MOVE_ONLY_TYPE_FOR_CPP_03(File, RValue) | 56 MOVE_ONLY_TYPE_FOR_CPP_03(File) |
| 57 | 57 |
| 58 public: | 58 public: |
| 59 // FLAG_(OPEN|CREATE).* are mutually exclusive. You should specify exactly one | 59 // FLAG_(OPEN|CREATE).* are mutually exclusive. You should specify exactly one |
| 60 // of the five (possibly combining with other flags) when opening or creating | 60 // of the five (possibly combining with other flags) when opening or creating |
| 61 // a file. | 61 // a file. |
| 62 // FLAG_(WRITE|APPEND) are mutually exclusive. This is so that APPEND behavior | 62 // FLAG_(WRITE|APPEND) are mutually exclusive. This is so that APPEND behavior |
| 63 // will be consistent with O_APPEND on POSIX. | 63 // will be consistent with O_APPEND on POSIX. |
| 64 // FLAG_EXCLUSIVE_(READ|WRITE) only grant exclusive access to the file on | 64 // FLAG_EXCLUSIVE_(READ|WRITE) only grant exclusive access to the file on |
| 65 // creation on POSIX; for existing files, consider using Lock(). | 65 // creation on POSIX; for existing files, consider using Lock(). |
| 66 enum Flags { | 66 enum Flags { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Creates or opens the given file. This will fail with 'access denied' if the | 162 // Creates or opens the given file. This will fail with 'access denied' if the |
| 163 // |path| contains path traversal ('..') components. | 163 // |path| contains path traversal ('..') components. |
| 164 File(const FilePath& path, uint32 flags); | 164 File(const FilePath& path, uint32 flags); |
| 165 | 165 |
| 166 // Takes ownership of |platform_file|. | 166 // Takes ownership of |platform_file|. |
| 167 explicit File(PlatformFile platform_file); | 167 explicit File(PlatformFile platform_file); |
| 168 | 168 |
| 169 // Creates an object with a specific error_details code. | 169 // Creates an object with a specific error_details code. |
| 170 explicit File(Error error_details); | 170 explicit File(Error error_details); |
| 171 | 171 |
| 172 // Move constructor for C++03 move emulation of this type. | 172 File(File&& other); |
| 173 File(RValue other); | |
| 174 | 173 |
| 175 ~File(); | 174 ~File(); |
| 176 | 175 |
| 177 // Takes ownership of |platform_file|. | 176 // Takes ownership of |platform_file|. |
| 178 static File CreateForAsyncHandle(PlatformFile platform_file); | 177 static File CreateForAsyncHandle(PlatformFile platform_file); |
| 179 | 178 |
| 180 // Move operator= for C++03 move emulation of this type. | 179 File& operator=(File&& other); |
| 181 File& operator=(RValue other); | |
| 182 | 180 |
| 183 // Creates or opens the given file. | 181 // Creates or opens the given file. |
| 184 void Initialize(const FilePath& path, uint32 flags); | 182 void Initialize(const FilePath& path, uint32 flags); |
| 185 | 183 |
| 186 // Returns |true| if the handle / fd wrapped by this object is valid. This | 184 // Returns |true| if the handle / fd wrapped by this object is valid. This |
| 187 // method doesn't interact with the file system (and is safe to be called from | 185 // method doesn't interact with the file system (and is safe to be called from |
| 188 // ThreadRestrictions::SetIOAllowed(false) threads). | 186 // ThreadRestrictions::SetIOAllowed(false) threads). |
| 189 bool IsValid() const; | 187 bool IsValid() const; |
| 190 | 188 |
| 191 // Returns true if a new file was created (or an old one truncated to zero | 189 // Returns true if a new file was created (or an old one truncated to zero |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 332 |
| 335 Error error_details_; | 333 Error error_details_; |
| 336 bool created_; | 334 bool created_; |
| 337 bool async_; | 335 bool async_; |
| 338 }; | 336 }; |
| 339 | 337 |
| 340 } // namespace base | 338 } // namespace base |
| 341 | 339 |
| 342 #endif // BASE_FILES_FILE_H_ | 340 #endif // BASE_FILES_FILE_H_ |
| 343 | 341 |
| OLD | NEW |