1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FILE_ACCESS_EXT_STUB_IMPL_H 17 #define FILE_ACCESS_EXT_STUB_IMPL_H 18 19 #include <memory> 20 #include <vector> 21 22 #include "file_access_ext_ability.h" 23 #include "file_access_ext_stub.h" 24 #include "file_access_extension_info.h" 25 #include "image_source.h" 26 #include "js_native_api_types.h" 27 #include "uri.h" 28 29 namespace OHOS { 30 namespace FileAccessFwk { 31 using namespace Media; 32 class FileAccessExtStubImpl : public FileAccessExtStub { 33 public: FileAccessExtStubImpl(const std::shared_ptr<FileAccessExtAbility> & extension,napi_env env)34 explicit FileAccessExtStubImpl(const std::shared_ptr<FileAccessExtAbility>& extension, napi_env env) 35 : extension_(extension) {} 36 ~FileAccessExtStubImpl()37 virtual ~FileAccessExtStubImpl() {} 38 39 int OpenFile(const Uri &uri, const int flags, int &fd) override; 40 int CreateFile(const Uri &parent, const std::string &displayName, Uri &newFile) override; 41 int Mkdir(const Uri &parent, const std::string &displayName, Uri &newFile) override; 42 int Delete(const Uri &sourceFile) override; 43 int Move(const Uri &sourceFile, const Uri &targetParent, Uri &newFile) override; 44 int Copy(const Uri &sourceUri, const Uri &destUri, std::vector<CopyResult> ©Result, 45 bool force = false) override; 46 int Rename(const Uri &sourceFile, const std::string &displayName, Uri &newFile) override; 47 int ListFile(const FileInfo &fileInfo, const int64_t offset, const int64_t maxCount, 48 const FileFilter &filter, std::vector<FileInfo> &fileInfoVec) override; 49 int ScanFile(const FileInfo &fileInfo, const int64_t offset, const int64_t maxCount, 50 const FileFilter &filter, std::vector<FileInfo> &fileInfoVec) override; 51 int GetThumbnail(const Uri &uri, const ThumbnailSize &thumbnailSize, std::shared_ptr<PixelMap> &pixelMap) override; 52 int Query(const Uri &uri, std::vector<std::string> &columns, std::vector<std::string> &results) override; 53 int GetFileInfoFromUri(const Uri &selectFile, FileInfo &fileInfo) override; 54 int GetFileInfoFromRelativePath(const std::string &selectFile, FileInfo &fileInfo) override; 55 int GetRoots(std::vector<RootInfo> &rootInfoVec) override; 56 int Access(const Uri &uri, bool &isExist) override; 57 int StartWatcher(const Uri &uri) override; 58 int StopWatcher(const Uri &uri, bool isUnregisterAll) override; 59 60 private: 61 std::shared_ptr<FileAccessExtAbility> GetOwner(); 62 std::shared_ptr<FileAccessExtAbility> extension_; 63 }; 64 } // namespace FileAccessFwk 65 } // namespace OHOS 66 #endif // FILE_ACCESS_EXT_STUB_IMPL_H 67