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