• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "image_source.h"
28 #include "uri.h"
29 
30 namespace OHOS {
31 namespace FileAccessFwk {
32 using namespace Media;
33 
34 class IFileAccessExtBase : public IRemoteBroker {
35 public:
36     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.FileAccessFwk.IFileAccessExtBase");
37 
38     enum {
39         CMD_OPEN_FILE = 1,
40         CMD_CREATE_FILE,
41         CMD_MKDIR,
42         CMD_DELETE,
43         CMD_MOVE,
44         CMD_COPY,
45         CMD_RENAME,
46         CMD_LIST_FILE,
47         CMD_SCAN_FILE,
48         CMD_START_WATCHER,
49         CMD_STOP_WATCHER,
50         CMD_QUERY,
51         CMD_GET_ROOTS,
52         CMD_ACCESS,
53         CMD_GET_THUMBNAIL,
54         CMD_GET_FILEINFO_FROM_URI,
55         CMD_GET_FILEINFO_FROM_RELATIVE_PATH
56     };
57 
58     virtual int OpenFile(const Uri &uri, const int flags, int &fd) = 0;
59     virtual int CreateFile(const Uri &parent, const std::string &displayName, Uri &newFile) = 0;
60     virtual int Mkdir(const Uri &parent, const std::string &displayName, Uri &newFile) = 0;
61     virtual int Delete(const Uri &sourceFile) = 0;
62     virtual int Move(const Uri &sourceFile, const Uri &targetParent, Uri &newFile) = 0;
63     virtual int Copy(const Uri &sourceUri, const Uri &destUri, std::vector<CopyResult> &copyResult,
64         bool force = false) = 0;
65     virtual int Rename(const Uri &sourceFile, const std::string &displayName, Uri &newFile) = 0;
66     virtual int ListFile(const FileInfo &fileInfo, const int64_t offset, const int64_t maxCount,
67         const FileFilter &filter, std::vector<FileInfo> &fileInfoVec) = 0;
68     virtual int ScanFile(const FileInfo &fileInfo, const int64_t offset, const int64_t maxCount,
69         const FileFilter &filter, std::vector<FileInfo> &fileInfoVec) = 0;
70     virtual int GetThumbnail(const Uri &uri, const ThumbnailSize &thumbnailSize,
71         std::shared_ptr<PixelMap> &pixelMap) = 0;
72     virtual int Query(const Uri &uri, std::vector<std::string> &columns, std::vector<std::string> &results) = 0;
73     virtual int GetFileInfoFromUri(const Uri &selectFile, FileInfo &fileInfo) = 0;
74     virtual int GetFileInfoFromRelativePath(const std::string &selectFile, FileInfo &fileInfo) = 0;
75     virtual int GetRoots(std::vector<RootInfo> &rootInfoVec) = 0;
76     virtual int Access(const Uri &uri, bool &isExist) = 0;
77     virtual int StartWatcher(const Uri &uri) = 0;
78     virtual int StopWatcher(const Uri &uri, bool isUnregisterAll) = 0;
79 };
80 } // namespace FileAccessFwk
81 } // namespace OHOS
82 #endif // I_FILE_ACCESS_EXT_BASE_H
83