| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 // This explicit mapping matches both FILE_ on Windows and SEEK_ on Linux. | 122 // This explicit mapping matches both FILE_ on Windows and SEEK_ on Linux. |
| 123 enum Whence { | 123 enum Whence { |
| 124 FROM_BEGIN = 0, | 124 FROM_BEGIN = 0, |
| 125 FROM_CURRENT = 1, | 125 FROM_CURRENT = 1, |
| 126 FROM_END = 2 | 126 FROM_END = 2 |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 // Used to hold information about a given file. | 129 // Used to hold information about a given file. |
| 130 // If you add more fields to this structure (platform-specific fields are OK), | 130 // If you add more fields to this structure (platform-specific fields are OK), |
| 131 // make sure to update all functions that use it in file_util_{win|posix}.cc | 131 // make sure to update all functions that use it in file_util_{win|posix}.cc, |
| 132 // too, and the ParamTraits<base::PlatformFileInfo> implementation in | 132 // too, and the ParamTraits<base::File::Info> implementation in |
| 133 // chrome/common/common_param_traits.cc. | 133 // ipc/ipc_message_utils.cc. |
| 134 struct BASE_EXPORT Info { | 134 struct BASE_EXPORT Info { |
| 135 Info(); | 135 Info(); |
| 136 ~Info(); | 136 ~Info(); |
| 137 #if defined(OS_POSIX) | 137 #if defined(OS_POSIX) |
| 138 // Fills this struct with values from |stat_info|. | 138 // Fills this struct with values from |stat_info|. |
| 139 void FromStat(const stat_wrapper_t& stat_info); | 139 void FromStat(const stat_wrapper_t& stat_info); |
| 140 #endif | 140 #endif |
| 141 | 141 |
| 142 // The size of the file in bytes. Undefined when is_directory is true. | 142 // The size of the file in bytes. Undefined when is_directory is true. |
| 143 int64 size; | 143 int64 size; |
| 144 | 144 |
| 145 // True if the file corresponds to a directory. | 145 // True if the file corresponds to a directory. |
| 146 bool is_directory; | 146 bool is_directory; |
| 147 | 147 |
| 148 // True if the file corresponds to a symbolic link. | 148 // True if the file corresponds to a symbolic link. For Windows currently |
| 149 // not supported and thus always false. |
| 149 bool is_symbolic_link; | 150 bool is_symbolic_link; |
| 150 | 151 |
| 151 // The last modified time of a file. | 152 // The last modified time of a file. |
| 152 base::Time last_modified; | 153 base::Time last_modified; |
| 153 | 154 |
| 154 // The last accessed time of a file. | 155 // The last accessed time of a file. |
| 155 base::Time last_accessed; | 156 base::Time last_accessed; |
| 156 | 157 |
| 157 // The creation time of a file. | 158 // The creation time of a file. |
| 158 base::Time creation_time; | 159 base::Time creation_time; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // POSIX-specific semantics: | 281 // POSIX-specific semantics: |
| 281 // * Locks are advisory only. | 282 // * Locks are advisory only. |
| 282 // * 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) |
| 283 // will succeed. | 284 // will succeed. |
| 284 // * Closing any descriptor on a given file releases the lock. | 285 // * Closing any descriptor on a given file releases the lock. |
| 285 Error Lock(); | 286 Error Lock(); |
| 286 | 287 |
| 287 // Unlock a file previously locked. | 288 // Unlock a file previously locked. |
| 288 Error Unlock(); | 289 Error Unlock(); |
| 289 | 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 |
| 290 bool async() const { return async_; } | 298 bool async() const { return async_; } |
| 291 | 299 |
| 292 #if defined(OS_WIN) | 300 #if defined(OS_WIN) |
| 293 static Error OSErrorToFileError(DWORD last_error); | 301 static Error OSErrorToFileError(DWORD last_error); |
| 294 #elif defined(OS_POSIX) | 302 #elif defined(OS_POSIX) |
| 295 static Error OSErrorToFileError(int saved_errno); | 303 static Error OSErrorToFileError(int saved_errno); |
| 296 #endif | 304 #endif |
| 297 | 305 |
| 298 // 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. |
| 299 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... |
| 355 #endif | 363 #endif |
| 356 | 364 |
| 357 Error error_details_; | 365 Error error_details_; |
| 358 bool created_; | 366 bool created_; |
| 359 bool async_; | 367 bool async_; |
| 360 }; | 368 }; |
| 361 | 369 |
| 362 } // namespace base | 370 } // namespace base |
| 363 | 371 |
| 364 #endif // BASE_FILES_FILE_H_ | 372 #endif // BASE_FILES_FILE_H_ |
| OLD | NEW |