1 /* 2 * Copyright (C) 2021 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 MYAPPLICATION_AUDIO_RESOURCEMANAGER_H 17 #define MYAPPLICATION_AUDIO_RESOURCEMANAGER_H 18 19 #include <string> 20 #include <vector> 21 #include <cstdlib> 22 #include "napi/native_api.h" 23 #include "rawfile/raw_file_manager.h" 24 #include "rawfile/raw_file.h" 25 #include "rawfile/raw_dir.h" 26 #include "hilog/log.h" 27 28 class FileRecourceManager { 29 public: 30 static const int globalResmgr = 0xFF00; 31 static const std::string resourceManagerTag; 32 static std::unique_ptr<uint8_t[]> data; 33 static std::unique_ptr<uint8_t[]> dataCopy; 34 static long len; 35 36 static constexpr size_t MAX_ALLOWED_SIZE = 1024; 37 38 public: 39 static napi_value CreateJsArrayValue(napi_env env, std::unique_ptr<uint8_t[]> &data, long length); 40 static napi_value GetRawFileContent(napi_env env, napi_callback_info info); 41 static napi_value GetFileList(napi_env env, napi_callback_info info); 42 }; 43 44 45 46 #endif //MYAPPLICATION_AUDIO_RESOURCEMANAGER_H