// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "../zen.h" #include #include #include namespace zen { class CbObjectView; } namespace cpr { class Response; } class ExportProjectCommand : public ZenCmdBase { public: ExportProjectCommand(); ~ExportProjectCommand(); virtual int Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) override; virtual cxxopts::Options* Options() override { return &m_Options; } struct OplogHeader { enum uint32 { kMagic = 0x7816'B013 }; uint32_t Magic = kMagic; uint32_t HeaderSize = sizeof(OplogHeader); uint64_t OpCount = 0; zen::IoHash Checksum = zen::IoHash::Zero; }; struct OplogEntry { uint64_t Offset; uint32_t OpLength; }; struct ChunksHeader { enum uint32 { kMagic = 0x574C'B016 }; uint32_t Magic = kMagic; uint64_t ChunkCount = 0; uint8_t BlockSizeShift = 31u; uint8_t Reserved1 = 0; uint16_t Reserved2 = 0; uint32_t Reserved3 = 0; }; struct ChunkEntry { zen::IoHash ChunkHash; uint64_t Offset; uint64_t Length; }; static std::filesystem::path GetOplogPath(const std::filesystem::path RootPath, const std::string& Oplog); static std::filesystem::path GetLargeChunkPath(const std::filesystem::path RootPath, const zen::IoHash& OpHash); static std::filesystem::path GetProjectPath(const std::filesystem::path RootPath, const std::string_view ProjectName); static std::filesystem::path GetChunksIndexPath(const std::filesystem::path RootPath); static std::filesystem::path GetChunksPath(const std::filesystem::path RootPath, uint32_t BlockIndex); static bool IsSuccess(const cpr::Response& Response, const std::string_view Operation); private: cxxopts::Options m_Options{"export-project", "Export one or more project oplogs to disk"}; std::string m_HostName; std::string m_TargetPath; std::string m_ProjectName; std::vector m_OplogNames; };