1 /* 2 * Copyright (c) 2022 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 OHOS_RESOURCE_ADAPTER_H 17 #define OHOS_RESOURCE_ADAPTER_H 18 19 #include <string> 20 #include <sys/types.h> 21 22 namespace OHOS::NWeb { 23 24 class OhosFileMapper { 25 public: 26 OhosFileMapper() = default; 27 virtual ~OhosFileMapper() = default; 28 29 virtual int32_t GetFd() = 0; 30 31 virtual int32_t GetOffset() = 0; 32 33 virtual std::string GetFileName() = 0; 34 35 virtual bool IsCompressed() = 0; 36 37 virtual void* GetDataPtr() = 0; 38 39 virtual size_t GetDataLen() = 0; 40 41 virtual bool UnzipData(uint8_t** dest, size_t& len) = 0; 42 }; 43 44 class OhosResourceAdapter { 45 public: 46 OhosResourceAdapter() = default; 47 virtual ~OhosResourceAdapter() = default; 48 49 virtual bool GetRawFileData(const std::string& rawFile, size_t& len, uint8_t** dest, bool isSys = false) = 0; 50 51 virtual std::shared_ptr<OhosFileMapper> GetRawFileMapper(const std::string& rawFile, bool isSys = false) = 0; 52 53 virtual bool IsRawFileExist(const std::string& rawFile, bool isSys = false) = 0; 54 55 virtual bool GetRawFileLastModTime( 56 const std::string& rawFile, uint16_t& date, uint16_t& time, bool isSys = false) = 0; 57 58 virtual bool GetRawFileLastModTime(const std::string& rawFile, time_t& time, bool isSys = false) = 0; 59 60 virtual std::string GetSystemLanguage() = 0; 61 }; 62 63 } // namespace OHOS::NWeb 64 65 #endif // OHOS_RESOURCE_ADAPTER_H 66