• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MOVEDIR_CORE_H
17 #define INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_MOVEDIR_CORE_H
18 
19 #include <deque>
20 #include <string>
21 
22 #include "filemgmt_libfs.h"
23 #include "fs_utils.h"
24 
25 namespace OHOS {
26 namespace FileManagement {
27 namespace ModuleFileIO {
28 
29 constexpr int DIRMODE_MIN = 0;
30 constexpr int DIRMODE_MAX = 3;
31 
32 constexpr int FILE_DISMATCH = 0;
33 constexpr int FILE_MATCH = 1;
34 constexpr int MOVEDIR_DEFAULT_PERM = 0770;
35 
36 enum ModeOfMoveDir {
37     DIRMODE_DIRECTORY_THROW_ERR = 0,
38     DIRMODE_FILE_THROW_ERR,
39     DIRMODE_FILE_REPLACE,
40     DIRMODE_DIRECTORY_REPLACE
41 };
42 
43 struct ErrFiles {
44     std::string srcFiles;
45     std::string destFiles;
ErrFilesErrFiles46     ErrFiles(const std::string& src, const std::string& dest) : srcFiles(src), destFiles(dest) {}
47     ~ErrFiles() = default;
48 };
49 
50 struct MoveDirResult {
51     FsResult<void> fsResult;
52     optional<deque<struct ErrFiles>> errFiles;
53 };
54 
55 class MoveDirCore final {
56 public:
57     static MoveDirResult DoMoveDir(
58         const std::string &src, const std::string &dest, std::optional<int32_t> mode = std::nullopt);
59 };
60 
61 } // namespace ModuleFileIO
62 } // namespace FileManagement
63 } // namespace OHOS
64 #endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_MOVEDIR_CORE_H