OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 9 #include "build/build_config.h" |
10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Closes a file handle. Returns |true| on success and |false| otherwise. | 116 // Closes a file handle. Returns |true| on success and |false| otherwise. |
117 BASE_EXPORT bool ClosePlatformFile(PlatformFile file); | 117 BASE_EXPORT bool ClosePlatformFile(PlatformFile file); |
118 | 118 |
119 // Reads the given number of bytes (or until EOF is reached) starting with the | 119 // Reads the given number of bytes (or until EOF is reached) starting with the |
120 // given offset. Returns the number of bytes read, or -1 on error. | 120 // given offset. Returns the number of bytes read, or -1 on error. |
121 BASE_EXPORT int ReadPlatformFile(PlatformFile file, int64 offset, | 121 BASE_EXPORT int ReadPlatformFile(PlatformFile file, int64 offset, |
122 char* data, int size); | 122 char* data, int size); |
123 | 123 |
124 // Writes the given buffer into the file at the given offset, overwritting any | 124 // Writes the given buffer into the file at the given offset, overwritting any |
125 // data that was previously there. Returns the number of bytes written, or -1 | 125 // data that was previously there. Returns the number of bytes written, or -1 |
126 // on error. | 126 // on error. Note that this function makes a best effort to write all data on |
| 127 // all platforms. |
127 BASE_EXPORT int WritePlatformFile(PlatformFile file, int64 offset, | 128 BASE_EXPORT int WritePlatformFile(PlatformFile file, int64 offset, |
128 const char* data, int size); | 129 const char* data, int size); |
129 | 130 |
130 // Truncates the given file to the given length. If |length| is greater than | 131 // Truncates the given file to the given length. If |length| is greater than |
131 // the current size of the file, the file is extended with zeros. If the file | 132 // the current size of the file, the file is extended with zeros. If the file |
132 // doesn't exist, |false| is returned. | 133 // doesn't exist, |false| is returned. |
133 BASE_EXPORT bool TruncatePlatformFile(PlatformFile file, int64 length); | 134 BASE_EXPORT bool TruncatePlatformFile(PlatformFile file, int64 length); |
134 | 135 |
135 // Flushes the buffers of the given file. | 136 // Flushes the buffers of the given file. |
136 BASE_EXPORT bool FlushPlatformFile(PlatformFile file); | 137 BASE_EXPORT bool FlushPlatformFile(PlatformFile file); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return temp; | 178 return temp; |
178 } | 179 } |
179 | 180 |
180 private: | 181 private: |
181 PlatformFile* value_; | 182 PlatformFile* value_; |
182 }; | 183 }; |
183 | 184 |
184 } // namespace base | 185 } // namespace base |
185 | 186 |
186 #endif // BASE_PLATFORM_FILE_H_ | 187 #endif // BASE_PLATFORM_FILE_H_ |
OLD | NEW |