OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ | 5 #ifndef PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ |
6 #define PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ | 6 #define PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ |
7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" |
8 #include "ppapi/c/pp_module.h" | 9 #include "ppapi/c/pp_module.h" |
9 #include "ppapi/c/pp_resource.h" | 10 #include "ppapi/c/pp_resource.h" |
10 #include "ppapi/c/pp_stdint.h" | 11 #include "ppapi/c/pp_stdint.h" |
11 #include "ppapi/c/pp_time.h" | 12 #include "ppapi/c/pp_time.h" |
12 | 13 |
13 struct PP_CompletionCallback; | 14 struct PP_CompletionCallback; |
14 struct PP_FileInfo_Dev; | 15 struct PP_FileInfo_Dev; |
15 | 16 |
16 typedef enum { | 17 typedef enum { |
17 // Requests read access to a file. | 18 // Requests read access to a file. |
(...skipping 11 matching lines...) Expand all Loading... |
29 // Requests that the file be truncated to length 0 if it exists and is a | 30 // Requests that the file be truncated to length 0 if it exists and is a |
30 // regular file. PP_FILEOPENFLAG_WRITE must also be specified. | 31 // regular file. PP_FILEOPENFLAG_WRITE must also be specified. |
31 PP_FILEOPENFLAG_TRUNCATE = 1 << 3, | 32 PP_FILEOPENFLAG_TRUNCATE = 1 << 3, |
32 | 33 |
33 // Requests that the file is created when this flag is combined with | 34 // Requests that the file is created when this flag is combined with |
34 // PP_FILEOPENFLAG_CREATE. If this flag is specified, and the file already | 35 // PP_FILEOPENFLAG_CREATE. If this flag is specified, and the file already |
35 // exists, then the FileIO::Open call will fail. | 36 // exists, then the FileIO::Open call will fail. |
36 PP_FILEOPENFLAG_EXCLUSIVE = 1 << 4 | 37 PP_FILEOPENFLAG_EXCLUSIVE = 1 << 4 |
37 } PP_FileOpenFlags_Dev; | 38 } PP_FileOpenFlags_Dev; |
38 | 39 |
39 #define PPB_FILEIO_DEV_INTERFACE "PPB_FileIO(Dev);0.1" | 40 #define PPB_FILEIO_DEV_INTERFACE "PPB_FileIO(Dev);0.2" |
40 | 41 |
41 // Use this interface to operate on a regular file (PP_FileType_Regular). | 42 // Use this interface to operate on a regular file (PP_FileType_Regular). |
42 struct PPB_FileIO_Dev { | 43 struct PPB_FileIO_Dev { |
43 // Creates a new FileIO object. Returns 0 if the module is invalid. | 44 // Creates a new FileIO object. Returns 0 if the module is invalid. |
44 PP_Resource (*Create)(PP_Module module); | 45 PP_Resource (*Create)(PP_Module module); |
45 | 46 |
46 // Returns true if the given resource is a FileIO. Returns false if the | 47 // Returns PP_TRUE if the given resource is a FileIO. Returns PP_FALSE if the |
47 // resource is invalid or some type other than a FileIO. | 48 // resource is invalid or some type other than a FileIO. |
48 bool (*IsFileIO)(PP_Resource resource); | 49 PP_Bool (*IsFileIO)(PP_Resource resource); |
49 | 50 |
50 // Open the specified regular file for I/O according to the given open flags, | 51 // Open the specified regular file for I/O according to the given open flags, |
51 // which is a bit-mask of the PP_FileOpenFlags values. Upon success, the | 52 // which is a bit-mask of the PP_FileOpenFlags values. Upon success, the |
52 // corresponding file is classified as "in use" by this FileIO object until | 53 // corresponding file is classified as "in use" by this FileIO object until |
53 // such time as the FileIO object is closed or destroyed. | 54 // such time as the FileIO object is closed or destroyed. |
54 int32_t (*Open)(PP_Resource file_io, | 55 int32_t (*Open)(PP_Resource file_io, |
55 PP_Resource file_ref, | 56 PP_Resource file_ref, |
56 int32_t open_flags, | 57 int32_t open_flags, |
57 struct PP_CompletionCallback callback); | 58 struct PP_CompletionCallback callback); |
58 | 59 |
59 // Queries info about the file opened by this FileIO object. Fails if the | 60 // Queries info about the file opened by this FileIO object. Fails if the |
60 // FileIO object has not been opened. | 61 // FileIO object has not been opened. |
61 int32_t (*Query)(PP_Resource file_io, | 62 int32_t (*Query)(PP_Resource file_io, |
62 PP_FileInfo_Dev* info, | 63 struct PP_FileInfo_Dev* info, |
63 struct PP_CompletionCallback callback); | 64 struct PP_CompletionCallback callback); |
64 | 65 |
65 // Updates timestamps for the file opened by this FileIO object. Fails if | 66 // Updates timestamps for the file opened by this FileIO object. Fails if |
66 // the FileIO object has not been opened. | 67 // the FileIO object has not been opened. |
67 int32_t (*Touch)(PP_Resource file_io, | 68 int32_t (*Touch)(PP_Resource file_io, |
68 PP_Time last_access_time, | 69 PP_Time last_access_time, |
69 PP_Time last_modified_time, | 70 PP_Time last_modified_time, |
70 struct PP_CompletionCallback callback); | 71 struct PP_CompletionCallback callback); |
71 | 72 |
72 // Read from an offset in the file. The size of the buffer must be large | 73 // Read from an offset in the file. The size of the buffer must be large |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Cancels any IO that may be pending, and closes the FileIO object. Any | 107 // Cancels any IO that may be pending, and closes the FileIO object. Any |
107 // pending callbacks will still run, reporting PP_Error_Aborted if pending IO | 108 // pending callbacks will still run, reporting PP_Error_Aborted if pending IO |
108 // was interrupted. It is NOT valid to call Open again after a call to this | 109 // was interrupted. It is NOT valid to call Open again after a call to this |
109 // method. Note: If the FileIO object is destroyed, and it is still open, | 110 // method. Note: If the FileIO object is destroyed, and it is still open, |
110 // then it will be implicitly closed, so you are not required to call the | 111 // then it will be implicitly closed, so you are not required to call the |
111 // Close method. | 112 // Close method. |
112 void (*Close)(PP_Resource file_io); | 113 void (*Close)(PP_Resource file_io); |
113 }; | 114 }; |
114 | 115 |
115 #endif // PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ | 116 #endif // PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ |
OLD | NEW |