UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::FPackageTrailerBuilder Class Reference

#include <PackageTrailer.h>

Public Types

using AdditionalDataCallback = TFunction< void(FLinkerSave &LinkerSave, const class FPackageTrailer &Trailer)>
 

Public Member Functions

 FPackageTrailerBuilder ()=default
 
COREUOBJECT_API FPackageTrailerBuilder (const FName &InPackageName)
 
COREUOBJECT_API FPackageTrailerBuilder (FString &&DebugContext)
 
 ~FPackageTrailerBuilder ()=default
 
COREUOBJECT_API void AddPayload (const FIoHash &Identifier, FCompressedBuffer Payload, UE::Virtualization::EPayloadFilterReason Filter, AdditionalDataCallback &&Callback)
 
COREUOBJECT_API void AddPayload (const FIoHash &Identifier, FCompressedBuffer Payload, UE::Virtualization::EPayloadFilterReason Filter)
 
COREUOBJECT_API void AddVirtualizedPayload (const FIoHash &Identifier, int64 RawSize)
 
COREUOBJECT_API bool UpdatePayloadAsLocal (const FIoHash &Identifier, FCompressedBuffer Payload)
 
COREUOBJECT_API bool BuildAndAppendTrailer (FLinkerSave *Linker, FArchive &DataArchive)
 
COREUOBJECT_API bool BuildAndAppendTrailer (FLinkerSave *Linker, FArchive &DataArchive, int64 &InOutPackageFileOffset)
 
COREUOBJECT_API bool IsEmpty () const
 
COREUOBJECT_API bool IsLocalPayloadEntry (const FIoHash &Identifier) const
 
COREUOBJECT_API bool IsReferencedPayloadEntry (const FIoHash &Identifier) const
 
COREUOBJECT_API bool IsVirtualizedPayloadEntry (const FIoHash &Identifier) const
 
COREUOBJECT_API uint64 CalculateTrailerLength ()
 
COREUOBJECT_API int32 GetNumPayloads () const
 
COREUOBJECT_API int32 GetNumLocalPayloads () const
 
COREUOBJECT_API int32 GetNumReferencedPayloads () const
 
COREUOBJECT_API int32 GetNumVirtualizedPayloads () const
 
const FString & GetDebugContext () const
 

Static Public Member Functions

static COREUOBJECT_API FPackageTrailerBuilder CreateFromTrailer (const class FPackageTrailer &Trailer, FArchive &Ar, FString DebugContext)
 
static FPackageTrailerBuilder CreateFromTrailer (const class FPackageTrailer &Trailer, FArchive &Ar, const FName &PackageName)
 
static COREUOBJECT_API TUniquePtr< UE::FPackageTrailerBuilderCreateReferenceToTrailer (const class FPackageTrailer &Trailer, FString DebugContext)
 
static TUniquePtr< UE::FPackageTrailerBuilderCreateReferenceToTrailer (const class FPackageTrailer &Trailer, const FName &PackageName)
 

Detailed Description

This class is used to build a FPackageTrailer and write it disk.

While saving a package, payloads should be added to a FPackageTrailer via AddPayload then once the package has been saved to disk BuildAndAppendTrailer should be called.

Member Typedef Documentation

◆ AdditionalDataCallback

Constructor & Destructor Documentation

◆ FPackageTrailerBuilder() [1/3]

UE::FPackageTrailerBuilder::FPackageTrailerBuilder ( )
default

◆ FPackageTrailerBuilder() [2/3]

UE::FPackageTrailerBuilder::FPackageTrailerBuilder ( const FName InPackageName)

◆ FPackageTrailerBuilder() [3/3]

UE::FPackageTrailerBuilder::FPackageTrailerBuilder ( FString &&  DebugContext)

◆ ~FPackageTrailerBuilder()

UE::FPackageTrailerBuilder::~FPackageTrailerBuilder ( )
default

Member Function Documentation

◆ AddPayload() [1/2]

void UE::FPackageTrailerBuilder::AddPayload ( const FIoHash Identifier,
FCompressedBuffer  Payload,
UE::Virtualization::EPayloadFilterReason  Filter 
)

◆ AddPayload() [2/2]

void UE::FPackageTrailerBuilder::AddPayload ( const FIoHash Identifier,
FCompressedBuffer  Payload,
UE::Virtualization::EPayloadFilterReason  Filter,
AdditionalDataCallback &&  Callback 
)

Adds a payload to the builder to be written to the trailer. Duplicate payloads will be discarded and only a single instance stored in the trailer.

Parameters
IdentifierThe identifier of the payload
PayloadThe payload data
FlagsThe custom flags to be applied to the payload
CallbackThis callback will be invoked once the FPackageTrailer has been built and appended to disk.

◆ AddVirtualizedPayload()

void UE::FPackageTrailerBuilder::AddVirtualizedPayload ( const FIoHash Identifier,
int64  RawSize 
)

Adds an already virtualized payload to the builder to be written to the trailer. When the trailer is written the payload will have EPayloadAccessMode::Virtualized set as it's access mode. It is assumed that the payload is already stored in the virtualization backends and it is up to the calling code to confirm this. Duplicate payloads will be discarded and only a single instance stored in the trailer.

Parameters
IdentifierThe identifier of the payload
RawSizeThe size of the payload (in bytes) when uncompressed

◆ BuildAndAppendTrailer() [1/2]

bool UE::FPackageTrailerBuilder::BuildAndAppendTrailer ( FLinkerSave Linker,
FArchive DataArchive 
)
Parameters
ExportsArchiveThe linker associated with the package being written to disk.
DataArchiveThe archive where the package data has been written to. This is where the FPackageTrailer will be written to
Returns
True if the builder was created and appended successfully and false if any error was encountered

◆ BuildAndAppendTrailer() [2/2]

bool UE::FPackageTrailerBuilder::BuildAndAppendTrailer ( FLinkerSave Linker,
FArchive DataArchive,
int64 InOutPackageFileOffset 
)
Parameters
ExportsArchiveThe linker associated with the package being written to disk.
DataArchiveThe archive where the package data has been written to. This is where the FPackageTrailer will be written to
InOutPackageFileOffsetThe offset at which the trailer is written in the package file. In this function version, DataArchive might be an archive for the entire package file, or it might be a separate archive solely for the package trailer. The caller must provide the initial value with the accumulated offset, and the function will increment this value by how many bytes are written to DataArchive.
Returns
True if the builder was created and appended successfully and false if any error was encountered

◆ CalculateTrailerLength()

uint64 UE::FPackageTrailerBuilder::CalculateTrailerLength ( )

Returns the length of the trailer (in bytes) that the builder would currently create.

NOTE: At the moment this is not const as we need to check for and remove duplicate payload entries as we do this before building the trailer not when gathering the entry info.

◆ CreateFromTrailer() [1/2]

static FPackageTrailerBuilder UE::FPackageTrailerBuilder::CreateFromTrailer ( const class FPackageTrailer Trailer,
FArchive Ar,
const FName PackageName 
)
inlinestatic

◆ CreateFromTrailer() [2/2]

static COREUOBJECT_API FPackageTrailerBuilder UE::FPackageTrailerBuilder::CreateFromTrailer ( const class FPackageTrailer Trailer,
FArchive Ar,
FString  DebugContext 
)
static

Creates a builder from a pre-existing FPackageTrailer. Payloads stored locally in the source trailer will be loaded from disk via the provided archive so that the builder can write them to any future trailer that it creates.

Parameters
TrailerThe trailer to create the builder from
ArAn archive that the trailer can use to load payloads from
DebugContextThe name or path of the of the file that owns the trailer. Used for error messages.

◆ CreateReferenceToTrailer() [1/2]

static TUniquePtr< UE::FPackageTrailerBuilder > UE::FPackageTrailerBuilder::CreateReferenceToTrailer ( const class FPackageTrailer Trailer,
const FName PackageName 
)
inlinestatic

◆ CreateReferenceToTrailer() [2/2]

TUniquePtr< UE::FPackageTrailerBuilder > UE::FPackageTrailerBuilder::CreateReferenceToTrailer ( const class FPackageTrailer Trailer,
FString  DebugContext 
)
static

Creates a builder from a pre-existing FPackageTrailer that will will reference the local payloads of the source trailer. This means that there is no need to load the payloads.

Parameters
TrailerThe trailer to create the reference from.
DebugContextThe name or path of the of the file that owns the trailer. Used for error messages.

◆ GetDebugContext()

const FString & UE::FPackageTrailerBuilder::GetDebugContext ( ) const
inline

Returns the debug context associated with the builder, used for adding further description to error messages

◆ GetNumLocalPayloads()

int32 UE::FPackageTrailerBuilder::GetNumLocalPayloads ( ) const

Returns the number of payload entries in the builder with the access mode EPayloadAccessMode::Local

◆ GetNumPayloads()

int32 UE::FPackageTrailerBuilder::GetNumPayloads ( ) const

Returns the total number of payload entries in the builder

◆ GetNumReferencedPayloads()

int32 UE::FPackageTrailerBuilder::GetNumReferencedPayloads ( ) const

Returns the number of payload entries in the builder with the access mode EPayloadAccessMode::Referenced

◆ GetNumVirtualizedPayloads()

int32 UE::FPackageTrailerBuilder::GetNumVirtualizedPayloads ( ) const

Returns the number of payload entries in the builder with the access mode EPayloadAccessMode::Virtualized

◆ IsEmpty()

bool UE::FPackageTrailerBuilder::IsEmpty ( ) const

Returns if the builder has any payload entries or not

◆ IsLocalPayloadEntry()

bool UE::FPackageTrailerBuilder::IsLocalPayloadEntry ( const FIoHash Identifier) const

◆ IsReferencedPayloadEntry()

bool UE::FPackageTrailerBuilder::IsReferencedPayloadEntry ( const FIoHash Identifier) const

◆ IsVirtualizedPayloadEntry()

bool UE::FPackageTrailerBuilder::IsVirtualizedPayloadEntry ( const FIoHash Identifier) const

◆ UpdatePayloadAsLocal()

bool UE::FPackageTrailerBuilder::UpdatePayloadAsLocal ( const FIoHash Identifier,
FCompressedBuffer  Payload 
)

Allows the caller to replace a payload in the builder that is already marked as virtualized and replace it with one that will be stored locally.

Parameters
IdentifierThe identifier of the payload
PayloadThe content of the payload
Returns
true if a virtualized payload was replaced, false if the payload was not in the builder at all

The documentation for this class was generated from the following files: