• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 UTILS_DIRECTORY_H
17 #define UTILS_DIRECTORY_H
18 
19 #include <string>
20 #include <sys/types.h>
21 #include <vector>
22 
23 #include <cstring>
24 #include <unistd.h>
25 
26 #include <dirent.h>
27 #include <iostream>
28 
29 namespace OHOS {
30 namespace Storage {
31 namespace DistributedFile {
32 namespace Utils {
33 enum Uid {
34     UID_ROOT = 0,
35     UID_SYSTEM = 1000,
36     UID_MEDIA_RW = 1023,
37 };
38 
39 void ForceCreateDirectory(const std::string &path);
40 void ForceCreateDirectory(const std::string &path, mode_t mode);
41 void ForceCreateDirectory(const std::string &path, mode_t mode, uid_t uid, gid_t gid);
42 
43 void ForceRemoveDirectory(const std::string &path);
44 bool IsFolder(const std::string &name);
45 std::vector<std::string> GetFilePath(const std::string &name);
46 int32_t ChangeOwnerRecursive(const std::string &path, uid_t uid, gid_t gid);
47 } // namespace Utils
48 } // namespace DistributedFile
49 } // namespace Storage
50 } // namespace OHOS
51 #endif // UTILS_DIRECTORY_H