/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_FILE_FS_LIST_FILE_H #define OHOS_FILE_FS_LIST_FILE_H #include #include "cj_common_ffi.h" #include "file_filter.h" namespace OHOS { namespace CJSystemapi { struct RetDataCArrStringN { int code; CArrString data; }; struct CFilter { CArrString suffix; CArrString displayName; CArrString mimeType; int64_t fileSizeOver; double lastModifiedAfter; bool excludeMedia; }; struct CListFileOptions { bool recursion; int listNum; CFilter filter; }; struct NameListArg { struct dirent** namelist = { nullptr }; int direntNum = 0; }; constexpr int DEFAULT_SIZE = -1; constexpr int DEFAULT_MODIFY_AFTER = -1; constexpr int FILTER_MATCH = 1; constexpr int FILTER_DISMATCH = 0; const int32_t MAX_SUFFIX_LENGTH = 256; struct OptionArgs { OHOS::FileManagement::ModuleFileIO::FileFilter filter = OHOS::FileManagement::ModuleFileIO::FileFilterBuilder() .SetFileSizeOver(DEFAULT_SIZE) .SetLastModifiedAfter(DEFAULT_MODIFY_AFTER) .Build(); int listNum = 0; int countNum = 0; bool recursion = false; std::string path = ""; void Clear() { filter.FilterClear(); filter.SetFileSizeOver(DEFAULT_SIZE); filter.SetLastModifiedAfter(DEFAULT_MODIFY_AFTER); listNum = 0; countNum = 0; recursion = false; path = ""; } }; class ListFileImpl { public: static RetDataCArrStringN ListFile(const std::string &path, CListFileOptions options); }; } } #endif // OHOS_FILE_FS_LIST_FILE_H