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#ifndef UPDATER_STORE_H
16#define UPDATER_STORE_H
17
18#include <string>
19#include <unordered_map>
20#include <openssl/sha.h>
21#include "applypatch/block_set.h"
22#include "applypatch/command.h"
23
24namespace Updater {
25class Store {
26public:
27    // Create new store space
28    static int32_t CreateNewSpace(const std::string &path, bool needClear);
29    static void DoFreeSpace(const std::string &directoryPath);
30    static int32_t FreeStore(const std::string &dirPath, const std::string &fileName);
31    // Write data to store space by id
32    static int32_t WriteDataToStore(const std::string &dirPath, const std::string &fileName,
33        const std::vector<uint8_t> &buffer, int size);
34    // Load data from store by id
35    static int32_t LoadDataFromStore(const std::string &dirPath, const std::string &fileName,
36        std::vector<uint8_t> &buffer);
37};
38} // namespace Updater
39#endif // UPDATER_STORE_H
40