Files
UnrealEngineUWP/Engine/Source/Programs/Unsync/Private/UnsyncCmdPatch.cpp
yuriy odonnell 4efaac4719 unsync - Tweak default logging level to output minimal information by default
* Add --silent flag to explicitly turn off all console logging except warnings and errors
* Output command line when starting logging to file

[CL 29289476 by yuriy odonnell in ue5-main branch]
2023-10-31 16:34:04 -04:00

45 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "UnsyncCmdPatch.h"
#include "UnsyncFile.h"
namespace unsync {
int32 // TODO: return a TResult
CmdPatch(const FCmdPatchOptions& Options)
{
UNSYNC_LOG(L"Patching base file '%ls' using '%ls'", Options.Base.wstring().c_str(), Options.Patch.wstring().c_str());
UNSYNC_LOG(L"Output file '%ls'", Options.Output.wstring().c_str());
FBuffer BaseFile = ReadFileToBuffer(Options.Base);
if (BaseFile.Empty())
{
UNSYNC_ERROR(L"Failed to open file '%ls'", Options.Base.wstring().c_str());
return 1;
}
FBuffer PatchFile = ReadFileToBuffer(Options.Patch);
if (PatchFile.Empty())
{
UNSYNC_ERROR(L"Failed to open patch file '%ls'", Options.Patch.wstring().c_str());
return 1;
}
FBuffer TargetData = BuildTargetWithPatch(PatchFile.Data(), PatchFile.Size(), BaseFile.Data(), BaseFile.Size());
if (TargetData.Empty())
{
return 1;
}
if (!GDryRun)
{
UNSYNC_LOG(L"Writing output file to '%ls'", Options.Output.wstring().c_str());
return WriteBufferToFile(Options.Output, TargetData) ? 0 : 1;
}
return 0;
}
} // namespace unsync