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