Navigation
API > API/Runtime > API/Runtime/PakFile
Pak file.
| Name | FPakFile |
| Type | class |
| Header File | /Engine/Source/Runtime/PakFile/Public/IPlatformFilePak.h |
| Include Path | #include "IPlatformFilePak.h" |
Syntax
class FPakFile :
private FNoncopyable,
public FRefCountBase,
public IPakFile
Inheritance Hierarchy
- FNoncopyable → FPakFile
- TTransactionalAtomicRefCount → FRefCountBase → FPakFile
Implements Interfaces
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FPakFile
(
FArchive* Archive |
Creates a pak file using the supplied archive. | IPlatformFilePak.h | |
FPakFile
(
IPlatformFile* LowerLevel, |
Creates a pak file using the supplied file handle. | IPlatformFilePak.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual ~FPakFile() |
Private destructor, use AddRef/Release instead | IPlatformFilePak.h |
Classes
| Name | Remarks |
|---|---|
| FBaseIterator | Base functionality for iterating over the DirectoryIndex. |
| FFilenameIterator | Iterator class used to iterate over just the files in the pak for which we have filenames. |
| FPakEntryIterator | Iterator class for every FPakEntry in the FPakFile, but does not provide filenames unless the PakFile has an unpruned DirectoryIndex. |
Structs
| Name | Remarks |
|---|---|
| FArchiveAndLastAccessTime | |
| FIndexSettings | |
| FScopedPakDirectoryIndexAccess | A ReadLock wrapper that must be used to prevent threading errors around any call to FindPrunedDirectory or internal uses of DirectoryIndex |
| FVisitFilter |
Enums
Public
| Name | Remarks |
|---|---|
| ECacheType | Pak files can share a cache or have their own |
| EFindResult | Finds an entry in the pak file matching the given filename. |
| EIteratorType | Internal IteratorType used by an FBaseIterator. |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FDirectoryIndex | TMap< FString, FPakDirectory > | Index data that keeps an in-memory directoryname/filename tree to map a Filename to an FPakEntryLocation | IPlatformFilePak.h |
| FDirectoryTreeIndex | UE::PakFile::Private::FDirectoryTreeIndex | IPlatformFilePak.h | |
| FPathHashIndex | TMap< uint64, FPakEntryLocation > | Index data that provides a map from the hash of a Filename to an FPakEntryLocation | IPlatformFilePak.h |
| ReadNextEntryFunction | TFunction< FPakEntryPair &()> | 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 | IPlatformFilePak.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| bSomePakNeedsPruning | bool | Global flag for whether a Pak has indicated it needs Pruning | IPlatformFilePak.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bHasFullDirectoryIndex | bool | True if the DirectoryIndex has not been pruned and still contains a Filename for every FPakEntry in this PakFile | IPlatformFilePak.h | |
| bHasPathHashIndex | bool | True if the PathHashIndex has been populated for this PakFile | IPlatformFilePak.h | |
| bIsMounted | bool | Record of whether the pak file is still mounted, so PakPrecacher can reject requests to register it. | IPlatformFilePak.h | |
| bIsValid | bool | True if this pak file is valid and usable. | IPlatformFilePak.h | |
| bNeedsLegacyPruning | bool | True if the Index of this PakFile was a legacy index that did not have the precomputed Pruned DirectoryIndex and we need to compute it before swapping the Pruned DirectoryIndex | IPlatformFilePak.h | |
| bSigned | bool | True if this is a signed pak file. | IPlatformFilePak.h | |
| bWillPruneDirectoryIndex | bool | True if we have a FullDirectoryIndex that we will modify in OptimizeMemoryUsageForMountedPaks and therefore need to guard access with DirectoryIndexLock | IPlatformFilePak.h | |
| CachedTotalSize | int64 | TotalSize of the pak file | IPlatformFilePak.h | |
| CacheIndex | int32 | The index of this pak file into the cache array, -1 = not initialized | IPlatformFilePak.h | |
| CacheType | ECacheType | The type of cache this pak file should have | IPlatformFilePak.h | |
| CurrentlyUsedReaders | std::atomic< int32 > | How many readers have been loaned out and not yet returned. | IPlatformFilePak.h | |
| Decryptor | TUniquePtr< class FChunkCacheWorker > | Archive to serialize the pak file from. | IPlatformFilePak.h | |
| DirectoryIndex | FDirectoryIndex | Pak Index organized as a map of directories to support searches by path. | IPlatformFilePak.h | |
| DirectoryIndexLock | FRWLock | ReaderWriter lock to guard DirectoryIndex iteration from being interrupted by the swap of PrunedDirectoryIndex | IPlatformFilePak.h | |
| DirectoryTreeIndex | FDirectoryTreeIndex | IPlatformFilePak.h | ||
| EncodedPakEntries | TArray< uint8 > | FPakEntries that have been serialized into a compacted format in an array of bytes. | IPlatformFilePak.h | |
| Files | TArray< FPakEntry > | Info on all files stored in pak. | IPlatformFilePak.h | |
| Info | FPakInfo | Pak file info (trailer). | IPlatformFilePak.h | |
| IoContainerHeader | TUniquePtr< FIoContainerHeader > | IPlatformFilePak.h | ||
| MappedFileHandle | TSharedPtr< IMappedFileHandle > | IPlatformFilePak.h | ||
| MappedFileHandleCriticalSection | FCriticalSection | IPlatformFilePak.h | ||
| MountPoint | FString | Mount point. | IPlatformFilePak.h | |
| NumEntries | int32 | The number of file entries in the pak file | IPlatformFilePak.h | |
| OptionalSegmentIoContainerHeader | TUniquePtr< FIoContainerHeader > | IPlatformFilePak.h | ||
| PakchunkIndex | int32 | ID for the chunk this pakfile is part of. | IPlatformFilePak.h | |
| PakFilename | FString | Pak filename. | IPlatformFilePak.h | |
| PakFilenameName | FName | IPlatformFilePak.h | ||
| PathHashIndex | FPathHashIndex | Index data that provides a map from the hash of a Filename to an FPakEntryLocation | IPlatformFilePak.h | |
| PathHashSeed | uint64 | The seed passed to the hash function for hashing filenames in this pak. | IPlatformFilePak.h | |
| PrunedDirectoryIndex | FDirectoryIndex | Temporary-lifetime copy of the Pruned DirectoryIndex; all Pruned files have been removed form this copy. | IPlatformFilePak.h | |
| PrunedDirectoryTreeIndex | FDirectoryTreeIndex | IPlatformFilePak.h | ||
| Readers | TArray< FArchiveAndLastAccessTime > | List of readers and when they were last used. | IPlatformFilePak.h | |
| ReadersCriticalSection | FCriticalSection | Critical section for accessing Readers. | IPlatformFilePak.h | |
| Timestamp | FDateTime | Timestamp of this pak file. | IPlatformFilePak.h | |
| UnderlyingCacheTrimDisabled | bool | Allow the cache of a pak file to never shrink, should be used with caution, it will burn memory | IPlatformFilePak.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool Check() |
Checks the validity of the pak data by reading out the data for every file in the pak | IPlatformFilePak.h | |
bool DirectoryExistsInPruned
(
const TCHAR* InPath |
Checks if a directory exists in pak file. | IPlatformFilePak.h | |
EFindResult Find
(
const FString& FullPath, |
IPlatformFilePak.h | ||
const FPakDirectory * FindPrunedDirectory
(
const TCHAR* InPath |
Finds a directory in pak file. | IPlatformFilePak.h | |
void FindPrunedFilesAtPath
(
ContainerType& OutFiles, |
IPlatformFilePak.h | ||
void FindPrunedFilesAtPath
(
const TCHAR* InPath, |
Looks for files or directories within the Pruned DirectoryIndex of the pak file. | IPlatformFilePak.h | |
int32 GetCacheIndex() |
IPlatformFilePak.h | ||
ECacheType GetCacheType() |
IPlatformFilePak.h | ||
const FString & GetFilename() |
Gets pak filename. | IPlatformFilePak.h | |
FName GetFilenameName() |
IPlatformFilePak.h | ||
const FPakInfo & GetInfo() |
Gets this pak file info. | IPlatformFilePak.h | |
bool GetIsMounted() |
IPlatformFilePak.h | ||
const FString & GetMountPoint() |
Gets pak file mount point. | IPlatformFilePak.h | |
virtual int32 GetNumFiles() |
Gets the number of files in this pak. | IPlatformFilePak.h | |
void GetPrunedFilenames
(
TArray< FString >& OutFileList |
Returns the FullPath (includes Mount) Filename found in Pruned DirectoryIndex | IPlatformFilePak.h | |
void GetPrunedFilenamesInChunk
(
const TArray< int32 >& InChunkIDs, |
Returns the RelativePathFromMount Filename for every Filename found in the Pruned DirectoryIndex that points to a PakEntry in the given Chunk | IPlatformFilePak.h | |
FSharedPakReader GetSharedReader
(
IPlatformFile* LowerLevel |
Gets shared pak file archive for given thread. | IPlatformFilePak.h | |
const FDateTime & GetTimestamp() |
Gets this pak file's tiemstamp. | IPlatformFilePak.h | |
bool GetUnderlyingCacheTrimDisabled() |
IPlatformFilePak.h | ||
bool HasFilenames() |
Returns whether filenames currently exist in the DirectoryIndex for all files in the Pak. | IPlatformFilePak.h | |
bool IsValid() |
Checks if the pak file is valid. | IPlatformFilePak.h | |
virtual bool PakContains
(
const FString& FullPath |
IPlatformFilePak.h | ||
virtual const FString & PakGetMountPoint() |
IPlatformFilePak.h | ||
virtual int32 PakGetPakchunkIndex() |
IPlatformFilePak.h | ||
virtual const FString & PakGetPakFilename() |
IPakFile interface, for users of PakFiles that cannot have a dependency on this header. | IPlatformFilePak.h | |
virtual void PakVisitPrunedFilenames
(
IPlatformFile::FDirectoryVisitor& Visitor |
IPlatformFilePak.h | ||
bool PassedSignatureChecks() |
Checks if the pak has valid chunk signature checking data, and that the data passed the initial signing check | IPlatformFilePak.h | |
void ReadHashFromPayload
(
const FPakEntry& PakEntry, |
FPakFile helper functions shared between the runtime and UnrealPak.exe. | IPlatformFilePak.h | |
bool RecreatePakReaders
(
IPlatformFile* LowerLevel |
Recreates the pak reader for each thread | IPlatformFilePak.h | |
void ReleaseOldReaders
(
double MaxAgeSeconds |
Delete all readers that haven't been used in MaxAgeSeconds. | IPlatformFilePak.h | |
void ReturnSharedReader
(
FArchive* SharedReader |
Return a shared pak reader. Should only be called from the FSharedPakReader's destructor. | IPlatformFilePak.h | |
void SetCacheIndex
(
int32 InCacheIndex |
IPlatformFilePak.h | ||
void SetCacheType
(
ECacheType InCacheType |
IPlatformFilePak.h | ||
void SetIsMounted
(
bool bInIsMounted |
IPlatformFilePak.h | ||
void SetMountPoint
(
const TCHAR* Path |
Sets the pak file mount point. | IPlatformFilePak.h | |
void SetUnderlyingCacheTrimDisabled
(
bool InUnderlyingCacheTrimDisabled |
IPlatformFilePak.h | ||
int64 TotalSize() |
IPlatformFilePak.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static void AddEntryToIndex
(
const FString& Filename, |
Add the given (Filename,FPakEntryLocation) value into the provided indexes | IPlatformFilePak.h | |
static int32 CompareFilenameHashes
(
const void* Left, |
IPlatformFilePak.h | ||
| Decodes a bit-encoded pak entry from a pointer to the start of its encoded bytes into the given OutEntry | IPlatformFilePak.h | ||
static void EncodePakEntriesIntoIndex
(
int32 InNumEntries, |
IPlatformFilePak.h | ||
static bool EncodePakEntry
(
FArchive& Ar, |
Encodes a pak entry as an array of bytes into the given archive. | IPlatformFilePak.h | |
static void FindFilesAtPathInPakDirectoryInternal
(
const FString& MountPoint, |
IPlatformFilePak.h | ||
static const FPakEntryLocation * FindLocationFromIndex
(
const FString& FullPath, |
Lookup the FPakEntryLocation stored in the given PathHashIndex, return nullptr if not found | IPlatformFilePak.h | |
static const FPakEntryLocation * FindLocationFromIndex
(
const FString& FullPath, |
Lookup the FPakEntryLocation stored in the given DirectoryIndex, return nullptr if not found | IPlatformFilePak.h | |
static FIndexSettings & GetIndexSettings() |
IPlatformFilePak.h | ||
static EFindResult GetPakEntry
(
const FPakEntryLocation& FPakEntryLocation, |
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 | IPlatformFilePak.h | |
static const TCHAR * GetRelativeFilePathFromMountPointer
(
const FString& Child, |
Helper function to return Filename's relative path from the mount point. | IPlatformFilePak.h | |
static bool GetRelativePathFromMountInline
(
FString& Child, |
Helper function to return Child's relative path from the mount point. | IPlatformFilePak.h | |
static uint64 HashPath
(
const TCHAR* RelativePathFromMount, |
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 | IPlatformFilePak.h | |
static bool IsPakDelayPruning () |
Returns the global,const flag for whether the current process should keep a copy of the Full DirectoryIndex around until OptimizeMemoryUsageForMountedPaks is called, so that systems can run directory queries against the full index until then. | IPlatformFilePak.h | |
static bool IsPakKeepFullDirectory() |
Returns the global,const flag for whether the current process is allowing PakFiles to keep their entire DirectoryIndex (if it exists in the PakFile on disk) rather than pruning it | IPlatformFilePak.h | |
static bool IsPakValidatePruning () |
Returns the global,const flag for whether the current process should run directory queries on both the DirectoryIndex and the Pruned DirectoryIndex and log an error if they don't match. | IPlatformFilePak.h | |
static bool IsPakWriteFullDirectoryIndex() |
Returns the global,const flag for whether UnrealPak should write a copy of the full DirectoryIndex to the PakFile | IPlatformFilePak.h | |
static bool IsPakWritePathHashIndex() |
Returns the global,const flag for whether UnrealPak should write a copy of the full PathHashIndex and Pruned DirectoryIndex to the PakFile | IPlatformFilePak.h | |
static bool IsPathInDirectoryFormat
(
const FString& Path |
Helper function to check that the given string is in our directory format (ends with '/') | IPlatformFilePak.h | |
static void MakeDirectoryFromPath
(
FString& Path |
Helper function to modify the given string to append '/' at the end of path to normalize directory names for hash and string compares | IPlatformFilePak.h | |
static FString PakPathCombine
(
FStringView Parent, |
IPlatformFilePak.h | ||
static FString PakPathCombine
(
FStringView Parent, |
Helper function to join two path strings that are in the PakPath format | IPlatformFilePak.h | |
static void PruneDirectoryIndex
(
FDirectoryIndex& InOutDirectoryIndex, |
Given a directory index, remove entries from it that are directed by ini to not have filenames kept at runtime. | IPlatformFilePak.h | |
static void PruneDirectoryIndexInternal
(
FDirectoryIndex* InOutDirectoryIndex, |
IPlatformFilePak.h | ||
static void SaveIndexInternal_DirectoryIndex
(
FArchive& Ar, |
This is an internal function that should only be called by FPakFile or by PakFileUtilities.cpp; it can change without deprecation. | IPlatformFilePak.h | |
static bool SplitPathInline
(
FStringView& InOutPath, |
Helper function to split a PakDirectoryIndex-Formatted PathName into its PakDirectoryIndex-Formatted parent directory and the CleanFileName | IPlatformFilePak.h | |
static bool SplitPathInline
(
FString& InOutPath, |
IPlatformFilePak.h |