1 /* 2 * Copyright (c) 2025 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 INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_COPY_DIR_CORE_H 17 #define INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_COPY_DIR_CORE_H 18 19 #include <optional> 20 #include <string> 21 22 #include "filemgmt_libfs.h" 23 24 namespace OHOS { 25 namespace FileManagement { 26 namespace ModuleFileIO { 27 using namespace std; 28 29 constexpr int COPYMODE_MIN = 0; 30 constexpr int COPYMODE_MAX = 1; 31 constexpr int COPYDIR_DEFAULT_PERM = 0770; 32 33 constexpr int DISMATCH = 0; 34 constexpr int MATCH = 1; 35 36 enum ModeOfCopyDir { DIRMODE_FILE_COPY_THROW_ERR = 0, DIRMODE_FILE_COPY_REPLACE }; 37 38 struct CopyDirResult { 39 FsResult<void> fsResult; 40 optional<vector<struct ConflictFiles>> errFiles; 41 }; 42 43 class CopyDirCore final { 44 public: 45 static struct CopyDirResult DoCopyDir( 46 const string &src, const string &dest, const optional<int32_t> &mode = nullopt); 47 }; 48 49 struct ConflictFiles { 50 string srcFiles; 51 string destFiles; ConflictFilesConflictFiles52 ConflictFiles(const string &src, const string &dest) : srcFiles(src), destFiles(dest) {} 53 ~ConflictFiles() = default; 54 }; 55 56 } // namespace ModuleFileIO 57 } // namespace FileManagement 58 } // namespace OHOS 59 #endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_COPY_DIR_CORE_H