1 /* 2 * Copyright (c) 2023 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_NATIVE_SRC_TRASH_FILE_TRASH_N_EXPORTER_H 17 #define INTERFACES_KITS_NATIVE_SRC_TRASH_FILE_TRASH_N_EXPORTER_H 18 19 #include "uv.h" 20 21 #include "filemgmt_libn.h" 22 #include "napi/native_api.h" 23 #include "napi/native_node_api.h" 24 25 namespace OHOS { 26 namespace Trash { 27 using namespace FileManagement::LibN; 28 using namespace std; 29 30 const std::string TRASH_SUB_DIR = "oh_trash_content"; 31 const int PARAM_CONST_VALUE_LEN_MAX = 10; 32 const int SLICE_LENGTH = 10; 33 /** 34 * Indicates the supported capabilities of the file or directory. 35 */ 36 const size_t REPRESENTS_FILE = 1; 37 const size_t REPRESENTS_DIR = 1 << 1; 38 const size_t SUPPORTS_READ = 1 << 2; 39 const size_t SUPPORTS_WRITE = 1 << 3; 40 41 class FileTrashNExporter final : public NExporter { 42 public: 43 inline static const std::string className_ = "trash"; 44 inline static std::string trashPath_ {}; 45 // 初始化回收站路径 46 static void InitTrashPath(); 47 48 static napi_value ListFile(napi_env env, napi_callback_info info); 49 static napi_value Recover(napi_env env, napi_callback_info info); 50 static napi_value CompletelyDelete(napi_env env, napi_callback_info info); 51 52 bool Export() override; 53 std::string GetClassName() override; 54 FileTrashNExporter(napi_env env, napi_value exports); 55 ~FileTrashNExporter() override; 56 }; 57 58 } // namespace Trash 59 } // namespace OHOS 60 #endif // INTERFACES_KITS_NATIVE_SRC_TRASH_FILE_TRASH_N_EXPORTER_H