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

#include <IPlatformFilePak.h>

+ Inheritance diagram for FPakFile:

Classes

struct  FArchiveAndLastAccessTime
 
class  FBaseIterator
 
class  FFilenameIterator
 
struct  FIndexSettings
 
class  FPakEntryIterator
 
struct  FScopedPakDirectoryIndexAccess
 

Public Types

enum class  ECacheType : uint8 { Shared , Individual }
 
enum class  EFindResult : uint8 { NotFound , Found , FoundDeleted }
 
enum class  EIteratorType : uint8 { PathHash , DirectoryIndex , DirectoryTree }
 
typedef TMap< uint64, FPakEntryLocationFPathHashIndex
 
typedef TMap< FString, FPakDirectoryFDirectoryIndex
 
typedef TFunction< FPakEntryPair &()> ReadNextEntryFunction
 

Public Member Functions

PAKFILE_API bool RecreatePakReaders (IPlatformFile *LowerLevel)
 
virtual const FString & PakGetPakFilename () const override
 
virtual bool PakContains (const FString &FullPath) const override
 
virtual int32 PakGetPakchunkIndex () const override
 
virtual void PakVisitPrunedFilenames (IPlatformFile::FDirectoryVisitor &Visitor) const override
 
virtual const FString & PakGetMountPoint () const override
 
void SetUnderlyingCacheTrimDisabled (bool InUnderlyingCacheTrimDisabled)
 
bool GetUnderlyingCacheTrimDisabled (void)
 
void SetCacheType (ECacheType InCacheType)
 
ECacheType GetCacheType (void)
 
void SetCacheIndex (int32 InCacheIndex)
 
int32 GetCacheIndex (void)
 
void SetIsMounted (bool bInIsMounted)
 
bool GetIsMounted () const
 
PAKFILE_API FPakFile (IPlatformFile *LowerLevel, const TCHAR *Filename, bool bIsSigned, bool bLoadIndex=true)
 
bool IsValid () const
 
PAKFILE_API bool PassedSignatureChecks () const
 
const FString & GetFilename () const
 
FName GetFilenameName () const
 
int64 TotalSize () const
 
virtual int32 GetNumFiles () const override
 
PAKFILE_API void GetPrunedFilenames (TArray< FString > &OutFileList) const
 
PAKFILE_API void GetPrunedFilenamesInChunk (const TArray< int32 > &InChunkIDs, TArray< FString > &OutFileList) const
 
PAKFILE_API FSharedPakReader GetSharedReader (IPlatformFile *LowerLevel)
 
PAKFILE_API void ReturnSharedReader (FArchive *SharedReader)
 
PAKFILE_API void ReleaseOldReaders (double MaxAgeSeconds)
 
PAKFILE_API EFindResult Find (const FString &FullPath, FPakEntry *OutEntry) const
 
void SetMountPoint (const TCHAR *Path)
 
const FString & GetMountPoint () const
 
template<class ContainerType >
void FindPrunedFilesAtPath (ContainerType &OutFiles, const TCHAR *InPath, bool bIncludeFiles=true, bool bIncludeDirectories=false, bool bRecursive=false) const
 
PAKFILE_API void FindPrunedFilesAtPath (const TCHAR *InPath, TArray< FString > &OutFiles, bool bIncludeFiles=true, bool bIncludeDirectories=false, bool bRecursive=false) const
 
const FPakDirectoryFindPrunedDirectory (const TCHAR *InPath) const
 
bool DirectoryExistsInPruned (const TCHAR *InPath) const
 
PAKFILE_API bool Check ()
 
const FPakInfoGetInfo () const
 
const FDateTimeGetTimestamp () const
 
bool HasFilenames () const
 
void ReadHashFromPayload (const FPakEntry &PakEntry, uint8 *OutBuffer)
 
- Public Member Functions inherited from FRefCountBase
 FRefCountBase ()=default
 
virtual ~FRefCountBase ()=default
 
 FRefCountBase (const FRefCountBase &Rhs)=delete
 
FRefCountBaseoperator= (const FRefCountBase &Rhs)=delete
 
FReturnedRefCountValue AddRef () const
 
uint32 Release () const
 
uint32 GetRefCount () const
 

Static Public Member Functions

static PAKFILE_API uint64 HashPath (const TCHAR *RelativePathFromMount, uint64 Seed, int32 PakFileVersion)
 
static PAKFILE_API void EncodePakEntriesIntoIndex (int32 InNumEntries, const ReadNextEntryFunction &InReadNextEntry, const TCHAR *InPakFilename, const FPakInfo &InPakInfo, const FString &MountPoint, int32 &OutNumEncodedEntries, int32 &OutNumDeletedEntries, uint64 *OutPathHashSeed, FDirectoryIndex *OutDirectoryIndex, FPathHashIndex *OutPathHashIndex, TArray< uint8 > &OutEncodedPakEntries, TArray< FPakEntry > &OutNonEncodableEntries, TMap< uint64, FString > *InOutCollisionDetection, int32 PakFileVersion)
 
static PAKFILE_API const FPakEntryLocationFindLocationFromIndex (const FString &FullPath, const FString &MountPoint, const FPathHashIndex &PathHashIndex, uint64 PathHashSeed, int32 PakFileVersion)
 
static PAKFILE_API const FPakEntryLocationFindLocationFromIndex (const FString &FullPath, const FString &MountPoint, const FDirectoryIndex &DirectoryIndex)
 
static PAKFILE_API EFindResult GetPakEntry (const FPakEntryLocation &FPakEntryLocation, FPakEntry *OutEntry, const TArray< uint8 > &EncodedPakEntries, const TArray< FPakEntry > &Files, const FPakInfo &Info)
 
static PAKFILE_API void PruneDirectoryIndex (FDirectoryIndex &InOutDirectoryIndex, FDirectoryIndex *PrunedDirectoryIndex, const FString &MountPoint)
 
static void MakeDirectoryFromPath (FString &Path)
 
static bool IsPathInDirectoryFormat (const FString &Path)
 
static FString PakPathCombine (FStringView Parent, FStringView Child)
 
static FString PakPathCombine (FStringView Parent, FUtf8StringView Child)
 
static bool SplitPathInline (FStringView &InOutPath, FStringView &OutFilename)
 
static bool SplitPathInline (FString &InOutPath, FString &OutFilename)
 
static bool GetRelativePathFromMountInline (FString &Child, const FString &MountPoint)
 
static const TCHARGetRelativeFilePathFromMountPointer (const FString &Child, const FString &MountPoint)
 
static PAKFILE_API bool IsPakKeepFullDirectory ()
 
static PAKFILE_API bool IsPakWritePathHashIndex ()
 
static PAKFILE_API bool IsPakWriteFullDirectoryIndex ()
 
static PAKFILE_API void SaveIndexInternal_DirectoryIndex (FArchive &Ar, const FDirectoryIndex &DirectoryTMap)
 

Friends

class FPakPlatformFile
 
class FRefCountBase
 

Detailed Description

Pak file.

Member Typedef Documentation

◆ FDirectoryIndex

Index data that keeps an in-memory directoryname/filename tree to map a Filename to an FPakEntryLocation

◆ FPathHashIndex

Index data that provides a map from the hash of a Filename to an FPakEntryLocation

◆ ReadNextEntryFunction

Read a list of (Filename, FPakEntry) pairs from a provided enumeration, attempt to encode each one, store each one in the appropriate given encoded and/or unencoded array, and populate the given Directories to map each filename to the location for the FPakEntry

Parameters
InNumEntriesHow many entries will be read from ReadNextEntryFunction
ReadNextEntryFunctionCallback called repeatedly to enumerate the (Filename,FPakEntry) pairs to be encoded
InPakFilenameFilename for the pak containing the files, used to create the hashseed for the given pak
InPakInfoPakInfo for the given pak, used for serialization flags
MountPointDirectory into which the pak will be mounted, used to create the Directory and PathHash indexes
OutNumEncodedEntriesHow many entries were written to the bytes in OutEncodedPakEntries
OutNumDeletedEntriesHow many entries were skipped and not stored because the input FPakEntry was a Delete record
OutPathHashSeedoptional out param to get a copy of the pakfile-specific hashseed
OutDirectoryIndexoptional output FDirectoryIndex
OutPathHashIndexoptional output FPathHashIndex
OutEncodedPakEntriesarray of bytes into which the encoded FPakEntries are stored. Values in OutDirectoryIndex and OutPathHashIndex can be offsets into this array indicated the start point for the encoding of the given FPakEntry
OutNonEncodableEntriesA list of all the FPakEntries that could not be encoded. Values in OutDirectoryIndex and OutPathHashIndex can be indices into this list.
InOutCollisionDetectionOptional parameter to detect hash collisions. If present, each hashed filename will be check()'d for a collision against a different filename in InOutCollisionDetection, and will be added into InOutCollisionDetection
PakFileVersionVersion of the pakfile containing the index, to support legacy formats

Member Enumeration Documentation

◆ ECacheType

Pak files can share a cache or have their own

Enumerator
Shared 
Individual 

◆ EFindResult

Finds an entry in the pak file matching the given filename.

Parameters
FilenameFile to find.
OutEntryThe optional address of an FPakEntry instance where the found file information should be stored. Pass NULL to only check for file existence.
Returns
Returns true if the file was found, false otherwise.
Enumerator
NotFound 
Found 
FoundDeleted 

◆ EIteratorType

Internal IteratorType used by an FBaseIterator.

Enumerator
PathHash 
DirectoryIndex 
DirectoryTree 

Constructor & Destructor Documentation

◆ FPakFile()

FPakFile::FPakFile ( IPlatformFile LowerLevel,
const TCHAR Filename,
bool  bIsSigned,
bool  bLoadIndex = true 
)

Creates a pak file using the supplied file handle.

Parameters
LowerLevelLower level platform file.
FilenameFilename.
bIsSigned= true if the pak is signed.

Member Function Documentation

◆ Check()

bool FPakFile::Check ( )

Checks the validity of the pak data by reading out the data for every file in the pak

Returns
true if the pak file is valid

◆ DirectoryExistsInPruned()

bool FPakFile::DirectoryExistsInPruned ( const TCHAR InPath) const
inline

Checks if a directory exists in pak file.

Parameters
InPathDirectory path.
Returns
true if the given path exists in pak file, false otherwise.

◆ EncodePakEntriesIntoIndex()

void FPakFile::EncodePakEntriesIntoIndex ( int32  InNumEntries,
const ReadNextEntryFunction InReadNextEntry,
const TCHAR InPakFilename,
const FPakInfo InPakInfo,
const FString &  MountPoint,
int32 OutNumEncodedEntries,
int32 OutNumDeletedEntries,
uint64 OutPathHashSeed,
FDirectoryIndex OutDirectoryIndex,
FPathHashIndex OutPathHashIndex,
TArray< uint8 > &  OutEncodedPakEntries,
TArray< FPakEntry > &  OutNonEncodableEntries,
TMap< uint64, FString > *  InOutCollisionDetection,
int32  PakFileVersion 
)
static

◆ Find()

FPakFile::EFindResult FPakFile::Find ( const FString &  FullPath,
FPakEntry OutEntry 
) const

◆ FindLocationFromIndex() [1/2]

const FPakEntryLocation * FPakFile::FindLocationFromIndex ( const FString &  FullPath,
const FString &  MountPoint,
const FDirectoryIndex DirectoryIndex 
)
static

Lookup the FPakEntryLocation stored in the given DirectoryIndex, return nullptr if not found

◆ FindLocationFromIndex() [2/2]

const FPakEntryLocation * FPakFile::FindLocationFromIndex ( const FString &  FullPath,
const FString &  MountPoint,
const FPathHashIndex PathHashIndex,
uint64  PathHashSeed,
int32  PakFileVersion 
)
static

Lookup the FPakEntryLocation stored in the given PathHashIndex, return nullptr if not found

◆ FindPrunedDirectory()

const FPakDirectory * FPakFile::FindPrunedDirectory ( const TCHAR InPath) const
inline

Finds a directory in pak file.

Parameters
InPathDirectory path.
Returns
Pointer to a map with directory contents if the directory was found, NULL otherwise.

◆ FindPrunedFilesAtPath() [1/2]

void FPakFile::FindPrunedFilesAtPath ( const TCHAR InPath,
TArray< FString > &  OutFiles,
bool  bIncludeFiles = true,
bool  bIncludeDirectories = false,
bool  bRecursive = false 
) const

Looks for files or directories within the Pruned DirectoryIndex of the pak file. The Pruned DirectoryIndex does not have entries for most Files in the pak; they were removed to save memory. A project can specify which FileNames and DirectoryNames can be marked to keep in the DirectoryIndex; see FPakFile::FIndexSettings and FPakFile::PruneDirectoryIndex Returned paths are full paths (include the mount point)

Parameters
InPathPath to look for files or folder at.
OutFilesList of files or folder matching search criteria.
bIncludeFilesIf true OutFiles will include matching files.
bIncludeDirectoriesIf true OutFiles will include matching folders.
bRecursiveIf true, sub-folders will also be checked.

◆ FindPrunedFilesAtPath() [2/2]

template<class ContainerType >
void FPakFile::FindPrunedFilesAtPath ( ContainerType &  OutFiles,
const TCHAR InPath,
bool  bIncludeFiles = true,
bool  bIncludeDirectories = false,
bool  bRecursive = false 
) const
inline

◆ GetCacheIndex()

int32 FPakFile::GetCacheIndex ( void  )
inline

◆ GetCacheType()

ECacheType FPakFile::GetCacheType ( void  )
inline

◆ GetFilename()

const FString & FPakFile::GetFilename ( ) const
inline

Gets pak filename.

Returns
Pak filename.

◆ GetFilenameName()

FName FPakFile::GetFilenameName ( ) const
inline

◆ GetInfo()

const FPakInfo & FPakFile::GetInfo ( ) const
inline

Gets this pak file info.

Returns
Info about this pak file.

◆ GetIsMounted()

bool FPakFile::GetIsMounted ( ) const
inline

◆ GetMountPoint()

const FString & FPakFile::GetMountPoint ( ) const
inline

Gets pak file mount point.

Returns
Mount point path.

◆ GetNumFiles()

virtual int32 FPakFile::GetNumFiles ( ) const
inlineoverridevirtual

Gets the number of files in this pak.

Implements IPakFile.

◆ GetPakEntry()

FPakFile::EFindResult FPakFile::GetPakEntry ( const FPakEntryLocation FPakEntryLocation,
FPakEntry OutEntry,
const TArray< uint8 > &  EncodedPakEntries,
const TArray< FPakEntry > &  Files,
const FPakInfo Info 
)
static

Returns the FPakEntry pointed to by the given FPakEntryLocation inside the given EncodedPakEntries or Files Can return Found or Deleted; if the FPakEntryLocation is invalid this function assumes the FPakEntry exists in this pack but as a deleted file If OutEntry is non-null, populates it with a copy of the FPakEntry found, or sets it to an FPakEntry with SetDeleteRecord(true) if not found

◆ GetPrunedFilenames()

void FPakFile::GetPrunedFilenames ( TArray< FString > &  OutFileList) const

Returns the FullPath (includes Mount) Filename found in Pruned DirectoryIndex

◆ GetPrunedFilenamesInChunk()

void FPakFile::GetPrunedFilenamesInChunk ( const TArray< int32 > &  InChunkIDs,
TArray< FString > &  OutFileList 
) const

Returns the RelativePathFromMount Filename for every Filename found in the Pruned DirectoryIndex that points to a PakEntry in the given Chunk

◆ GetRelativeFilePathFromMountPointer()

static const TCHAR * FPakFile::GetRelativeFilePathFromMountPointer ( const FString &  Child,
const FString &  MountPoint 
)
inlinestatic

Helper function to return Filename's relative path from the mount point. Returns null if Child is not equal to MountPoint and is not a child path under MountPoint, else returns pointer to the offset within Child after the MountPoint. If child equals MountPoint, returns null; The MountPoint itself is not a valid Filename, since Filenames must have non-zero length and are added on to the MountPoint.

◆ GetRelativePathFromMountInline()

static bool FPakFile::GetRelativePathFromMountInline ( FString &  Child,
const FString &  MountPoint 
)
inlinestatic

Helper function to return Child's relative path from the mount point. Returns false if Child is not equal to MountPoint and is not a child path under MountPoint, else returns true. Edits Child only if returning true, setting it to the relative path. If child equals MountPoint, returns true and sets Child to the relative path to the MountPoint, which is "/"

◆ GetSharedReader()

FSharedPakReader FPakFile::GetSharedReader ( IPlatformFile LowerLevel)

Gets shared pak file archive for given thread.

Returns
Pointer to pak file archive used to read data from pak.

◆ GetTimestamp()

const FDateTime & FPakFile::GetTimestamp ( ) const
inline

Gets this pak file's tiemstamp.

Returns
Timestamp.

◆ GetUnderlyingCacheTrimDisabled()

bool FPakFile::GetUnderlyingCacheTrimDisabled ( void  )
inline

◆ HasFilenames()

bool FPakFile::HasFilenames ( ) const
inline

Returns whether filenames currently exist in the DirectoryIndex for all files in the Pak.

Returns
true if filenames are present for all FPakEntry, false otherwise.

◆ HashPath()

uint64 FPakFile::HashPath ( const TCHAR RelativePathFromMount,
uint64  Seed,
int32  PakFileVersion 
)
static

Hash the given full-path filename using the hash function used by FPakFiles, with the given FPakFile-specific seed, with version provided for legacy pak files that used different hash function

◆ IsPakKeepFullDirectory()

bool FPakFile::IsPakKeepFullDirectory ( )
static

◆ IsPakWriteFullDirectoryIndex()

bool FPakFile::IsPakWriteFullDirectoryIndex ( )
static

◆ IsPakWritePathHashIndex()

bool FPakFile::IsPakWritePathHashIndex ( )
static

◆ IsPathInDirectoryFormat()

static bool FPakFile::IsPathInDirectoryFormat ( const FString &  Path)
inlinestatic

◆ IsValid()

bool FPakFile::IsValid ( ) const
inline

Checks if the pak file is valid.

Returns
true if this pak file is valid, false otherwise.

◆ MakeDirectoryFromPath()

static void FPakFile::MakeDirectoryFromPath ( FString &  Path)
inlinestatic

◆ PakContains()

virtual bool FPakFile::PakContains ( const FString &  Filename) const
inlineoverridevirtual

Return whether the Pak has an entry for the given FileName. Not necessarily exclusive; other Patch Paks may have their own copy of the same File.

Parameters
FilenameThe full LongPackageName path to the file, as returned from FPackageName::LongPackageNameToFilename + extension. Comparison is case-insensitive.

Implements IPakFile.

◆ PakGetMountPoint()

virtual const FString & FPakFile::PakGetMountPoint ( ) const
inlineoverridevirtual

Implements IPakFile.

◆ PakGetPakchunkIndex()

virtual int32 FPakFile::PakGetPakchunkIndex ( ) const
inlineoverridevirtual

Implements IPakFile.

◆ PakGetPakFilename()

virtual const FString & FPakFile::PakGetPakFilename ( ) const
inlineoverridevirtual

Implements IPakFile.

◆ PakPathCombine() [1/2]

FString FPakFile::PakPathCombine ( FStringView  Parent,
FStringView  Child 
)
static

◆ PakPathCombine() [2/2]

FString FPakFile::PakPathCombine ( FStringView  Parent,
FUtf8StringView  Child 
)
static

◆ PakVisitPrunedFilenames()

virtual void FPakFile::PakVisitPrunedFilenames ( IPlatformFile::FDirectoryVisitor Visitor) const
inlineoverridevirtual

Calls the given Visitor on every FileName in the Pruned Directory Index. FileNames passed to the Vistory are the RelativePath from the Mount of the PakFile The Pruned Directory Index at Runtime contains only the DirectoryIndexKeepFiles-specified subset of FilesNames and DirectoryNames that exist in the PakFile

Implements IPakFile.

◆ PassedSignatureChecks()

bool FPakFile::PassedSignatureChecks ( ) const

Checks if the pak has valid chunk signature checking data, and that the data passed the initial signing check

Returns
true if this pak file has passed the initial signature checking phase

◆ PruneDirectoryIndex()

void FPakFile::PruneDirectoryIndex ( FDirectoryIndex InOutDirectoryIndex,
FDirectoryIndex PrunedDirectoryIndex,
const FString &  MountPoint 
)
static

Given a directory index, remove entries from it that are directed by ini to not have filenames kept at runtime.

InOutDirectoryIndex - The full index from which to potentially remove entries OutDirectoryIndex - If null, InOutDirectoryIndex will have pruned entries removed. If non-null, InOutDirectoryIndex will not be modified, and PrunedDirectoryIndex will have kept values added. MountPoint The mount point for the pak containing the index, used to provide the fullpath for filenames in the DirectoryIndex for comparison against paths in ini

◆ ReadHashFromPayload()

void FPakFile::ReadHashFromPayload ( const FPakEntry PakEntry,
uint8 OutBuffer 
)
inline

◆ RecreatePakReaders()

bool FPakFile::RecreatePakReaders ( IPlatformFile LowerLevel)

Recreates the pak reader for each thread

◆ ReleaseOldReaders()

void FPakFile::ReleaseOldReaders ( double  MaxAgeSeconds)

◆ ReturnSharedReader()

void FPakFile::ReturnSharedReader ( FArchive SharedReader)

◆ SaveIndexInternal_DirectoryIndex()

void FPakFile::SaveIndexInternal_DirectoryIndex ( FArchive Ar,
const FDirectoryIndex DirectoryTMap 
)
static

◆ SetCacheIndex()

void FPakFile::SetCacheIndex ( int32  InCacheIndex)
inline

◆ SetCacheType()

void FPakFile::SetCacheType ( ECacheType  InCacheType)
inline

◆ SetIsMounted()

void FPakFile::SetIsMounted ( bool  bInIsMounted)
inline

◆ SetMountPoint()

void FPakFile::SetMountPoint ( const TCHAR Path)
inline

Sets the pak file mount point.

Parameters
PathNew mount point path.

◆ SetUnderlyingCacheTrimDisabled()

void FPakFile::SetUnderlyingCacheTrimDisabled ( bool  InUnderlyingCacheTrimDisabled)
inline

◆ SplitPathInline() [1/2]

static bool FPakFile::SplitPathInline ( FString &  InOutPath,
FString &  OutFilename 
)
inlinestatic

◆ SplitPathInline() [2/2]

bool FPakFile::SplitPathInline ( FStringView InOutPath,
FStringView OutFilename 
)
static

Helper function to split a PakDirectoryIndex-Formatted PathName into its PakDirectoryIndex-Formatted parent directory and the CleanFileName

◆ TotalSize()

int64 FPakFile::TotalSize ( ) const
inline

Friends And Related Symbol Documentation

◆ FPakPlatformFile

friend class FPakPlatformFile
friend

◆ FRefCountBase

friend class FRefCountBase
friend

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