1 /* 2 * Copyright (C) 2025 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 #ifndef FS_FILE_FILTER_H 16 #define FS_FILE_FILTER_H 17 18 #include <optional> 19 #include <string> 20 #include <vector> 21 22 namespace OHOS { 23 namespace FileManagement { 24 namespace ModuleFileIO { 25 26 class FsFileFilter { 27 public: 28 FsFileFilter() = default; 29 ~FsFileFilter() = default; 30 31 FsFileFilter(const FsFileFilter &filter) = default; 32 FsFileFilter &operator=(const FsFileFilter &filter) = default; 33 SetSuffix(const std::optional<std::vector<std::string>> & suffix)34 void SetSuffix(const std::optional<std::vector<std::string>> &suffix) 35 { 36 suffix_ = std::move(suffix); 37 } 38 GetSuffix()39 const std::optional<std::vector<std::string>> &GetSuffix() const 40 { 41 return suffix_; 42 } 43 SetDisplayName(const std::optional<std::vector<std::string>> & displayName)44 void SetDisplayName(const std::optional<std::vector<std::string>> &displayName) 45 { 46 displayName_ = std::move(displayName); 47 } 48 GetDisplayName()49 const std::optional<std::vector<std::string>> &GetDisplayName() const 50 { 51 return displayName_; 52 } 53 SetMimeType(const std::optional<std::vector<std::string>> & mimeType)54 void SetMimeType(const std::optional<std::vector<std::string>> &mimeType) 55 { 56 mimeType_ = std::move(mimeType); 57 } 58 GetMimeType()59 const std::optional<std::vector<std::string>> &GetMimeType() const 60 { 61 return mimeType_; 62 } 63 SetFileSizeOver(const std::optional<int64_t> & fileSizeOver)64 void SetFileSizeOver(const std::optional<int64_t> &fileSizeOver) 65 { 66 fileSizeOver_ = std::move(fileSizeOver); 67 } 68 GetFileSizeOver()69 const std::optional<int64_t> &GetFileSizeOver() const 70 { 71 return fileSizeOver_; 72 } 73 SetLastModifiedAfter(const std::optional<int64_t> & lastModifiedAfter)74 void SetLastModifiedAfter(const std::optional<int64_t> &lastModifiedAfter) 75 { 76 lastModifiedAfter_ = std::move(lastModifiedAfter); 77 } 78 GetLastModifiedAfter()79 const std::optional<double> &GetLastModifiedAfter() const 80 { 81 return lastModifiedAfter_; 82 } 83 SetExcludeMedia(const bool & excludeMedia)84 void SetExcludeMedia(const bool &excludeMedia) 85 { 86 excludeMedia_ = excludeMedia; 87 } 88 GetExcludeMedia()89 bool GetExcludeMedia() const 90 { 91 return excludeMedia_; 92 } 93 SetHasFilter(const bool & hasFilter)94 void SetHasFilter(const bool &hasFilter) 95 { 96 hasFilter_ = hasFilter; 97 } 98 GetHasFilter()99 bool GetHasFilter() const 100 { 101 return hasFilter_; 102 } 103 104 private: 105 std::optional<std::vector<std::string>> suffix_ = std::nullopt; 106 std::optional<std::vector<std::string>> displayName_ = std::nullopt; 107 std::optional<std::vector<std::string>> mimeType_ = std::nullopt; 108 std::optional<int64_t> fileSizeOver_ = std::nullopt; 109 std::optional<double> lastModifiedAfter_ = std::nullopt; 110 bool excludeMedia_ = false; 111 bool hasFilter_ = false; 112 }; 113 114 } // namespace ModuleFileIO 115 } // namespace FileManagement 116 } // namespace OHOS 117 #endif // FS_FILE_FILTER_H