* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef UPDATER_COMMAND_PROCESS_H
#define UPDATER_COMMAND_PROCESS_H
#include "applypatch/command.h"
#include "applypatch/command_function.h"
namespace Updater {
class AbortCommandFn : public CommandFunction {
public:
AbortCommandFn() {}
~AbortCommandFn() override {}
CommandResult Execute(const Command ¶ms) override;
};
class NewCommandFn : public CommandFunction {
public:
NewCommandFn() {}
~NewCommandFn() override {}
CommandResult Execute(const Command ¶ms) override;
private:
int32_t StreamExecute(const Command ¶ms);
};
class ZeroAndEraseCommandFn : public CommandFunction {
public:
ZeroAndEraseCommandFn() {}
~ZeroAndEraseCommandFn() override {}
CommandResult Execute(const Command ¶ms) override;
};
class FreeCommandFn : public CommandFunction {
public:
FreeCommandFn() {}
~FreeCommandFn() override {}
CommandResult Execute(const Command ¶ms) override;
};
class StashCommandFn : public CommandFunction {
public:
StashCommandFn() {}
~StashCommandFn() override {}
CommandResult Execute(const Command ¶ms) override;
};
class DiffAndMoveCommandFn : public CommandFunction {
public:
DiffAndMoveCommandFn() {}
~DiffAndMoveCommandFn() override {}
CommandResult Execute(const Command ¶ms) override;
virtual int32_t WriteDiffToBlock(const Command ¶ms, std::vector<uint8_t> &srcBuffer,
uint8_t *patchBuffer, size_t patchLength, BlockSet &targetBlock);
virtual int32_t WriteFileToBlock(const Command ¶ms, std::vector<uint8_t> &srcBuffer,
size_t offset, size_t patchLength, BlockSet &targetBlock);
private:
bool SkipInPlaceMove(const Command ¶ms, CommandType type) const;
};
}
#endif