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 I_FILE_ACCESS_EXT_BASE_H 17 #define I_FILE_ACCESS_EXT_BASE_H 18 19 #include <bitset> 20 #include <cstdint> 21 #include <string_ex.h> 22 #include <iremote_broker.h> 23 24 #include "file_access_extension_info.h" 25 #include "file_access_framework_errno.h" 26 #include "file_filter.h" 27 #include "file_info_shared_memory.h" 28 #include "uri.h" 29 30 namespace OHOS { 31 namespace FileAccessFwk { 32 33 class IFileAccessExtBase : public IRemoteBroker { 34 public: 35 DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.FileAccessFwk.IFileAccessExtBase"); 36 37 enum { 38 CMD_OPEN_FILE = 1, 39 CMD_CREATE_FILE, 40 CMD_MKDIR, 41 CMD_DELETE, 42 CMD_MOVE, 43 CMD_COPY, 44 CMD_RENAME, 45 CMD_LIST_FILE, 46 CMD_SCAN_FILE, 47 CMD_START_WATCHER, 48 CMD_STOP_WATCHER, 49 CMD_QUERY, 50 CMD_GET_ROOTS, 51 CMD_ACCESS, 52 CMD_GET_FILEINFO_FROM_URI, 53 CMD_GET_FILEINFO_FROM_RELATIVE_PATH, 54 CMD_COPY_FILE, 55 CMD_MOVE_ITEM, 56 CMD_MOVE_FILE 57 }; 58 59 virtual int OpenFile(const Uri &uri, const int flags, int &fd) = 0; 60 virtual int CreateFile(const Uri &parent, const std::string &displayName, Uri &newFile) = 0; 61 virtual int Mkdir(const Uri &parent, const std::string &displayName, Uri &newFile) = 0; 62 virtual int Delete(const Uri &sourceFile) = 0; 63 virtual int Move(const Uri &sourceFile, const Uri &targetParent, Uri &newFile) = 0; 64 virtual int Copy(const Uri &sourceUri, const Uri &destUri, std::vector<Result> ©Result, 65 bool force = false) = 0; 66 virtual int CopyFile(const Uri &sourceUri, const Uri &destUri, const std::string &fileName, 67 Uri &newFileUri) = 0; 68 virtual int Rename(const Uri &sourceFile, const std::string &displayName, Uri &newFile) = 0; 69 virtual int ListFile(const FileInfo &fileInfo, const int64_t offset, 70 const FileFilter &filter, SharedMemoryInfo &memInfo) = 0; 71 virtual int ScanFile(const FileInfo &fileInfo, const int64_t offset, const int64_t maxCount, 72 const FileFilter &filter, std::vector<FileInfo> &fileInfoVec) = 0; 73 virtual int Query(const Uri &uri, std::vector<std::string> &columns, std::vector<std::string> &results) = 0; 74 virtual int GetFileInfoFromUri(const Uri &selectFile, FileInfo &fileInfo) = 0; 75 virtual int GetFileInfoFromRelativePath(const std::string &selectFile, FileInfo &fileInfo) = 0; 76 virtual int GetRoots(std::vector<RootInfo> &rootInfoVec) = 0; 77 virtual int Access(const Uri &uri, bool &isExist) = 0; 78 virtual int StartWatcher(const Uri &uri) = 0; 79 virtual int StopWatcher(const Uri &uri) = 0; 80 virtual int MoveItem(const Uri &sourceFile, const Uri &targetParent, std::vector<Result> &moveResult, 81 bool force = false) = 0; 82 virtual int MoveFile(const Uri &sourceFile, const Uri &targetParent, std::string &fileName, Uri &newFile) = 0; 83 }; 84 } // namespace FileAccessFwk 85 } // namespace OHOS 86 #endif // I_FILE_ACCESS_EXT_BASE_H