/* * Copyright (c) 2022-2023 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_FILEMGMT_BACKUP_B_DIR_H #define OHOS_FILEMGMT_BACKUP_B_DIR_H #include <linux/stat.h> #include <map> #include <string> #include <string_view> #include <sys/stat.h> #include <sys/types.h> #include <tuple> #include <unistd.h> #include <vector> #include "b_json/b_report_entity.h" #include "errors.h" namespace OHOS::FileManagement::Backup { class BDir { public: /** * @brief è¯»å–æŒ‡å®šç›®å½•下所有文件(éžé€’å½’) * * @param 目录 * @return 错误ç ã€æ–‡ä»¶å数组 */ static std::tuple<ErrCode, std::vector<std::string>> GetDirFiles(const std::string &path); /** * @brief 从给定的includeså’Œexcludesç›®å½•åŠæ–‡ä»¶ä¸èŽ·å–æ‰€æœ‰æœ‰ç”¨å¤§æ–‡ä»¶å’Œå…¶é“¾æŽ¥æ–‡ä»¶çš„é›†åˆ * * @param includes 需è¦åŒ…å«çš„æ–‡ä»¶åŠç›®å½•é›†åˆ * @param excludes éœ€è¦æŽ’é™¤çš„æ–‡ä»¶åŠç›®å½•é›†åˆ * @return 错误ç ã€å¤§æ–‡ä»¶åé›†åˆ */ static std::tuple<ErrCode, std::map<std::string, struct stat>, std::map<std::string, size_t>> GetBigFiles( const std::vector<std::string> &includes, const std::vector<std::string> &excludes); /** * @brief Get the Dirs object * * @param paths 目录集åˆå¯å¸¦æœ‰é€šé…符路径 * @return std::vector<std::string> ç›®å½•é›†åˆ */ static std::vector<std::string> GetDirs(const std::vector<std::string_view> &paths); /** * @brief 从给定的includeså’Œexcludes目录ä¸èŽ·å–æ‰€æœ‰çš„å¤§æ–‡ä»¶å’Œå°æ–‡ä»¶ * * @param includes 需è¦åŒ…å«çš„æ–‡ä»¶åŠç›®å½•é›†åˆ * @param excludes éœ€è¦æŽ’é™¤çš„æ–‡ä»¶åŠç›®å½•é›†åˆ * @return å¤§æ–‡ä»¶å’Œå°æ–‡ä»¶çš„é›†åˆ */ static std::tuple<std::vector<std::string>, std::vector<std::string>> GetBackupList( const std::vector<std::string> &includes, const std::vector<std::string> &excludes); /** * @brief 获å–bigfileå’Œsmaillfile的文件信æ¯å¹¶ç”Ÿæˆæ¸…å• * * @param bigFile 需è¦åŒ…å«çš„æ–‡ä»¶åŠç›®å½•é›†åˆ * @param smallFile éœ€è¦æŽ’é™¤çš„æ–‡ä»¶åŠç›®å½•é›†åˆ * @param allFiles 生æˆçš„æ‰€æœ‰æ–‡ä»¶ä¿¡æ¯æ¸…å• * @param smallFiles 生æˆçš„å°æ–‡ä»¶ä¿¡æ¯æ¸…å• * @param bigFiles 生æˆçš„å¤§æ–‡ä»¶ä¿¡æ¯æ¸…å• * @return */ static void GetUser0FileStat(std::vector<std::string> bigFile, std::vector<std::string> smallFile, std::vector<struct ReportFileInfo> &allFiles, std::vector<struct ReportFileInfo> &smallFiles, std::vector<struct ReportFileInfo> &bigFiles); /** * @brief æ ¸å®žæ–‡ä»¶æ˜¯å¦ä¸ºå¼‚å¸¸æ— æ•ˆè·¯å¾„ * * @param filePath å¾…æ ¸å®žçš„è·¯å¾„ * @return æ˜¯å¦æ˜¯å¼‚å¸¸æ— æ•ˆè·¯å¾„ */ static bool CheckFilePathInvalid(const std::string &filePath); }; } // namespace OHOS::FileManagement::Backup #endif // OHOS_FILEMGMT_BACKUP_B_DIR_H