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