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_CPP_PRIVATE_FLASH_FILE_H_ 6 #define PPAPI_CPP_PRIVATE_FLASH_FILE_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "ppapi/c/private/ppb_flash_file.h" 12 13 namespace pp { 14 15 class FileRef; 16 class InstanceHandle; 17 18 namespace flash { 19 20 // FileModuleLocal ------------------------------------------------------------- 21 22 class FileModuleLocal { 23 public: 24 // Returns true if the required interface is available. 25 static bool IsAvailable(); 26 27 // Returns |PP_kInvalidFileHandle| on error. 28 static PP_FileHandle OpenFile(const InstanceHandle& instance, 29 const std::string& path, 30 int32_t mode); 31 static bool RenameFile(const InstanceHandle& instance, 32 const std::string& path_from, 33 const std::string& path_to); 34 static bool DeleteFileOrDir(const InstanceHandle& instance, 35 const std::string& path, 36 bool recursive); 37 static bool CreateDir(const InstanceHandle& instance, 38 const std::string& path); 39 static bool QueryFile(const InstanceHandle& instance, 40 const std::string& path, 41 PP_FileInfo* info); 42 // Note that, unlike the C interface, no |FreeDirContents()| is needed. 43 struct DirEntry { 44 std::string name; 45 bool is_dir; 46 }; 47 static bool GetDirContents(const InstanceHandle& instance, 48 const std::string& path, 49 std::vector<DirEntry>* dir_contents); 50 51 // Returns |PP_kInvalidFileHandle| on error. 52 static PP_FileHandle CreateTemporaryFile(const InstanceHandle& instance); 53 }; 54 55 // FileFileRef ----------------------------------------------------------------- 56 57 class FileFileRef { 58 public: 59 // Returns true if the required interface is available. 60 static bool IsAvailable(); 61 62 // Returns |PP_kInvalidFileHandle| on error. 63 static PP_FileHandle OpenFile(const pp::FileRef& resource, 64 int32_t mode); 65 static bool QueryFile(const pp::FileRef& resource, 66 PP_FileInfo* info); 67 }; 68 69 } // namespace flash 70 } // namespace pp 71 72 #endif // PPAPI_CPP_PRIVATE_FLASH_FILE_H_ 73