| 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 | 5 |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This file defines the API to create a file i/o object. | 8 * This file defines the API to create a file i/o object. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 * completion of Open(). | 92 * completion of Open(). |
| 93 * | 93 * |
| 94 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 94 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 95 */ | 95 */ |
| 96 int32_t Open([in] PP_Resource file_io, | 96 int32_t Open([in] PP_Resource file_io, |
| 97 [in] PP_Resource file_ref, | 97 [in] PP_Resource file_ref, |
| 98 [in] int32_t open_flags, | 98 [in] int32_t open_flags, |
| 99 [in] PP_CompletionCallback callback); | 99 [in] PP_CompletionCallback callback); |
| 100 | 100 |
| 101 /** | 101 /** |
| 102 * Query() queries info about the file opened by this FileIO object. The | 102 * Query() queries info about the file opened by this FileIO object. This |
| 103 * FileIO object must be opened, and there must be no other operations | 103 * function will fail if the FileIO object has not been opened. |
| 104 * pending. | |
| 105 * | 104 * |
| 106 * @param[in] file_io A <code>PP_Resource</code> corresponding to a | 105 * @param[in] file_io A <code>PP_Resource</code> corresponding to a |
| 107 * FileIO. | 106 * FileIO. |
| 108 * @param[out] info The <code>PP_FileInfo</code> structure representing all | 107 * @param[out] info The <code>PP_FileInfo</code> structure representing all |
| 109 * information about the file. | 108 * information about the file. |
| 110 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | 109 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 111 * completion of Query(). | 110 * completion of Query(). |
| 112 * | 111 * |
| 113 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 112 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 114 * PP_ERROR_FAILED will be returned if the file isn't opened, and | |
| 115 * PP_ERROR_INPROGRESS will be returned if there is another operation pending. | |
| 116 */ | 113 */ |
| 117 int32_t Query([in] PP_Resource file_io, | 114 int32_t Query([in] PP_Resource file_io, |
| 118 [out] PP_FileInfo info, | 115 [out] PP_FileInfo info, |
| 119 [in] PP_CompletionCallback callback); | 116 [in] PP_CompletionCallback callback); |
| 120 | 117 |
| 121 /** | 118 /** |
| 122 * Touch() Updates time stamps for the file opened by this FileIO object. | 119 * Touch() Updates time stamps for the file opened by this FileIO object. |
| 123 * This function will fail if the FileIO object has not been opened. The | 120 * This function will fail if the FileIO object has not been opened. |
| 124 * FileIO object must be opened, and there must be no other operations | |
| 125 * pending. | |
| 126 * | 121 * |
| 127 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file | 122 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file |
| 128 * FileIO. | 123 * FileIO. |
| 129 * @param[in] last_access_time The last time the FileIO was accessed. | 124 * @param[in] last_access_time The last time the FileIO was accessed. |
| 130 * @param[in] last_modified_time The last time the FileIO was modified. | 125 * @param[in] last_modified_time The last time the FileIO was modified. |
| 131 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | 126 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 132 * completion of Touch(). | 127 * completion of Touch(). |
| 133 * | 128 * |
| 134 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 129 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 135 * PP_ERROR_FAILED will be returned if the file isn't opened, and | |
| 136 * PP_ERROR_INPROGRESS will be returned if there is another operation pending. | |
| 137 */ | 130 */ |
| 138 int32_t Touch([in] PP_Resource file_io, | 131 int32_t Touch([in] PP_Resource file_io, |
| 139 [in] PP_Time last_access_time, | 132 [in] PP_Time last_access_time, |
| 140 [in] PP_Time last_modified_time, | 133 [in] PP_Time last_modified_time, |
| 141 [in] PP_CompletionCallback callback); | 134 [in] PP_CompletionCallback callback); |
| 142 | 135 |
| 143 /** | 136 /** |
| 144 * Read() reads from an offset in the file. The size of the buffer must be | 137 * Read() reads from an offset in the file. The size of the buffer must be |
| 145 * large enough to hold the specified number of bytes to read. This function | 138 * large enough to hold the specified number of bytes to read. This function |
| 146 * might perform a partial read. | 139 * might perform a partial read. |
| 147 * | 140 * |
| 148 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file | 141 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file |
| 149 * FileIO. | 142 * FileIO. |
| 150 * @param[in] offset The offset into the file. | 143 * @param[in] offset The offset into the file. |
| 151 * @param[in] buffer The buffer to hold the specified number of bytes read. | 144 * @param[in] buffer The buffer to hold the specified number of bytes read. |
| 152 * @param[in] bytes_to_read The number of bytes to read from | 145 * @param[in] bytes_to_read The number of bytes to read from |
| 153 * <code>offset</code>. | 146 * <code>offset</code>. |
| 154 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | 147 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 155 * completion of Read(). | 148 * completion of Read(). |
| 156 * | 149 * |
| 157 * @return An The number of bytes read an error code from | 150 * @return An The number of bytes read an error code from |
| 158 * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was | 151 * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was |
| 159 * reached. It is valid to call Read() multiple times with a completion | 152 * reached. It is valid to call Read() multiple times with a completion |
| 160 * callback to queue up parallel reads from the file, but pending reads | 153 * callback to queue up parallel reads from the file at different offsets. |
| 161 * cannot be interleaved with other operations. | |
| 162 */ | 154 */ |
| 163 int32_t Read([in] PP_Resource file_io, | 155 int32_t Read([in] PP_Resource file_io, |
| 164 [in] int64_t offset, | 156 [in] int64_t offset, |
| 165 [inout] str_t buffer, | 157 [inout] str_t buffer, |
| 166 [in] int32_t bytes_to_read, | 158 [in] int32_t bytes_to_read, |
| 167 [in] PP_CompletionCallback callback); | 159 [in] PP_CompletionCallback callback); |
| 168 | 160 |
| 169 /** | 161 /** |
| 170 * Write() writes to an offset in the file. This function might perform a | 162 * Write() writes to an offset in the file. This function might perform a |
| 171 * partial write. The FileIO object must have been opened with write access. | 163 * partial write. The FileIO object must have been opened with write access. |
| 172 * | 164 * |
| 173 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file | 165 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file |
| 174 * FileIO. | 166 * FileIO. |
| 175 * @param[in] offset The offset into the file. | 167 * @param[in] offset The offset into the file. |
| 176 * @param[in] buffer The buffer to hold the specified number of bytes read. | 168 * @param[in] buffer The buffer to hold the specified number of bytes read. |
| 177 * @param[in] bytes_to_write The number of bytes to write to | 169 * @param[in] bytes_to_write The number of bytes to write to |
| 178 * <code>offset</code>. | 170 * <code>offset</code>. |
| 179 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | 171 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 180 * completion of Write(). | 172 * completion of Write(). |
| 181 * | 173 * |
| 182 * @return An The number of bytes written or an error code from | 174 * @return An The number of bytes written or an error code from |
| 183 * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was | 175 * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was |
| 184 * reached. It is valid to call Write() multiple times with a completion | 176 * reached. It is valid to call Write() multiple times with a completion |
| 185 * callback to queue up parallel writes to the file, but pending writes | 177 * callback to queue up parallel writes to the file at different offsets. |
| 186 * cannot be interleaved with other operations. | |
| 187 */ | 178 */ |
| 188 int32_t Write([in] PP_Resource file_io, | 179 int32_t Write([in] PP_Resource file_io, |
| 189 [in] int64_t offset, | 180 [in] int64_t offset, |
| 190 [in] str_t buffer, | 181 [in] str_t buffer, |
| 191 [in] int32_t bytes_to_write, | 182 [in] int32_t bytes_to_write, |
| 192 [in] PP_CompletionCallback callback); | 183 [in] PP_CompletionCallback callback); |
| 193 /** | 184 /** |
| 194 * SetLength() sets the length of the file. If the file size is extended, | 185 * SetLength() sets the length of the file. If the file size is extended, |
| 195 * then the extended area of the file is zero-filled. The FileIO object must | 186 * then the extended area of the file is zero-filled. The FileIO object must |
| 196 * have been opened with write access and there must be no other operations | 187 * have been opened with write access. |
| 197 * pending. | |
| 198 * | 188 * |
| 199 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file | 189 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file |
| 200 * FileIO. | 190 * FileIO. |
| 201 * @param[in] length The length of the file to be set. | 191 * @param[in] length The length of the file to be set. |
| 202 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | 192 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 203 * completion of SetLength(). | 193 * completion of SetLength(). |
| 204 * | 194 * |
| 205 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 195 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 206 * PP_ERROR_FAILED will be returned if the file isn't opened, and | |
| 207 * PP_ERROR_INPROGRESS will be returned if there is another operation pending. | |
| 208 */ | 196 */ |
| 209 int32_t SetLength([in] PP_Resource file_io, | 197 int32_t SetLength([in] PP_Resource file_io, |
| 210 [in] int64_t length, | 198 [in] int64_t length, |
| 211 [in] PP_CompletionCallback callback); | 199 [in] PP_CompletionCallback callback); |
| 212 | 200 |
| 213 /** | 201 /** |
| 214 * Flush() flushes changes to disk. This call can be very expensive! The | 202 * Flush() flushes changes to disk. This call can be very expensive! |
| 215 * FileIO object must have been opened with write access and there must be no | |
| 216 * other operations pending. | |
| 217 * | 203 * |
| 218 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file | 204 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file |
| 219 * FileIO. | 205 * FileIO. |
| 220 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | 206 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 221 * completion of Flush(). | 207 * completion of Flush(). |
| 222 * | 208 * |
| 223 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | 209 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 224 * PP_ERROR_FAILED will be returned if the file isn't opened, and | |
| 225 * PP_ERROR_INPROGRESS will be returned if there is another operation pending. | |
| 226 */ | 210 */ |
| 227 int32_t Flush([in] PP_Resource file_io, | 211 int32_t Flush([in] PP_Resource file_io, |
| 228 [in] PP_CompletionCallback callback); | 212 [in] PP_CompletionCallback callback); |
| 229 | 213 |
| 230 /** | 214 /** |
| 231 * Close() cancels any IO that may be pending, and closes the FileIO object. | 215 * Close() cancels any IO that may be pending, and closes the FileIO object. |
| 232 * Any pending callbacks will still run, reporting | 216 * Any pending callbacks will still run, reporting |
| 233 * <code>PP_Error_Aborted</code> if pending IO was interrupted. It is not | 217 * <code>PP_Error_Aborted</code> if pending IO was interrupted. It is not |
| 234 * valid to call Open() again after a call to this method. | 218 * valid to call Open() again after a call to this method. |
| 235 * <strong>Note:</strong> If the FileIO object is destroyed, and it is still | 219 * <strong>Note:</strong> If the FileIO object is destroyed, and it is still |
| 236 * open, then it will be implicitly closed, so you are not required to call | 220 * open, then it will be implicitly closed, so you are not required to call |
| 237 * Close(). | 221 * Close(). |
| 238 * | 222 * |
| 239 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file | 223 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file |
| 240 * FileIO. | 224 * FileIO. |
| 241 */ | 225 */ |
| 242 void Close([in] PP_Resource file_io); | 226 void Close([in] PP_Resource file_io); |
| 243 }; | 227 }; |
| 244 | 228 |
| OLD | NEW |