/* * Copyright (c) 2022 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_RESTOOL_FILE_ENTRY_H #define OHOS_RESTOOL_FILE_ENTRY_H #include #include #include namespace OHOS { namespace Global { namespace Restool { class FileEntry { public: class FilePath { public: FilePath(const std::string &path); virtual ~FilePath(); FilePath Append(const std::string &path); FilePath ReplaceExtension(const std::string &extension); FilePath GetParent(); const std::string &GetPath() const; const std::string &GetFilename() const; const std::string &GetExtension() const; const std::vector GetSegments() const; private: void Init(); void Format(); std::string filePath_; std::string filename_; std::string parent_; std::string extension_; }; FileEntry(const std::string &path); virtual ~FileEntry(); bool Init(); const std::vector> GetChilds() const; bool IsFile() const; const FilePath &GetFilePath() const; static bool Exist(const std::string &path); static bool RemoveAllDir(const std::string &path); static bool CreateDirs(const std::string &path); static bool CopyFile(const std::string &src, const std::string &dst); static bool IsDirectory(const std::string &path); private: bool IsIgnore(const std::string &filename) const; static bool RemoveAllDirInner(const FileEntry &entry); static bool CreateDirsInner(const std::string &path, std::string::size_type offset); FilePath filePath_; bool isFile_; static const std::string SEPARATE; }; } } } #endif