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 MOCK_NATIVE_INCLUDE_DIRECTORY_EX_H 17 #define MOCK_NATIVE_INCLUDE_DIRECTORY_EX_H 18 19 #include <string> 20 #include <vector> 21 #include <sys/stat.h> 22 23 namespace OHOS { 24 /** 25 * The GetCurrentProcFullFileName function get the current process exe name. 26 */ 27 std::string GetCurrentProcFullFileName(); 28 29 /** 30 * The GetCurrentProcPath function get the current process exe path. 31 */ 32 std::string GetCurrentProcPath(); 33 34 /** 35 * The ExtractFilePath function extract the input file path. 36 */ 37 std::string ExtractFilePath(const std::string& fileFullName); 38 39 /** 40 * The ExtractFilePath function extract the input file name. 41 */ 42 std::string ExtractFileName(const std::string& fileFullName); 43 44 /** 45 * The ExtractFileExt function extract the input file name type. 46 */ 47 std::string ExtractFileExt(const std::string& fileName); 48 49 /** 50 * The TransformFileName function transform the input file name for windows or mac. 51 */ 52 std::string TransformFileName(const std::string& fileName); 53 54 /** 55 * The ExcludeTrailingPathDelimiter function exclude the end '/' from the strPath, 56 * return the path without the end '/'. 57 */ 58 std::string ExcludeTrailingPathDelimiter(const std::string& path); 59 60 /** 61 * The IncludeTrailingPathDelimiter function include the end '/' from the strPath, 62 * return the path with the end '/'. 63 */ 64 std::string IncludeTrailingPathDelimiter(const std::string& path); 65 66 /** 67 * The GetDirFiles function get all files in the path. 68 */ 69 void GetDirFiles(const std::string& path, std::vector<std::string>& files); 70 71 /** 72 * The IsEmptyFolder function judge the path is empty, 73 * return true if is empty, else false. 74 */ 75 bool IsEmptyFolder(const std::string& path); 76 77 /** 78 * The ForceCreateDirectory function is force create the dir with subdir, 79 * return true if create succ, else false. 80 */ 81 bool ForceCreateDirectory(const std::string& path); 82 83 /** 84 * The ForceRemoveDirectory function is force delete the dir with subdir and files, 85 * return true if remove succ, else false. 86 */ 87 bool ForceRemoveDirectory(const std::string& path); 88 89 /** 90 * The RemoveFile function is remove the input strFileName, 91 * return true if remove succ, else false. 92 */ 93 bool RemoveFile(const std::string& fileName); 94 95 /** 96 * The GetFolderSize function is get the folder size(bytes). 97 */ 98 uint64_t GetFolderSize(const std::string& path); 99 100 /** 101 * The ChangeModeFile function is change the input file authority, 102 * return true if change succ, else false. 103 */ 104 bool ChangeModeFile(const std::string& fileName, const mode_t& mode); 105 106 /** 107 * The ChangeModeDirectory function is change the input Directory authority, include subdir, 108 * return true if change succ, else false. 109 */ 110 bool ChangeModeDirectory(const std::string& path, const mode_t& mode); 111 112 /** 113 * The PathToRealPath function is get real path from relative path, 114 * return true if change succ, else false. 115 */ 116 bool PathToRealPath(const std::string& path, std::string& realPath); 117 } // namespace OHOS 118 119 #endif // MOCK_NATIVE_INCLUDE_DIRECTORY_EX_H 120