1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef PPAPI_C_PRIVATE_PPB_FLASH_FILE_H_ 6 #define PPAPI_C_PRIVATE_PPB_FLASH_FILE_H_ 7 8 #include "ppapi/c/pp_bool.h" 9 #include "ppapi/c/pp_instance.h" 10 #include "ppapi/c/pp_resource.h" 11 #include "ppapi/c/private/pp_file_handle.h" 12 13 struct PP_FileInfo; 14 15 struct PP_DirEntry_Dev { 16 const char* name; 17 PP_Bool is_dir; 18 }; 19 20 struct PP_DirContents_Dev { 21 int32_t count; 22 struct PP_DirEntry_Dev* entries; 23 }; 24 25 // PPB_Flash_File_ModuleLocal -------------------------------------------------- 26 #define PPB_FLASH_FILE_MODULELOCAL_INTERFACE_3_0 "PPB_Flash_File_ModuleLocal;3" 27 #define PPB_FLASH_FILE_MODULELOCAL_INTERFACE \ 28 PPB_FLASH_FILE_MODULELOCAL_INTERFACE_3_0 29 30 // This interface provides (for Flash) synchronous access to module-local files. 31 // Module-local file paths are '/'-separated UTF-8 strings, relative to a 32 // module-specific root. 33 struct PPB_Flash_File_ModuleLocal_3_0 { 34 // Deprecated. Returns true. 35 bool (*CreateThreadAdapterForInstance)(PP_Instance instance); 36 // Deprecated. Does nothing. 37 void (*ClearThreadAdapterForInstance)(PP_Instance instance); 38 39 // Opens a file, returning a file descriptor (posix) or a HANDLE (win32) into 40 // file. The return value is the ppapi error, PP_OK if success, one of the 41 // PP_ERROR_* in case of failure. 42 int32_t (*OpenFile)(PP_Instance instance, 43 const char* path, 44 int32_t mode, 45 PP_FileHandle* file); 46 47 // Renames a file. The return value is the ppapi error, PP_OK if success, one 48 // of the PP_ERROR_* in case of failure. 49 int32_t (*RenameFile)(PP_Instance instance, 50 const char* path_from, 51 const char* path_to); 52 53 // Deletes a file or directory. If recursive is set and the path points to a 54 // directory, deletes all the contents of the directory. The return value is 55 // the ppapi error, PP_OK if success, one of the PP_ERROR_* in case of 56 // failure. 57 int32_t (*DeleteFileOrDir)(PP_Instance instance, 58 const char* path, 59 PP_Bool recursive); 60 61 // Creates a directory. The return value is the ppapi error, PP_OK if success, 62 // one of the PP_ERROR_* in case of failure. 63 int32_t (*CreateDir)(PP_Instance instance, const char* path); 64 65 // Queries information about a file. The return value is the ppapi error, 66 // PP_OK if success, one of the PP_ERROR_* in case of failure. 67 int32_t (*QueryFile)(PP_Instance instance, 68 const char* path, 69 struct PP_FileInfo* info); 70 71 // Gets the list of files contained in a directory. The return value is the 72 // ppapi error, PP_OK if success, one of the PP_ERROR_* in case of failure. If 73 // non-NULL, the returned contents should be freed with FreeDirContents. 74 int32_t (*GetDirContents)(PP_Instance instance, 75 const char* path, 76 struct PP_DirContents_Dev** contents); 77 78 // Frees the data allocated by GetDirContents. 79 void (*FreeDirContents)(PP_Instance instance, 80 struct PP_DirContents_Dev* contents); 81 82 // Creates a temporary file. The file will be automatically deleted when all 83 // handles to it are closed. 84 // Returns PP_OK if successful, one of the PP_ERROR_* values in case of 85 // failure. 86 // 87 // If successful, |file| is set to a file descriptor (posix) or a HANDLE 88 // (win32) to the file. If failed, |file| is not touched. 89 int32_t (*CreateTemporaryFile)(PP_Instance instance, PP_FileHandle* file); 90 }; 91 92 typedef struct PPB_Flash_File_ModuleLocal_3_0 PPB_Flash_File_ModuleLocal; 93 94 // PPB_Flash_File_FileRef ------------------------------------------------------ 95 96 #define PPB_FLASH_FILE_FILEREF_INTERFACE "PPB_Flash_File_FileRef;2" 97 98 // This interface provides (for Flash) synchronous access to files whose paths 99 // are given by a Pepper FileRef. Such FileRefs are typically obtained via the 100 // Pepper file chooser. 101 struct PPB_Flash_File_FileRef { 102 // The functions below correspond exactly to their module-local counterparts 103 // (except in taking FileRefs instead of paths, of course). We omit the 104 // functionality which we do not provide for FileRefs. 105 int32_t (*OpenFile)(PP_Resource file_ref_id, 106 int32_t mode, 107 PP_FileHandle* file); 108 int32_t (*QueryFile)(PP_Resource file_ref_id, 109 struct PP_FileInfo* info); 110 }; 111 112 #endif // PPAPI_C_PRIVATE_PPB_FLASH_FILE_H_ 113