aboutsummaryrefslogtreecommitdiff
path: root/src/zenhorde/hordebundle.h
blob: 052f604355587c3e84862c759b10fd9c8c51cf7c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include <filesystem>
#include <string>
#include <vector>

namespace zen::horde {

/** Describes a file to include in a Horde bundle. */
struct BundleFile
{
	std::filesystem::path Path;		 ///< Local file path
	bool				  Optional;	 ///< If true, skip without error if missing
};

/** Result of a successful bundle creation. */
struct BundleResult
{
	std::string			  Locator;	  ///< Root directory locator for WriteFiles
	std::filesystem::path BundleDir;  ///< Directory containing .blob files
};

/** Creates Horde V2 bundles from local files for upload to remote agents.
 *
 *  Produces a proper Horde storage V2 bundle containing:
 *  - Chunk leaf exports for file data (split into 64KB chunks for large files)
 *  - Optional interior chunk nodes referencing leaf chunks
 *  - A directory node listing all bundled files with metadata
 *
 *  The bundle is written as a single .blob file with a corresponding .ref file
 *  containing the locator string. The locator format is:
 *    <blob_name>#pkt=0,<encoded_len>&exp=<directory_export_index>
 */
struct BundleCreator
{
	/** Create a V2 bundle from one or more input files.
	 *  @param Files      Files to include in the bundle.
	 *  @param OutputDir  Directory where .blob and .ref files will be written.
	 *  @param OutResult  Receives the locator and output directory on success.
	 *  @return True on success. */
	static bool CreateBundle(const std::vector<BundleFile>& Files, const std::filesystem::path& OutputDir, BundleResult& OutResult);

	/** Read a locator string from a .ref file. Strips trailing whitespace/newlines. */
	static bool ReadLocator(const std::filesystem::path& RefFile, std::string& OutLocator);
};

}  // namespace zen::horde