1 /* 2 * Copyright (c) 2020 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_BUNDLE_FILE_UTILS_H 17 #define OHOS_BUNDLE_FILE_UTILS_H 18 19 #include <cstdint> 20 #include <string> 21 22 #include "nocopyable.h" 23 #include "utils_list.h" 24 25 namespace OHOS { 26 namespace { 27 const char PATH_SEPARATOR = '/'; 28 } 29 class BundleFileUtils : public NoCopyable { 30 public: 31 static bool MkRecursiveDir(const char *dir, bool isReadOthers); 32 static bool MkOwnerDir(const char *dir); 33 static bool IsExistDir(const char *path); 34 static bool IsExistFile(const char *file); 35 static bool RemoveFile(const char *path); 36 static bool RenameFile(const char *oldDir, const char *newDir); 37 static bool ChownFile(const char *file, int32_t uid, int32_t gid); 38 static bool WriteFile(const char *file, const void *buffer, uint32_t size); 39 static bool IsValidPath(const std::string &rootDir, const std::string &path); 40 static std::string GetPathDir(const std::string &path); 41 }; 42 } // OHOS 43 #endif // OHOS_BUNDLE_FILE_UTILS_H 44