• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 OHOS_FILEMGMT_BACKUP_B_DIR_H
17 #define OHOS_FILEMGMT_BACKUP_B_DIR_H
18 
19 #include <linux/stat.h>
20 #include <map>
21 #include <string>
22 #include <string_view>
23 #include <sys/stat.h>
24 #include <sys/types.h>
25 #include <tuple>
26 #include <unistd.h>
27 #include <vector>
28 
29 #include "errors.h"
30 
31 namespace OHOS::FileManagement::Backup {
32 class BDir {
33 public:
34     /**
35      * @brief 读取指定目录下所有文件(非递归)
36      *
37      * @param 目录
38      * @return 错误码、文件名数组
39      */
40     static std::tuple<ErrCode, std::vector<std::string>> GetDirFiles(const std::string &path);
41 
42     /**
43      * @brief 从给定的includes和excludes目录及文件中获取所有有用大文件和其链接文件的集合
44      *
45      * @param includes 需要包含的文件及目录集合
46      * @param excludes 需要排除的文件及目录集合
47      * @return 错误码、大文件名集合
48      */
49     static std::pair<ErrCode, std::map<std::string, struct stat>> GetBigFiles(const std::vector<std::string> &includes,
50                                                                               const std::vector<std::string> &excludes);
51 
52     /**
53      * @brief Get the Dirs object
54      *
55      * @param paths 目录集合可带有通配符路径
56      * @return std::vector<std::string> 目录集合
57      */
58     static std::vector<std::string> GetDirs(const std::vector<std::string_view> &paths);
59 };
60 } // namespace OHOS::FileManagement::Backup
61 
62 #endif // OHOS_FILEMGMT_BACKUP_B_DIR_H