Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_PLATFORM_FILE_H_ | 5 #ifndef BASE_PLATFORM_FILE_H_ |
| 6 #define BASE_PLATFORM_FILE_H_ | 6 #define BASE_PLATFORM_FILE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "base/time.h" | |
| 10 #if defined(OS_WIN) | 12 #if defined(OS_WIN) |
| 11 #include <windows.h> | 13 #include <windows.h> |
| 12 #endif | 14 #endif |
| 13 | 15 |
| 14 #include <string> | 16 #include <string> |
| 15 | 17 |
| 16 class FilePath; | 18 class FilePath; |
| 17 | 19 |
| 18 namespace base { | 20 namespace base { |
| 19 | 21 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 bool* created, | 65 bool* created, |
| 64 PlatformFileError* error_code); | 66 PlatformFileError* error_code); |
| 65 // Deprecated. | 67 // Deprecated. |
| 66 PlatformFile CreatePlatformFile(const std::wstring& name, | 68 PlatformFile CreatePlatformFile(const std::wstring& name, |
| 67 int flags, | 69 int flags, |
| 68 bool* created); | 70 bool* created); |
| 69 | 71 |
| 70 // Closes a file handle | 72 // Closes a file handle |
| 71 bool ClosePlatformFile(PlatformFile file); | 73 bool ClosePlatformFile(PlatformFile file); |
| 72 | 74 |
| 75 // Used to hold information about a given file. | |
| 76 // If you add more fields to this structure (platform-specific fields are OK), | |
| 77 // make sure to update all functions that use it in file_util_{win|posix}.cc | |
| 78 // too, and the ParamTraits<base::PlatformFileInfo> implementation in | |
| 79 // chrome/common/common_param_traits.cc. | |
| 80 struct PlatformFileInfo { | |
|
darin (slow to review)
2010/09/02 18:19:26
IIRC, the plan is to add more functions to this he
| |
| 81 // The size of the file in bytes. Undefined when is_directory is true. | |
| 82 int64 size; | |
| 83 | |
| 84 // True if the file corresponds to a directory. | |
| 85 bool is_directory; | |
| 86 | |
| 87 // The last modified time of a file. | |
| 88 base::Time last_modified; | |
| 89 | |
| 90 // The last accessed time of a file. | |
| 91 base::Time last_accessed; | |
| 92 | |
| 93 // The creation time of a file. | |
| 94 base::Time creation_time; | |
| 95 }; | |
| 96 | |
| 73 // Use this class to pass ownership of a PlatformFile to a receiver that may or | 97 // Use this class to pass ownership of a PlatformFile to a receiver that may or |
| 74 // may not want to accept it. This class does not own the storage for the | 98 // may not want to accept it. This class does not own the storage for the |
| 75 // PlatformFile. | 99 // PlatformFile. |
| 76 // | 100 // |
| 77 // EXAMPLE: | 101 // EXAMPLE: |
| 78 // | 102 // |
| 79 // void MaybeProcessFile(PassPlatformFile pass_file) { | 103 // void MaybeProcessFile(PassPlatformFile pass_file) { |
| 80 // if (...) { | 104 // if (...) { |
| 81 // PlatformFile file = pass_file.ReleaseValue(); | 105 // PlatformFile file = pass_file.ReleaseValue(); |
| 82 // // Now, we are responsible for closing |file|. | 106 // // Now, we are responsible for closing |file|. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 104 return temp; | 128 return temp; |
| 105 } | 129 } |
| 106 | 130 |
| 107 private: | 131 private: |
| 108 PlatformFile* value_; | 132 PlatformFile* value_; |
| 109 }; | 133 }; |
| 110 | 134 |
| 111 } // namespace base | 135 } // namespace base |
| 112 | 136 |
| 113 #endif // BASE_PLATFORM_FILE_H_ | 137 #endif // BASE_PLATFORM_FILE_H_ |
| OLD | NEW |