UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IPlatformFilePak.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
8#include "Containers/Map.h"
9#include "Containers/Set.h"
12#include "Containers/Ticker.h"
15#include "CoreMinimal.h"
16#include "Delegates/Delegate.h"
19#include "HAL/CriticalSection.h"
20#include "HAL/PlatformCrt.h"
21#include "HAL/PlatformTime.h"
22#include "HAL/UnrealMemory.h"
23#include "Logging/LogCategory.h"
24#include "Logging/LogMacros.h"
25#include "Math/BigInt.h"
26#include "Math/NumericLimits.h"
27#include "Math/UnrealMathSSE.h"
28#include "Misc/AES.h"
30#include "Misc/CString.h"
32#include "Misc/DateTime.h"
33#include "Misc/Guid.h"
34#include "Misc/IEngineCrypto.h"
35#include "Misc/Optional.h"
36#include "Misc/Paths.h"
37#include "Misc/ScopeLock.h"
38#include "Misc/ScopeRWLock.h"
39#include "Misc/SecureHash.h"
41#include "RSA.h"
44#include "Stats/Stats.h"
45#include "Templates/Function.h"
48#include "Templates/UniquePtr.h"
51#include "UObject/NameTypes.h"
52#include "UObject/UnrealNames.h"
53
54#ifndef ENABLE_PAKFILE_USE_DIRECTORY_TREE
55#define ENABLE_PAKFILE_USE_DIRECTORY_TREE 1
56#endif
57
59class FFileIoStore;
60class FIoStatus;
62class FOutputDevice;
65namespace UE::PakFile::Private
66{
67 class FPakFileDirectoryVisitorBase;
68 struct FHandleMountPaksExDelegate;
69
70 template<bool bInAllowDuplicateKeys = false>
71 struct FPakEntryFilenameSetKeyFuncs;
72}
73namespace UE::IoStore { class IFileIoDispatcherBackend; }
75
78
80
81#define PAK_TRACKER 0
82
83// ENABLE_PAKFILE_RUNTIME_PRUNING allows pruning the DirectoryIndex at runtime after all Paks have loaded rather than loading only the already-pruned DirectoryIndex
84// This requires extra cputime to make reads of the DirectoryIndex ThreadSafe, and will be removed in a future version
85#ifndef ENABLE_PAKFILE_RUNTIME_PRUNING
86#define ENABLE_PAKFILE_RUNTIME_PRUNING 1
87#endif
88#define ENABLE_PAKFILE_RUNTIME_PRUNING_VALIDATE ENABLE_PAKFILE_RUNTIME_PRUNING && !UE_BUILD_SHIPPING
89
90// Define the type of a chunk hash. Currently selectable between SHA1 and CRC32.
91#define PAKHASH_USE_CRC 1
92#if PAKHASH_USE_CRC
94#else
96#endif
97
100{
101#if PAKHASH_USE_CRC
102 return FString::Printf(TEXT("%08X"), InHash);
103#else
104 return LexToString(InHash);
105#endif
106}
107
126DECLARE_DELEGATE_ThreeParams(FPakCustomEncryptionDelegate, uint8* /*InData*/, uint32 /*InDataSize*/, FGuid /*InEncryptionKeyGuid*/);
130DECLARE_DELEGATE_ThreeParams(FPakSetIndexSettings, bool& /* bKeepFullDirectory*/, bool& /* bValidatePruning */, bool& /* bDelayPruning */);
131
132UE_DEPRECATED("5.1", "Use FPakPrincipalSignatureTableCheckFailureHandler instead")
138{
139 enum
140 {
142 PakFile_Magic = 0x5A6F12E1,
144 MaxChunkDataSize = 64*1024,
146 CompressionMethodNameLen = 32,
148 MaxNumCompressionMethods=5, // when we remove patchcompatibilitymode421 we can reduce this to 4
149 };
150
152 enum
153 {
154 PakFile_Version_Initial = 1,
155 PakFile_Version_NoTimestamps = 2,
156 PakFile_Version_CompressionEncryption = 3,
157 PakFile_Version_IndexEncryption = 4,
158 PakFile_Version_RelativeChunkOffsets = 5,
159 PakFile_Version_DeleteRecords = 6,
160 PakFile_Version_EncryptionKeyGuid = 7,
161 PakFile_Version_FNameBasedCompressionMethod = 8,
162 PakFile_Version_FrozenIndex = 9,
163 PakFile_Version_PathHashIndex = 10,
164 PakFile_Version_Fnv64BugFix = 11,
165 PakFile_Version_Utf8PakDirectory = 12,
166
167
170 PakFile_Version_Latest = PakFile_Version_Last - 1
171 };
172
189
194 : Magic(PakFile_Magic)
195 , Version(PakFile_Version_Latest)
196 , IndexOffset(-1)
197 , IndexSize(0)
198 , bEncryptedIndex(0)
199 {
200 // we always put in a NAME_None entry as index 0, so that an uncompressed PakEntry will have CompressionMethodIndex of 0 and can early out easily
201 CompressionMethods.Add(NAME_None);
202 }
203
209 int64 GetSerializedSize(int32 InVersion = PakFile_Version_Latest) const
210 {
211 int64 Size = sizeof(Magic) + sizeof(Version) + sizeof(IndexOffset) + sizeof(IndexSize) + sizeof(IndexHash) + sizeof(bEncryptedIndex);
212 if (InVersion >= PakFile_Version_EncryptionKeyGuid) Size += sizeof(EncryptionKeyGuid);
213 if (InVersion >= PakFile_Version_FNameBasedCompressionMethod) Size += CompressionMethodNameLen * MaxNumCompressionMethods;
214 if (InVersion >= PakFile_Version_FrozenIndex && InVersion < PakFile_Version_PathHashIndex) Size += sizeof(bool);
215
216 return Size;
217 }
218
222 {
223 return Version >= PakFile_Version_RelativeChunkOffsets;
224 }
225
232 {
233 if (Ar.IsLoading() && Ar.TotalSize() < (Ar.Tell() + GetSerializedSize(InVersion)))
234 {
235 Magic = 0;
236 return;
237 }
238
239 if (Ar.IsSaving() || InVersion >= PakFile_Version_EncryptionKeyGuid)
240 {
241 Ar << EncryptionKeyGuid;
242 }
243 Ar << bEncryptedIndex;
244 Ar << Magic;
245 if (Magic != PakFile_Magic)
246 {
247 // handle old versions by failing out now (earlier versions will be attempted)
248 Magic = 0;
249 return;
250 }
251
252 Ar << Version;
253 Ar << IndexOffset;
254 Ar << IndexSize;
255 Ar << IndexHash;
256
257 if (Ar.IsLoading())
258 {
259 if (Version < PakFile_Version_IndexEncryption)
260 {
261 bEncryptedIndex = false;
262 }
263
264 if (Version < PakFile_Version_EncryptionKeyGuid)
265 {
266 EncryptionKeyGuid.Invalidate();
267 }
268 }
269
270 if (Version >= PakFile_Version_FrozenIndex && Version < PakFile_Version_PathHashIndex)
271 {
272 bool bIndexIsFrozen = false;
273 Ar << bIndexIsFrozen;
274 if (bIndexIsFrozen)
275 {
276 UE_LOG(LogPakFile, Fatal, TEXT("PakFile was frozen with version FPakInfo::PakFile_Version_FrozenIndex, which is no longer supported. Regenerate Paks."));
277 }
278 }
279
280 if (Version < PakFile_Version_FNameBasedCompressionMethod)
281 {
282 // for old versions, put in some known names that we may have used
283 CompressionMethods.Add(NAME_Zlib);
284 CompressionMethods.Add(NAME_Gzip);
285 CompressionMethods.Add(TEXT("Oodle"));
286 }
287 else
288 {
289 // we need to serialize a known size, so make a buffer of "strings"
290 const int32 BufferSize = CompressionMethodNameLen * MaxNumCompressionMethods;
291 ANSICHAR Methods[BufferSize];
292 if (Ar.IsLoading())
293 {
294 Ar.Serialize(Methods, BufferSize);
295 for (int32 Index = 0; Index < MaxNumCompressionMethods; Index++)
296 {
297 ANSICHAR* MethodString = &Methods[Index * CompressionMethodNameLen];
298 if (MethodString[0] != 0)
299 {
300 // Make sure if the file has garbage we don't read off in to lala land.
301 MethodString[CompressionMethodNameLen-1] = 0;
302 CompressionMethods.Add(FName(MethodString));
303 }
304 }
305 }
306 else
307 {
308 // we always zero out fully what we write out so that reading in is simple
309 FMemory::Memzero(Methods, BufferSize);
310
311 for (int32 Index = 1; Index < CompressionMethods.Num(); Index++)
312 {
313 ANSICHAR* MethodString = &Methods[(Index - 1) * CompressionMethodNameLen];
314 FCStringAnsi::Strncpy(MethodString, TCHAR_TO_ANSI(*CompressionMethods[Index].ToString()), CompressionMethodNameLen);
315 }
316 Ar.Serialize(Methods, BufferSize);
317 }
318 }
319 }
320
322 {
323 // look for existing method
324 for (uint8 Index = 0; Index < CompressionMethods.Num(); Index++)
325 {
326 if (CompressionMethods[Index] == CompressionMethod)
327 {
328 return Index;
329 }
330 }
331
332 checkf(CompressionMethod.ToString().Len() < CompressionMethodNameLen, TEXT("Compression method name, %s, is too long for pak file serialization. You can increase CompressionMethodNameLen, but then will have to handle version management."), *CompressionMethod.ToString());
333 // CompressionMethods always has None at Index 0, that we don't serialize, so we can allow for one more in the array
334 checkf(CompressionMethods.Num() <= MaxNumCompressionMethods, TEXT("Too many unique compression methods in one pak file. You can increase MaxNumCompressionMethods, but then will have to handle version management."));
335
336 // add it if it didn't exist
337 return CompressionMethods.Add(CompressionMethod);
338 }
339
341 {
342 return CompressionMethods[Index];
343 }
344
346 {
347 if (IntFitsIn<int32>(Index) == false)
348 {
349 return TOptional<FName>();
350 }
351 return (int32)Index >= CompressionMethods.Num() ? TOptional<FName>() : TOptional<FName>(CompressionMethods[(int32)Index]);
352 }
353};
354
359{
364
366 {
367 return CompressedStart == B.CompressedStart && CompressedEnd == B.CompressedEnd;
368 }
369
371 {
372 return !(*this == B);
373 }
374};
375
377{
378 Ar << Block.CompressedStart;
379 Ar << Block.CompressedEnd;
380 return Ar;
381}
382
396{
397 static const uint8 Flag_None = 0x00;
398 static const uint8 Flag_Encrypted = 0x01;
399 static const uint8 Flag_Deleted = 0x02;
400
418 mutable bool Verified;
419
424 {
425 Reset();
426 }
427
434 {
435 int64 SerializedSize = sizeof(Offset) + sizeof(Size) + sizeof(UncompressedSize) + sizeof(Hash);
436
438 {
439 SerializedSize += sizeof(CompressionMethodIndex);
440 }
441 else
442 {
443 SerializedSize += sizeof(int32); // Old CompressedMethod var from pre-fname based compression methods
444 }
445
447 {
448 SerializedSize += sizeof(Flags) + sizeof(CompressionBlockSize);
450 {
451 SerializedSize += sizeof(FPakCompressedBlock) * CompressionBlocks.Num() + sizeof(int32);
452 }
453 }
455 {
456 // Timestamp
457 SerializedSize += sizeof(int64);
458 }
459 return SerializedSize;
460 }
461
465 bool operator == (const FPakEntry& B) const
466 {
467 return IndexDataEquals(B) &&
468 FMemory::Memcmp(Hash, B.Hash, sizeof(Hash)) == 0;
469 }
470
474 bool operator != (const FPakEntry& B) const
475 {
476 return !(*this == B);
477 }
478
479 bool IndexDataEquals(const FPakEntry& B) const
480 {
481 // Offset are only in the Index and so are not compared
482 // Hash is only in the payload and so are not compared
483 // Verified is only in the payload and is mutable and so is not compared
484 return Size == B.Size &&
485 UncompressedSize == B.UncompressedSize &&
486 CompressionMethodIndex == B.CompressionMethodIndex &&
487 Flags == B.Flags &&
488 CompressionBlockSize == B.CompressionBlockSize &&
489 CompressionBlocks == B.CompressionBlocks;
490 }
491
492 void Reset()
493 {
494 Offset = -1;
495 Size = 0;
497 FMemory::Memset(Hash, 0, sizeof(Hash));
502 Verified = false;
503 }
504
511 void Serialize(FArchive& Ar, int32 Version)
512 {
513 Ar << Offset;
514 Ar << Size;
515 Ar << UncompressedSize;
517 {
521 {
523 }
525 {
527 }
529 {
531 }
533 {
535 }
536 else
537 {
538 UE_LOG(LogPakFile, Fatal, TEXT("Found an unknown compression type in pak file, will need to be supported for legacy files"));
539 }
540 }
541 else
542 {
544 }
546 {
548 Ar << Timestamp;
549 }
550 Ar.Serialize(Hash, sizeof(Hash));
552 {
554 {
555 Ar << CompressionBlocks;
556 }
557 Ar << Flags;
559 }
560 }
561
562 inline void SetFlag( uint8 InFlag, bool bValue )
563 {
564 if( bValue )
565 {
566 Flags |= InFlag;
567 }
568 else
569 {
570 Flags &= ~InFlag;
571 }
572 }
573
574 inline bool GetFlag( uint8 InFlag ) const
575 {
576 return (Flags & InFlag) == InFlag;
577 }
578
579 inline bool IsEncrypted() const { return GetFlag(Flag_Encrypted); }
580 inline void SetEncrypted( bool bEncrypted ) { SetFlag( Flag_Encrypted, bEncrypted ); }
581
582 inline bool IsDeleteRecord() const { return GetFlag(Flag_Deleted); }
584
585
593};
594
600{
601public:
602 /*
603 * 0x00000000 - 0x7ffffffe: EncodedOffset from 0 to MaxIndex
604 * 0x7fffffff: Unused, interpreted as Invalid
605 * 0x80000000: Invalid
606 * 0x80000001 - 0xffffffff: FileIndex from MaxIndex to 0
607 */
608 static const int32 Invalid = MIN_int32;
609 static const int32 MaxIndex = MAX_int32 - 1;
610
616
618 {
619 return FPakEntryLocation();
620 }
621
627
629 {
630 check(0 <= ListIndex && ListIndex <= MaxIndex);
631 return FPakEntryLocation(-ListIndex - 1);
632 }
633
634 bool IsInvalid() const
635 {
636 return Index <= Invalid || MaxIndex < Index;
637 }
638
640 {
641 return 0 <= Index && Index <= MaxIndex;
642 }
643
644 bool IsListIndex() const
645 {
646 return (-MaxIndex - 1) <= Index && Index <= -1;
647 }
648
650 {
652 {
653 return Index;
654 }
655 else
656 {
657 return -1;
658 }
659 }
661 {
662 if (IsListIndex())
663 {
664 return -(Index + 1);
665 }
666 else
667 {
668 return -1;
669 }
670 }
671
673 {
674 Ar << Index;
675 }
676
678 {
679 return Index == Other.Index;
680 }
681private:
683 {
684 }
685
686 int32 Index;
687};
693
694
695class FPakFile;
696
697// Wrapper for a pointer to a shared pak reader archive that has been temporarily acquired.
699{
700 friend class FPakFile;
701
702 FArchive* Archive = nullptr;
703 FPakFile* PakFile = nullptr; // Pak file to return ownership to on destruction
704
706
707public:
709
714
715 explicit operator bool() const { return Archive != nullptr; }
716 bool operator==(TYPE_OF_NULLPTR) { return Archive == nullptr; }
717 bool operator!=(TYPE_OF_NULLPTR) { return Archive != nullptr; }
718 FArchive* operator->() { return Archive; }
719
720
721 // USE WITH CARE, the FSharedPakReader must live longer than this reference to prevent the archive being used by another thread. Do not call on a temporary return value!
722 FArchive& GetArchive() { return *Archive; }
723
724};
725
728
729namespace UE::PakFile::Private
730{
731#if ENABLE_PAKFILE_USE_DIRECTORY_TREE
733#else
735 {
736 };
738#endif
739}
740
741/* Convenience struct for building FPakFile indexes from an enumeration of (Filename,FPakEntry) pairs */
743{
744 FString Filename;
746};
747
752{
753public:
758
760 enum class ECacheType : uint8
761 {
762 Shared,
764 };
765
768 {
770#if ENABLE_PAKFILE_RUNTIME_PRUNING
772 , bRequiresDirectoryIndexLock(PakFile.RequiresDirectoryIndexLock())
773#endif
774 {
775#if ENABLE_PAKFILE_RUNTIME_PRUNING
777 {
778 PakFile.DirectoryIndexLock.ReadLock();
779 }
780#endif
781 }
782#if ENABLE_PAKFILE_RUNTIME_PRUNING
784 {
786 {
787 PakFile.DirectoryIndexLock.ReadUnlock();
788 }
789 }
792#endif
793 };
794
797
803
804private:
805 friend class FPakPlatformFile;
806
808 FString PakFilename;
809 FName PakFilenameName;
815 std::atomic<int32> CurrentlyUsedReaders = 0;
817 FCriticalSection ReadersCriticalSection;
821 FString MountPoint;
823 TArray<FPakEntry> Files;
826
828
829 FDirectoryTreeIndex DirectoryTreeIndex;
830
831#if ENABLE_PAKFILE_RUNTIME_PRUNING
833 FDirectoryIndex PrunedDirectoryIndex;
834 FDirectoryTreeIndex PrunedDirectoryTreeIndex;
836 mutable FRWLock DirectoryIndexLock;
837#endif
838
840 FPathHashIndex PathHashIndex;
841 /* FPakEntries that have been serialized into a compacted format in an array of bytes. */
842 TArray<uint8> EncodedPakEntries;
843 /* The seed passed to the hash function for hashing filenames in this pak. Differs per pack so that the same filename in different paks has different hashes */
844 uint64 PathHashSeed;
845
847 int32 NumEntries;
851 int64 CachedTotalSize;
853 bool bSigned;
855 bool bIsValid;
856 /* True if the PathHashIndex has been populated for this PakFile */
857 bool bHasPathHashIndex;
858 /* True if the DirectoryIndex has not been pruned and still contains a Filename for every FPakEntry in this PakFile */
859 bool bHasFullDirectoryIndex;
860#if ENABLE_PAKFILE_RUNTIME_PRUNING
861 /* True if we have a FullDirectoryIndex that we will modify in OptimizeMemoryUsageForMountedPaks and therefore need to guard access with DirectoryIndexLock */
862 bool bWillPruneDirectoryIndex;
863 /* 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*/
864 bool bNeedsLegacyPruning;
865#endif
866#if ENABLE_PAKFILE_USE_DIRECTORY_TREE
867 bool bUseDirectoryTree;
868#endif
870 int32 PakchunkIndex;
871
872 TSharedPtr<IMappedFileHandle> MappedFileHandle;
873 FCriticalSection MappedFileHandleCriticalSection;
874
876 ECacheType CacheType;
878 int32 CacheIndex;
880 bool UnderlyingCacheTrimDisabled;
882 bool bIsMounted;
883
884 TUniquePtr<FIoContainerHeader> IoContainerHeader;
885#if WITH_EDITOR
887#endif
888
889 static inline int32 CDECL CompareFilenameHashes(const void* Left, const void* Right)
890 {
891 const uint64* LeftHash = (const uint64*)Left;
892 const uint64* RightHash = (const uint64*)Right;
893 if (*LeftHash < *RightHash)
894 {
895 return -1;
896 }
897 if (*LeftHash > *RightHash)
898 {
899 return 1;
900 }
901 return 0;
902 }
903
904 PAKFILE_API FArchive* CreatePakReader(IPlatformFile* LowerLevel, const TCHAR* Filename);
905 PAKFILE_API FArchive* SetupSignedPakReader(FArchive* Reader, const TCHAR* Filename);
906
907
908public:
909 // IPakFile interface, for users of PakFiles that cannot have a dependency on this header
910 virtual const FString& PakGetPakFilename() const override
911 {
912 return PakFilename;
913 }
914
915 virtual bool PakContains(const FString& FullPath) const override
916 {
917 return Find(FullPath, nullptr) == EFindResult::Found;
918 }
919
920 virtual int32 PakGetPakchunkIndex() const override
921 {
922 return PakchunkIndex;
923 }
924
925 virtual void PakVisitPrunedFilenames(IPlatformFile::FDirectoryVisitor& Visitor) const override
926 {
927 for (FFilenameIterator It(*this); It; ++It)
928 {
929 Visitor.CallShouldVisitAndVisit(*It.Filename(), false);
930 }
931 }
932
933 virtual const FString& PakGetMountPoint() const override
934 {
935 return MountPoint;
936 }
937
938
940 bool GetUnderlyingCacheTrimDisabled(void) { return UnderlyingCacheTrimDisabled; }
941
943 ECacheType GetCacheType(void) { return CacheType; }
945 int32 GetCacheIndex(void) { return CacheIndex; }
946 void SetIsMounted(bool bInIsMounted) { bIsMounted = bInIsMounted; }
947 bool GetIsMounted() const { return bIsMounted; }
948#if IS_PROGRAM
955 PAKFILE_API FPakFile(const TCHAR* Filename, bool bIsSigned);
956#endif
957
965 PAKFILE_API FPakFile(IPlatformFile* LowerLevel, const TCHAR* Filename, bool bIsSigned, bool bLoadIndex = true);
966
972#if WITH_EDITOR
973 PAKFILE_API FPakFile(FArchive* Archive);
974#endif
975
976private:
978 PAKFILE_API virtual ~FPakFile();
979 friend class FRefCountBase;
980
981public:
982
988 bool IsValid() const
989 {
990 return bIsValid;
991 }
992
999
1005 const FString& GetFilename() const
1006 {
1007 return PakFilename;
1008 }
1010 {
1011 return PakFilenameName;
1012 }
1013
1015 {
1016 return CachedTotalSize;
1017 }
1018
1022 virtual int32 GetNumFiles() const override
1023 {
1024 return NumEntries;
1025 }
1026
1029
1032
1039
1040 // Return a shared pak reader. Should only be called from the FSharedPakReader's destructor.
1042
1043 // Delete all readers that haven't been used in MaxAgeSeconds.
1045
1053 enum class EFindResult : uint8
1054 {
1055 NotFound,
1056 Found,
1058 };
1059 PAKFILE_API EFindResult Find(const FString& FullPath, FPakEntry* OutEntry) const;
1060
1066 void SetMountPoint(const TCHAR* Path)
1067 {
1068 MountPoint = Path;
1069 MakeDirectoryFromPath(MountPoint);
1070 }
1071
1077 const FString& GetMountPoint() const
1078 {
1079 return MountPoint;
1080 }
1081
1082 template <class ContainerType>
1083 UE_DEPRECATED(5.4, "Use version that takes a TArray<FString>& instead.")
1085 bool bIncludeFiles = true, bool bIncludeDirectories = false, bool bRecursive = false) const
1086 {
1087 TArray<FString> LocalFiles;
1088 FindPrunedFilesAtPath(InPath, LocalFiles, bIncludeFiles, bIncludeDirectories, bRecursive);
1089 for (FString& File : LocalFiles)
1090 {
1091 OutFiles.Add(File);
1092 }
1093 }
1094
1108 bool bIncludeFiles = true, bool bIncludeDirectories = false, bool bRecursive = false) const;
1109
1117 {
1118 // Caller holds FScopedPakDirectoryIndexAccess
1119 FString RelativePathFromMount;
1120 if (!NormalizeDirectoryQuery(InPath, RelativePathFromMount))
1121 {
1122 return nullptr;
1123 }
1124
1125 return FindPrunedDirectoryInternal(RelativePathFromMount);
1126 }
1127
1135 {
1136 FString RelativePathFromMount;
1137 if (!NormalizeDirectoryQuery(InPath, RelativePathFromMount))
1138 {
1139 return false;
1140 }
1141
1143 return FindPrunedDirectoryInternal(RelativePathFromMount) != nullptr;
1144 }
1145
1151 PAKFILE_API bool Check();
1152
1155 {
1156 PathHash,
1159 };
1162 {
1163 private:
1165 const FPakFile* PakFile;
1168#if ENABLE_PAKFILE_USE_DIRECTORY_TREE
1175#endif
1181 mutable FString CachedFilename;
1182 /* The PakEntry for return in Info */
1183 mutable FPakEntry PakEntry;
1184 /* Which type of internal iterator this iterator and its pakfile are using. */
1185 EIteratorType IteratorType;
1187 bool bIncludeDeleted;
1188#if ENABLE_PAKFILE_RUNTIME_PRUNING
1190 bool bRequiresDirectoryIndexLock;
1191#endif
1192
1193 public:
1196 // PakFile iterators can be large, because they have to walk a tree, so do not copy them, move construct only.
1199
1201
1203 PAKFILE_API explicit operator bool() const;
1204
1206 PAKFILE_API bool operator !() const;
1207
1209 PAKFILE_API const FPakEntry& Info() const;
1210
1211 PAKFILE_API bool HasFilename() const;
1212
1213 protected:
1215
1216#if ENABLE_PAKFILE_RUNTIME_PRUNING
1218#endif
1219
1221 PAKFILE_API const FString& Filename() const;
1222
1225
1226 private:
1227
1228 /* Skips over deleted records and moves to the next Directory in the DirectoryIndex when necessary. */
1229 void AdvanceToValid();
1230
1232 FPathHashIndex::TConstIterator& GetPathHashIt();
1233 const FPathHashIndex::TConstIterator& GetPathHashIt() const;
1234
1239 bool IsDirectoryItValid() const;
1240 void IncrementDirectoryIt();
1241 FStringView GetDirectoryItKey() const;
1242 const FPakDirectory& GetDirectoryItValue() const;
1243 FPakDirectory::TConstIterator& GetFileIt();
1244 const FPakDirectory::TConstIterator& GetFileIt() const;
1245
1247 FDirectoryIndex::TConstIterator& GetDirectoryIndexIt();
1248 const FDirectoryIndex::TConstIterator& GetDirectoryIndexIt() const;
1249
1250#if ENABLE_PAKFILE_USE_DIRECTORY_TREE
1253 const FDirectoryTreeIndex::FConstIterator& GetTreeIt() const;
1254#endif
1255 };
1256
1259 {
1260 public:
1262 : FBaseIterator(InPakFile, bInIncludeDeleted, !InPakFile.bHasFullDirectoryIndex /* bUsePathHash */)
1263 {
1264 }
1265
1266 const FString* TryGetFilename() const
1267 {
1268 if (HasFilename())
1269 {
1270 return &Filename();
1271 }
1272 else
1273 {
1274 return nullptr;
1275 }
1276 }
1277 };
1278
1281 {
1282 public:
1289 : FBaseIterator(InPakFile, bInIncludeDeleted, false /* bUsePathHash */)
1290 {
1291 }
1292
1294 };
1295
1301 const FPakInfo& GetInfo() const
1302 {
1303 return Info;
1304 }
1305
1312 {
1313 return Timestamp;
1314 }
1315
1321 bool HasFilenames() const
1322 {
1323 return bHasFullDirectoryIndex;
1324 }
1325
1326 // FPakFile helper functions shared between the runtime and UnrealPak.exe
1327 /*
1328 * Given a FPakEntry from the index, seek to the payload and read the hash of the payload out of the payload entry
1329 * Warning: Slow function, do not use in performance critical operations
1330 *
1331 * @param PakEntry the FPakEntry from the index, which has the Offset to read to
1332 * @param OutBuffer a buffer at least sizeof(FPakEntry::Hash) in size, into which the hash will be copied
1333 */
1334 void ReadHashFromPayload(const FPakEntry& PakEntry, uint8* OutBuffer)
1335 {
1336 if (PakEntry.IsDeleteRecord())
1337 {
1338 FMemory::Memset(OutBuffer, 0, sizeof(FPakEntry::Hash));
1339 }
1340 else
1341 {
1342 TUniquePtr<FArchive> Reader {CreatePakReader(nullptr, *GetFilename())};
1343 Reader->Seek(PakEntry.Offset);
1345 SerializedEntry.Serialize(*Reader, GetInfo().Version);
1346 FMemory::Memcpy(OutBuffer, &SerializedEntry.Hash, sizeof(SerializedEntry.Hash));
1347 }
1348 }
1349
1352
1377
1379 static PAKFILE_API const FPakEntryLocation* FindLocationFromIndex(const FString& FullPath, const FString& MountPoint, const FPathHashIndex& PathHashIndex, uint64 PathHashSeed, int32 PakFileVersion);
1380
1382 static PAKFILE_API const FPakEntryLocation* FindLocationFromIndex(const FString& FullPath, const FString& MountPoint, const FDirectoryIndex& DirectoryIndex);
1383
1390 static PAKFILE_API EFindResult GetPakEntry(const FPakEntryLocation& FPakEntryLocation, FPakEntry* OutEntry, const TArray<uint8>& EncodedPakEntries, const TArray<FPakEntry>& Files, const FPakInfo& Info);
1391
1399 static PAKFILE_API void PruneDirectoryIndex(FDirectoryIndex& InOutDirectoryIndex, FDirectoryIndex* PrunedDirectoryIndex, const FString& MountPoint);
1400
1401 /* Helper function to modify the given string to append '/' at the end of path to normalize directory names for hash and string compares */
1402 static void MakeDirectoryFromPath(FString& Path)
1403 {
1404 if (Path.Len() > 0 && Path[Path.Len() - 1] != '/')
1405 {
1406 Path += TEXT("/");
1407 }
1408 }
1409 /* Helper function to check that the given string is in our directory format (ends with '/') */
1410 static bool IsPathInDirectoryFormat(const FString& Path)
1411 {
1412 return Path.Len() > 0 && Path[Path.Len() - 1] == TEXT('/');
1413 }
1414
1415 /* Helper function to join two path strings that are in the PakPath format */
1418
1421
1422 static bool SplitPathInline(FString& InOutPath, FString& OutFilename)
1423 {
1424 FStringView Path(InOutPath), Filename;
1425 const bool bResult = SplitPathInline(Path, Filename);
1426 OutFilename = Filename;
1427 InOutPath = Path;
1428 return bResult;
1429 }
1430
1436 static bool GetRelativePathFromMountInline(FString& Child, const FString& MountPoint)
1437 {
1438 if (!Child.StartsWith(MountPoint))
1439 {
1440 return false;
1441 }
1442 Child = Child.Mid(MountPoint.Len());
1443 if (Child.IsEmpty())
1444 {
1445 // Child equals the MountPoint
1446 Child = TEXT("/");
1447 }
1448 return true;
1449 }
1450
1456 static const TCHAR* GetRelativeFilePathFromMountPointer(const FString& Child, const FString& MountPoint)
1457 {
1458 if (!Child.StartsWith(MountPoint))
1459 {
1460 return nullptr;
1461 }
1462 const TCHAR* RelativePathFromMount = (*Child) + MountPoint.Len();
1463 if (RelativePathFromMount[0] == TEXT('\0'))
1464 {
1465 // Child is equal to MountPoint, invalid
1466 return nullptr;
1467 }
1468 return RelativePathFromMount;
1469 }
1470
1471 /* 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 */
1472 static PAKFILE_API bool IsPakKeepFullDirectory();
1473
1474 /* Returns the global,const flag for whether UnrealPak should write a copy of the full PathHashIndex and Pruned DirectoryIndex to the PakFile */
1476
1477 /* Returns the global,const flag for whether UnrealPak should write a copy of the full DirectoryIndex to the PakFile */
1479
1480private:
1481
1485 void Initialize(FArchive& Reader, bool bLoadIndex = true);
1486
1490 void LoadIndex(FArchive& Reader);
1491
1496
1498 struct FIndexSettings;
1499
1500 static FIndexSettings& GetIndexSettings();
1501
1507 static bool IsPakValidatePruning();
1513 static bool IsPakDelayPruning();
1514
1515#if ENABLE_PAKFILE_RUNTIME_PRUNING
1517 static bool bSomePakNeedsPruning;
1518#endif
1519
1524 PAKFILE_API bool RequiresDirectoryIndexLock() const;
1525
1529 PAKFILE_API bool ShouldValidatePrunedDirectory() const;
1530
1535 PAKFILE_API bool ShouldUseDirectoryTree() const;
1536
1550 static void AddEntryToIndex(const FString& Filename, const FPakEntryLocation& EntryLocation,
1551 const FString& MountPoint, uint64 PathHashSeed, FDirectoryIndex* DirectoryIndex,
1552 FDirectoryTreeIndex* DirectoryTreeIndex, FPathHashIndex* PathHashIndex,
1554
1555 /* Encodes a pak entry as an array of bytes into the given archive. Returns true if encoding succeeded. If encoding did not succeed, caller will need to store the InPakEntry in an unencoded list */
1556 static bool EncodePakEntry(FArchive& Ar, const FPakEntry& InPakEntry, const FPakInfo& InInfo);
1557
1558 /* Decodes a bit-encoded pak entry from a pointer to the start of its encoded bytes into the given OutEntry */
1559 static void DecodePakEntry(const uint8* SourcePtr, FPakEntry& OutEntry, const FPakInfo& InInfo);
1560
1561 /* Internal index loading function that returns false if index loading fails due to an intermittent IO error. Allows LoadIndex to retry or throw a fatal as required */
1562 bool LoadIndexInternal(FArchive& Reader, FDirectoryIndex& OutDirectoryTMap,
1564 FDirectoryTreeIndex& OutPrunedDirectoryTree, bool bStoreDirectoryTMap, bool bStoreDirectoryTree);
1565 void LoadIndexInternal_DirectoryIndex(FArchive& Ar, FDirectoryIndex& OutDirectoryTMap,
1566 FDirectoryTreeIndex& OutDirectoryTree, bool bLoadIntoDirectoryTMap, bool bLoadIntoDirectoryTree);
1567 // This is an internal function that should only be called by FPakFile or by PakFileUtilities.cpp; it can change without deprecation.
1568public:
1570private:
1571
1572 /* Legacy index loading function for PakFiles saved before FPakInfo::PakFile_Version_PathHashIndex */
1573 bool LoadLegacyIndex(FArchive& Reader, FDirectoryIndex& OutDirectoryTMap);
1574
1575 /* Helper function for LoadIndexInternal; each array of Index bytes read from the file needs to be independently decrypted and checked for corruption */
1576 bool DecryptAndValidateIndex(FArchive& Reader, TArray<uint8>& IndexData, FSHAHash& InExpectedHash, FSHAHash& OutActualHash);
1577
1578 /* Manually add a file to a pak file */
1579 void AddSpecialFile(const FPakEntry& Entry, const FString& Filename);
1580
1581 static void PruneDirectoryIndexInternal(FDirectoryIndex* InOutDirectoryIndex,
1582 FDirectoryTreeIndex* InOutDirectoryTreeIndex, FDirectoryIndex* PrunedDirectoryIndex,
1583 FDirectoryTreeIndex* PrunedDirectoryTreeIndex, const FString& MountPoint);
1584
1585 template <typename ShouldVisitFunc>
1586 struct FVisitFilter
1587 {
1589 const ShouldVisitFunc& ShouldVisit;
1590 bool bIncludeFiles = true;
1591 bool bIncludeDirectories = false;
1592 bool bRecursive = false;
1593 };
1594
1595 template <typename ShouldVisitFunc, class ContainerType>
1596 void FindPrunedFilesAtPathInternal(const TCHAR* InPath, ContainerType& OutFiles, const FVisitFilter<ShouldVisitFunc>& VisitFilter) const;
1597
1602 PAKFILE_API const FPakEntryLocation* FindLocationFromIndex(const FString& FullPath,
1603 const FDirectoryIndex& InDirectoryIndex, const FDirectoryTreeIndex& InDirectoryTreeIndex) const;
1604
1610 template <typename ShouldVisitFunc, class ContainerType>
1611 void FindFilesAtPathInIndex(const FDirectoryIndex& TargetIndex, const FDirectoryTreeIndex& TargetTreeIndex,
1612 ContainerType& OutFiles, const FString& FullSearchPath,
1614
1615#if ENABLE_PAKFILE_USE_DIRECTORY_TREE
1616 template <typename ShouldVisitFunc, class ContainerType>
1617 void FindFilesAtPathInTreeIndexInternal(FStringView RelSearchPath, const FDirectoryTreeIndex& TargetTreeIndex,
1618 ContainerType& OutFiles, TArray<FString>& OutDirectories,
1619 const FString& FullSearchPath, const FVisitFilter<ShouldVisitFunc>& VisitFilter) const;
1620
1621#if !UE_BUILD_SHIPPING
1622 template <class ContainerType>
1623 bool ValidateDirectoryTreeSearchConsistency(const ContainerType& FilesTree, const TArray<FString>& DirectoriesInPakTree, const ContainerType& FilesIndexed, const TArray<FString>& DirectoriesInPakIndexed) const;
1624#endif // UE_BUILD_SHIPPING
1625#endif // ENABLE_PAKFILE_USE_DIRECTORY_TREE
1626
1627 template <typename ShouldVisitFunc, class ContainerType>
1628 void FindFilesAtPathInIndexInternal(const FStringView& RelSearchPath, const FDirectoryIndex& TargetIndex,
1629 ContainerType& OutFiles, TArray<FString>& OutDirectories,
1630 const FString& FullSearchPath, const FVisitFilter<ShouldVisitFunc>& VisitFilter) const;
1631
1632 template <typename ShouldVisitFunc, class ContainerType>
1633 static void FindFilesAtPathInPakDirectoryInternal(const FString& MountPoint, FStringView RelPathInIndex,
1636
1638 PAKFILE_API bool NormalizeDirectoryQuery(const TCHAR* InPath, FString& OutRelativePathFromMount) const;
1639
1644 PAKFILE_API const FPakDirectory* FindPrunedDirectoryInternal(const FString& RelativePathFromMount) const;
1645 const FPakDirectory* FindPrunedDirectoryInIndexInternal(const FString& RelativePathFromMount,
1646 const FDirectoryIndex& InDirectoryIndex, const FDirectoryTreeIndex& InTreeIndex) const;
1647
1648#if ENABLE_PAKFILE_RUNTIME_PRUNING_VALIDATE
1649 /* Logs an error if the two sets are not identical after removing all config-specified ignore paths */
1650 PAKFILE_API void ValidateDirectorySearch(const TSet<FString>& FoundFullFiles, const TSet<FString>& PrunedFoundFiles, const TCHAR* InPath) const;
1651#endif
1652};
1653
1658{
1659public:
1660 enum
1661 {
1663 };
1664
1666 {
1667 return Size;
1668 }
1669
1670 static inline void DecryptBlock(void* Data, int64 Size, const FGuid& EncryptionKeyGuid)
1671 {
1672 // Nothing needs to be done here
1673 }
1674};
1675
1680
1681template< typename EncryptionPolicy = FPakNoEncryption >
1683{
1684public:
1693
1701
1702 inline int64 FileSize() const
1703 {
1704 return PakEntry.Size;
1705 }
1706
1708 {
1709 FGuid EncryptionKeyGuid = PakFile.GetInfo().EncryptionKeyGuid;
1710 const constexpr int64 Alignment = (int64)EncryptionPolicy::Alignment;
1711 const constexpr int64 AlignmentMask = ~(Alignment - 1);
1712 uint8 TempBuffer[Alignment];
1713 FSharedPakReader PakReader = AcquirePakReader();
1714 if (EncryptionPolicy::AlignReadRequest(DesiredPosition) != DesiredPosition)
1715 {
1717 int64 Offset = DesiredPosition - Start;
1718 int64 CopySize = FMath::Min(Alignment - Offset, Length);
1719 PakReader->Seek(OffsetToFile + Start);
1720 PakReader->Serialize(TempBuffer, Alignment);
1721 EncryptionPolicy::DecryptBlock(TempBuffer, Alignment, EncryptionKeyGuid);
1722 FMemory::Memcpy(V, TempBuffer + Offset, CopySize);
1723 V = (void*)((uint8*)V + CopySize);
1724 DesiredPosition += CopySize;
1725 Length -= CopySize;
1726 check(Length == 0 || DesiredPosition % Alignment == 0);
1727 }
1728 else
1729 {
1730 PakReader->Seek(OffsetToFile + DesiredPosition);
1731 }
1732
1733 int64 CopySize = Length & AlignmentMask;
1734 PakReader->Serialize(V, CopySize);
1735 EncryptionPolicy::DecryptBlock(V, CopySize, EncryptionKeyGuid);
1736 Length -= CopySize;
1737 V = (void*)((uint8*)V + CopySize);
1738
1739 if (Length > 0)
1740 {
1741 PakReader->Serialize(TempBuffer, Alignment);
1742 EncryptionPolicy::DecryptBlock(TempBuffer, Alignment, EncryptionKeyGuid);
1743 FMemory::Memcpy(V, TempBuffer, Length);
1744 }
1745 }
1746};
1747
1751template< typename ReaderPolicy = FPakReaderPolicy<> >
1753{
1755 int64 ReadPos;
1757 ReaderPolicy Reader;
1760
1761public:
1762
1777
1792
1800
1801 //~ Begin IFileHandle Interface
1802 virtual int64 Tell() override
1803 {
1804 return ReadPos;
1805 }
1806 virtual bool Seek(int64 NewPosition) override
1807 {
1808 if (NewPosition > Reader.FileSize() || NewPosition < 0)
1809 {
1810 return false;
1811 }
1812 ReadPos = NewPosition;
1813 return true;
1814 }
1816 {
1817 return Seek(Reader.FileSize() - NewPositionRelativeToEnd);
1818 }
1819 virtual bool Read(uint8* Destination, int64 BytesToRead) override
1820 {
1821 if (ReadInternal(Destination, BytesToRead, ReadPos))
1822 {
1823 ReadPos += BytesToRead;
1824 return true;
1825 }
1826 else
1827 {
1828 return false;
1829 }
1830 }
1831 virtual bool ReadAt(uint8* Destination, int64 BytesToRead, int64 Offset) override
1832 {
1833 if (BytesToRead < 0 || Offset < 0 || (BytesToRead + Offset) > Reader.FileSize())
1834 {
1835 return false;
1836 }
1837
1838 return ReadInternal(Destination, BytesToRead, Offset);
1839 }
1840 virtual bool Write(const uint8* Source, int64 BytesToWrite) override
1841 {
1842 // Writing in pak files is not allowed.
1843 return false;
1844 }
1845 virtual int64 Size() override
1846 {
1847 return Reader.FileSize();
1848 }
1849 virtual bool Flush(const bool bFullFlush = false) override
1850 {
1851 // pak files are read only, so don't need to support flushing
1852 return false;
1853 }
1854 virtual bool Truncate(int64 NewSize) override
1855 {
1856 // pak files are read only, so don't need to support truncation
1857 return false;
1858 }
1860private:
1861 bool ReadInternal(uint8* Destination, int64 BytesToRead, int64 Offset)
1862 {
1864
1865 if (!Reader.PakEntry.Verified)
1866 {
1868 FSharedPakReader PakReader = Reader.AcquirePakReader();
1869 PakReader->Seek(Reader.PakEntry.Offset);
1870 FileHeader.Serialize(PakReader.GetArchive(), Reader.PakFile.GetInfo().Version);
1871 if (FPakEntry::VerifyPakEntriesMatch(Reader.PakEntry, FileHeader))
1872 {
1873 Reader.PakEntry.Verified = true;
1874 }
1875 else
1876 {
1877 return false;
1878 }
1879 }
1880
1881 if (Reader.FileSize() >= (Offset + BytesToRead))
1882 {
1883 Reader.Serialize(Offset, Destination, BytesToRead);
1884 return true;
1885 }
1886 else
1887 {
1888 return false;
1889 }
1890 }
1891};
1892
1897{
1898 // Pak filename
1899 const TCHAR* PakFilename = nullptr;
1900 // Search order
1902 // Path to mount the pak at
1903 const TCHAR* Path = nullptr;
1904 // Mount options
1906 // Flag to load Index
1907 bool bLoadIndex = true;
1908};
1909
1914{
1915 struct FPakListEntry
1916 {
1917 FPakListEntry()
1918 : ReadOrder(0)
1919 , PakFile(nullptr)
1920 {}
1921
1922 uint32 ReadOrder;
1924
1925 inline bool operator < (const FPakListEntry& RHS) const
1926 {
1927 return ReadOrder > RHS.ReadOrder;
1928 }
1929 };
1930
1931 template<bool bInAllowDuplicateKeys>
1933
1934 struct FPakListDeferredEntry
1935 {
1936 FString Filename;
1937 FString Path;
1938 uint32 ReadOrder;
1939 FGuid EncryptionKeyGuid;
1940 int32 PakchunkIndex;
1941 };
1942
1944 IPlatformFile* LowerLevel;
1946 TArray<FPakListEntry> PakFiles;
1948 TArray<FPakListDeferredEntry> PendingEncryptedPakFiles;
1950 bool bSigned;
1952 mutable FTransactionallySafeCriticalSection PakListCritical;
1954 TSet<FName> ExcludedNonPakExtensions;
1956 FString IniFileExtension;
1958 FString GameUserSettingsIniFilename;
1960 TSharedPtr<FFilePackageStoreBackend> PackageStoreBackend;
1961
1962 FTSTicker::FDelegateHandle RetireReadersHandle;
1963
1964#if !UE_BUILD_SHIPPING
1965 // if true (via -looklocalfirst) then loose/non-ufs files will be looked for before looking in the .pak file
1966 // this respects IsNonPakFilenameAllowed()
1967 bool bLookLooseFirst = false;
1968#endif
1969
1973 inline void GetMountedPaks(TArray<FPakListEntry>& Paks)
1974 {
1975 UE::TScopeLock ScopedLock(PakListCritical);
1976 Paks.Append(PakFiles);
1977 }
1978
1985 PAKFILE_API bool DirectoryExistsInPrunedPakFiles(const TCHAR* Directory);
1986
1997 PAKFILE_API bool BufferedCopyFile(IFileHandle& Dest, IFileHandle& Source, const int64 FileSize, uint8* Buffer, const int64 BufferSize) const;
1998
2007 PAKFILE_API IFileHandle* CreatePakFileHandle(const TCHAR* Filename, const TRefCountPtr<FPakFile>& PakFile, const FPakEntry* FileEntry);
2008
2013 PAKFILE_API static int32 GetPakOrderFromPakFilePath(const FStringView PakFilePath);
2014
2018 PAKFILE_API IPakFile* HandleMountPakDelegate(const FString& PakFilePath, int32 PakOrder);
2019
2024
2028 PAKFILE_API bool HandleUnmountPakDelegate(const FString& PakFilePath);
2029
2036 PAKFILE_API static void FindPakFilesInDirectory(IPlatformFile* LowLevelFile, const TCHAR* Directory, const FString& WildCard, TArray<FString>& OutPakFiles);
2037
2043 PAKFILE_API static void FindAllPakFiles(IPlatformFile* LowLevelFile, const TArray<FString>& PakFolders, const FString& WildCard, TArray<FString>& OutPakFiles);
2044
2051 PAKFILE_API bool IsNonPakFilenameAllowed(const FString& InFilename);
2052
2059 PAKFILE_API void RegisterEncryptionKey(const FGuid& InEncryptionKeyGuid, const FAES::FAESKey& InKey);
2060
2067 PAKFILE_API static bool IsPakFileInstalled(const FString& InFilename);
2068
2069public:
2070
2072
2073 //~ For visibility of overloads we don't override
2078
2082 static const TCHAR* GetTypeName()
2083 {
2084 return TEXT("PakFile");
2085 }
2086
2091
2095 PAKFILE_API static void SetMountStartupPaksWildCard(const FString& WildCard);
2096
2101
2105 PAKFILE_API bool AnyChunksAvailable() const;
2106
2111 {
2112 UE::TScopeLock ScopedLock(PakListCritical);
2113 PakFilenames.Empty(PakFiles.Num());
2114 for (FPakListEntry& Entry : PakFiles)
2115 {
2116 PakFilenames.Add(Entry.PakFile->GetFilename());
2117 }
2118 }
2119
2124 {
2125 UE::TScopeLock ScopedLock(PakListCritical);
2126 PakFilenames.Empty(PakFiles.Num());
2127 for (FPakListEntry& Entry : PakFiles)
2128 {
2129 PakFilenames.Add(Entry.PakFile->GetFilename());
2130 }
2131 }
2132
2137 {
2138 UE::TScopeLock ScopedLock(PakListCritical);
2139 OutChunkIds.Empty(PakFiles.Num());
2140 for (FPakListEntry& Entry : PakFiles)
2141 {
2142 OutChunkIds.Add(Entry.PakFile->PakGetPakchunkIndex());
2143 }
2144 }
2145
2150
2154 PAKFILE_API static void GetPakFolders(const TCHAR* CmdLine, TArray<FString>& OutPakFolders);
2155
2160
2167
2172
2179
2184
2185 PAKFILE_API virtual bool ShouldBeUsed(IPlatformFile* Inner, const TCHAR* CmdLine) const override;
2186 PAKFILE_API virtual bool Initialize(IPlatformFile* Inner, const TCHAR* CommandLineParam) override;
2187 PAKFILE_API virtual void InitializeNewAsyncIO() override;
2188
2190
2191 virtual IPlatformFile* GetLowerLevel() override
2192 {
2193 return LowerLevel;
2194 }
2196 {
2197 LowerLevel = NewLowerLevel;
2198 }
2199
2200 virtual const TCHAR* GetName() const override
2201 {
2203 }
2204
2205 PAKFILE_API void Tick() override;
2206
2217 PAKFILE_API bool Mount(const TCHAR* InPakFilename, uint32 PakOrder, const TCHAR* InPath = nullptr, bool bLoadIndex = true, FPakListEntry* OutPakListEntry = nullptr);
2218
2228 PAKFILE_API bool Mount(const FPakMountArgs& MountArgs, FIoStatus* OutIoMountStatus = nullptr, FPakListEntry* OutPakListEntry = nullptr);
2229
2231
2233 PAKFILE_API int32 MountAllPakFiles(const TArray<FString>& PakFolders, const FString& WildCard);
2234
2239
2244
2253 PAKFILE_API static bool FindFileInPakFiles(TArray<FPakListEntry>& Paks, const TCHAR* Filename,
2255
2263 PAKFILE_API bool FindFileInPakFiles(const TCHAR* Filename, TRefCountPtr<FPakFile>* OutPakFile = nullptr,
2264 FPakEntry* OutEntry = nullptr);
2265
2266 //~ Begin IPlatformFile Interface
2267 virtual bool FileExists(const TCHAR* Filename) override
2268 {
2269 // Check pak files first.
2270 if (FindFileInPakFiles(Filename))
2271 {
2272 return true;
2273 }
2274 // File has not been found in any of the pak files, continue looking in inner platform file.
2275 bool Result = false;
2276 if (IsNonPakFilenameAllowed(Filename))
2277 {
2278 Result = LowerLevel->FileExists(Filename);
2279 }
2280 return Result;
2281 }
2282
2283 virtual int64 FileSize(const TCHAR* Filename) override
2284 {
2285 // Check pak files first
2286 FPakEntry FileEntry;
2287 if (FindFileInPakFiles(Filename, nullptr, &FileEntry))
2288 {
2289 return FileEntry.CompressionMethodIndex != 0 ? FileEntry.UncompressedSize : FileEntry.Size;
2290 }
2291 // First look for the file in the user dir.
2292 int64 Result = INDEX_NONE;
2293 if (IsNonPakFilenameAllowed(Filename))
2294 {
2295 Result = LowerLevel->FileSize(Filename);
2296 }
2297 return Result;
2298 }
2299
2300 virtual bool DeleteFile(const TCHAR* Filename) override
2301 {
2302 // If file exists in pak file it will never get deleted.
2303 if (FindFileInPakFiles(Filename))
2304 {
2305 return false;
2306 }
2307 // The file does not exist in pak files, try LowerLevel->
2308 bool Result = false;
2309 if (IsNonPakFilenameAllowed(Filename))
2310 {
2311 Result = LowerLevel->DeleteFile(Filename);
2312 }
2313 return Result;
2314 }
2315
2316 virtual bool IsReadOnly(const TCHAR* Filename) override
2317 {
2318 // Files in pak file are always read-only.
2319 if (FindFileInPakFiles(Filename))
2320 {
2321 return true;
2322 }
2323 // The file does not exist in pak files, try LowerLevel->
2324 bool Result = false;
2325 if (IsNonPakFilenameAllowed(Filename))
2326 {
2327 Result = LowerLevel->IsReadOnly(Filename);
2328 }
2329 return Result;
2330 }
2331
2332 virtual bool MoveFile(const TCHAR* To, const TCHAR* From) override
2333 {
2334 // Files which exist in pak files can't be moved
2335 if (FindFileInPakFiles(From))
2336 {
2337 return false;
2338 }
2339 // Files not in pak are allowed to be moved.
2340 bool Result = false;
2341 if (IsNonPakFilenameAllowed(From))
2342 {
2343 Result = LowerLevel->MoveFile(To, From);
2344 }
2345 return Result;
2346 }
2347
2348 virtual bool SetReadOnly(const TCHAR* Filename, bool bNewReadOnlyValue) override
2349 {
2350 // Files in pak file will never change their read-only flag.
2351 if (FindFileInPakFiles(Filename))
2352 {
2353 // This fails if soemone wants to make files from pak writable.
2354 return bNewReadOnlyValue;
2355 }
2356 // Try lower level
2357 bool Result = bNewReadOnlyValue;
2358 if (IsNonPakFilenameAllowed(Filename))
2359 {
2360 Result = LowerLevel->SetReadOnly(Filename, bNewReadOnlyValue);
2361 }
2362 return Result;
2363 }
2364
2365 virtual FDateTime GetTimeStamp(const TCHAR* Filename) override
2366 {
2367 // Check pak files first.
2369 if (FindFileInPakFiles(Filename, &PakFile))
2370 {
2371 return PakFile->GetTimestamp();
2372 }
2373 // Fall back to lower level.
2374 FDateTime Result = FDateTime::MinValue();
2375 if (IsNonPakFilenameAllowed(Filename))
2376 {
2377 double StartTime = (UE_LOG_ACTIVE(LogPakFile, Verbose)) ? FPlatformTime::Seconds() : 0.0;
2378 Result = LowerLevel->GetTimeStamp(Filename);
2379 UE_LOG(LogPakFile, Verbose, TEXT("GetTimeStamp on disk (!!) for %s took %6.2fms."), Filename, float(FPlatformTime::Seconds() - StartTime) * 1000.0f);
2380 }
2381 return Result;
2382 }
2383
2385 {
2390
2391 // If either file exists, we'll assume both should exist here and therefore we can skip the
2392 // request to the lower level platform file.
2393 if (PakFileA != nullptr || PakFileB != nullptr)
2394 {
2395 OutTimeStampA = PakFileA != nullptr ? PakFileA->GetTimestamp() : FDateTime::MinValue();
2396 OutTimeStampB = PakFileB != nullptr ? PakFileB->GetTimestamp() : FDateTime::MinValue();
2397 }
2398 else
2399 {
2400 // Fall back to lower level.
2401 if (IsNonPakFilenameAllowed(FilenameA) && IsNonPakFilenameAllowed(FilenameB))
2402 {
2404 }
2405 else
2406 {
2409 }
2410 }
2411 }
2412
2413 virtual void SetTimeStamp(const TCHAR* Filename, FDateTime DateTime) override
2414 {
2415 // No modifications allowed on files from pak (although we could theoretically allow this one).
2416 if (!FindFileInPakFiles(Filename))
2417 {
2418 if (IsNonPakFilenameAllowed(Filename))
2419 {
2420 LowerLevel->SetTimeStamp(Filename, DateTime);
2421 }
2422 }
2423 }
2424
2425 virtual FDateTime GetAccessTimeStamp(const TCHAR* Filename) override
2426 {
2427 // AccessTimestamp not yet supported in pak files (although it is possible).
2429 if (FindFileInPakFiles(Filename, &PakFile))
2430 {
2431 return PakFile->GetTimestamp();
2432 }
2433 // Fall back to lower level.
2434 FDateTime Result = false;
2435 if (IsNonPakFilenameAllowed(Filename))
2436 {
2437 Result = LowerLevel->GetAccessTimeStamp(Filename);
2438 }
2439 return Result;
2440 }
2441
2442 virtual FString GetFilenameOnDisk(const TCHAR* Filename) override
2443 {
2444 FPakEntry FileEntry;
2446 if (FindFileInPakFiles(Filename, &PakFile, &FileEntry))
2447 {
2448 const FString Path(FPaths::GetPath(Filename));
2450
2451 const FPakDirectory* PakDirectory = PakFile->FindPrunedDirectory(*Path);
2452 if (PakDirectory != nullptr)
2453 {
2454 for (FPakDirectory::TConstIterator FileIt(*PakDirectory); FileIt; ++FileIt)
2455 {
2456 FPakEntry PakEntry;
2457 if (PakFile->GetPakEntry(FileIt.Value(), &PakEntry) != FPakFile::EFindResult::NotFound && PakEntry.Offset == FileEntry.Offset)
2458 {
2459 const FUtf8String& RealFilename = FileIt.Key();
2460 return Path / FString(RealFilename);
2461 }
2462 }
2463 }
2464
2465#if ENABLE_PAKFILE_RUNTIME_PRUNING_VALIDATE
2466 // The File exists in the Pak but has been pruned from its DirectoryIndex; log an error if we are validating pruning and return the original Filename.
2467 if (PakFile->ShouldValidatePrunedDirectory())
2468 {
2471 FullFoundFiles.Add(Filename);
2472 PakFile->ValidateDirectorySearch(FullFoundFiles, PrunedFoundFiles, Filename);
2473 }
2474#endif
2475
2476 return Filename;
2477 }
2478
2479 // Fall back to lower level.
2480 if (IsNonPakFilenameAllowed(Filename))
2481 {
2482 return LowerLevel->GetFilenameOnDisk(Filename);
2483 }
2484 else
2485 {
2486 return Filename;
2487 }
2488 }
2489
2490 virtual ESymlinkResult IsSymlink(const TCHAR* Filename) override
2491 {
2492 return LowerLevel->IsSymlink(Filename);
2493 }
2494
2495 PAKFILE_API virtual IFileHandle* OpenRead(const TCHAR* Filename, bool bAllowWrite = false) override;
2496 PAKFILE_API virtual IFileHandle* OpenWrite(const TCHAR* Filename, bool bAppend = false,
2497 bool bAllowRead = false) override;
2498
2499 PAKFILE_API virtual bool DirectoryExists(const TCHAR* Directory) override;
2500 PAKFILE_API virtual bool CreateDirectory(const TCHAR* Directory) override;
2501 PAKFILE_API virtual bool DeleteDirectory(const TCHAR* Directory) override;
2503 PAKFILE_API virtual bool IterateDirectory(const TCHAR* Directory,
2504 IPlatformFile::FDirectoryVisitor& Visitor) override;
2505 PAKFILE_API virtual bool IterateDirectoryRecursively(const TCHAR* Directory,
2506 IPlatformFile::FDirectoryVisitor& Visitor) override;
2507 PAKFILE_API virtual bool IterateDirectoryStat(const TCHAR* Directory,
2508 IPlatformFile::FDirectoryStatVisitor& Visitor) override;
2509 PAKFILE_API virtual bool IterateDirectoryStatRecursively(const TCHAR* Directory,
2510 IPlatformFile::FDirectoryStatVisitor& Visitor) override;
2511 PAKFILE_API virtual void FindFiles(TArray<FString>& FoundFiles,
2512 const TCHAR* Directory, const TCHAR* FileExtension) override;
2513 PAKFILE_API virtual void FindFilesRecursively(TArray<FString>& FoundFiles,
2514 const TCHAR* Directory, const TCHAR* FileExtension) override;
2515 PAKFILE_API virtual bool DeleteDirectoryRecursively(const TCHAR* Directory) override;
2516 PAKFILE_API virtual bool CreateDirectoryTree(const TCHAR* Directory) override;
2517
2519
2520 PAKFILE_API virtual IAsyncReadFileHandle* OpenAsyncRead(const TCHAR* Filename, bool bAllowWrite = false) override;
2522
2523 virtual FOpenMappedResult OpenMappedEx(const TCHAR* Filename, EOpenReadFlags OpenOptions = EOpenReadFlags::None, int64 MaximumSize = 0) override;
2531 FString ConvertToPakRelativePath(const TCHAR* Filename, const FPakFile* Pak)
2532 {
2533 FString RelativeFilename(Filename);
2534 return RelativeFilename.Mid(Pak->GetMountPoint().Len());
2535 }
2536
2537 FString ConvertToAbsolutePathForExternalAppForRead(const TCHAR* Filename) override
2538 {
2539 // Check in Pak file first
2541 if (FindFileInPakFiles(Filename, &Pak))
2542 {
2543 return FString::Printf(TEXT("Pak: %s/%s"), *Pak->GetFilename(), *ConvertToPakRelativePath(Filename, Pak));
2544 }
2545 else
2546 {
2547 return LowerLevel->ConvertToAbsolutePathForExternalAppForRead(Filename);
2548 }
2549 }
2550
2551 FString ConvertToAbsolutePathForExternalAppForWrite(const TCHAR* Filename) override
2552 {
2553 // Check in Pak file first
2555 if (FindFileInPakFiles(Filename, &Pak))
2556 {
2557 return FString::Printf(TEXT("Pak: %s/%s"), *Pak->GetFilename(), *ConvertToPakRelativePath(Filename, Pak));
2558 }
2559 else
2560 {
2561 return LowerLevel->ConvertToAbsolutePathForExternalAppForWrite(Filename);
2562 }
2563 }
2564 //~ End IPlatformFile Interface
2565
2571
2572 // Access static delegate for loose file security
2574
2575 // Access static delegate for custom encryption
2577
2595
2596 // Access static delegate for handling a Pak signature check failure
2598
2599 // Broadcast a signature check failure through any registered delegates in a thread safe way
2601
2602 // Broadcast a principal signature table failure through any registered delegates in a thread safe way
2604
2607
2608 // Access static delegate for setting PakIndex settings.
2610
2611 /* Get a list of RelativePathFromMount for every file in the given Pak that lives in any of the given chunks. Only searches the Pruned DirectoryIndex */
2613
2616
2619
2622
2625
2627
2628 // BEGIN Console commands
2629#if !UE_BUILD_SHIPPING
2631 PAKFILE_API void HandleMountCommand(const TCHAR* Cmd, FOutputDevice& Ar);
2635#endif
2636 // END Console commands
2637
2638#if PAK_TRACKER
2640 PAKFILE_API static void TrackPak(const TCHAR* Filename, const FPakEntry* PakEntry);
2641 static TMap<FString, int32>& GetPakMap() { return GPakSizeMap; }
2642#endif
2643
2644 // Internal cache of pak signature files
2647
2648private:
2649 bool IterateDirectoryInternal(const TCHAR* Directory, IPlatformFile::FDirectoryVisitor& Visitor, bool bRecursive);
2650 bool IterateDirectoryInPakFiles(const TCHAR* Directory,
2653 bool IterateDirectoryStatInternal(const TCHAR* Directory,
2654 IPlatformFile::FDirectoryStatVisitor& Visitor, bool bRecursive);
2655 void FindFilesInternal(TArray<FString>& FoundFiles,
2656 const TCHAR* Directory, const TCHAR* FileExtension, bool bRecursive);
2657};
2658
2663{
2664 // Magic number that tells us we're dealing with the new format sig files
2665 static const uint32 Magic = 0x73832DAA;
2666
2667 enum class EVersion
2668 {
2669 Invalid,
2670 First,
2671
2672 Last,
2673 Latest = Last - 1
2674 };
2675
2676 // Sig file version. Set to Legacy if the sig file is of an old version
2677 EVersion Version = EVersion::Latest;
2678
2679 // RSA encrypted hash
2681
2682 // SHA1 hash of the chunk CRC data. Only valid after calling DecryptSignatureAndValidate
2684
2685 // The actual array of data that was encrypted in the RSA block. Contains the chunk table hash and also other custom data related to the pak file
2687
2688 // CRCs of each contiguous 64kb block of the pak file
2690
2695 {
2696 ChunkHashes = InChunkHashes;
2697 SignatureData = InSignatureData;
2698 DecryptedHash = ComputeCurrentPrincipalHash();
2699
2701 NewSignatureData.Append(SignatureData);
2702 NewSignatureData.Append(DecryptedHash.Hash, UE_ARRAY_COUNT(FSHAHash::Hash));
2704 }
2705
2710 {
2711 uint32 FileMagic = Magic;
2712 Ar << FileMagic;
2713
2714 if (Ar.IsLoading() && FileMagic != Magic)
2715 {
2716 Version = EVersion::Invalid;
2717 EncryptedHash.Empty();
2718 ChunkHashes.Empty();
2719 return;
2720 }
2721
2722 Ar << Version;
2723 Ar << EncryptedHash;
2724 Ar << ChunkHashes;
2725 }
2726
2731 {
2732 if (Version == EVersion::Invalid)
2733 {
2734 UE_LOG(LogPakFile, Warning, TEXT("Pak signature file for '%s' was invalid"), *InFilename);
2735 }
2736 else
2737 {
2738 int32 BytesDecrypted = FRSA::DecryptPublic(EncryptedHash, SignatureData, InKey);
2740 {
2741 FMemory::Memcpy(DecryptedHash.Hash, SignatureData.GetData() + SignatureData.Num() - UE_ARRAY_COUNT(FSHAHash::Hash), UE_ARRAY_COUNT(FSHAHash::Hash));
2742 SignatureData.SetNum(SignatureData.Num() - UE_ARRAY_COUNT(FSHAHash::Hash));
2743 FSHAHash CurrentHash = ComputeCurrentPrincipalHash();
2744 if (DecryptedHash == CurrentHash)
2745 {
2746 return true;
2747 }
2748 else
2749 {
2750 UE_LOG(LogPakFile, Warning, TEXT("Pak signature table validation failed for '%s'! Expected %s, Received %s"), *InFilename, *DecryptedHash.ToString(), *CurrentHash.ToString());
2751 }
2752 }
2753 else
2754 {
2755 UE_LOG(LogPakFile, Warning, TEXT("Pak signature table validation failed for '%s'! Failed to decrypt signature"), *InFilename);
2756 }
2757 }
2758
2760 return false;
2761 }
2762
2767 {
2769 FSHA1::HashBuffer(ChunkHashes.GetData(), ChunkHashes.Num() * sizeof(TPakChunkHash), CurrentHash.Hash);
2770 return CurrentHash;
2771 }
2772
2773 UE_DEPRECATED("5.1", "Use ComputeCurrentPrincipalHash instead")
2774 FSHAHash ComputeCurrentMasterHash() const
2775 {
2776 return ComputeCurrentPrincipalHash();
2777 }
2778};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define NULL
Definition oodle2base.h:134
#define CDECL
Definition AndroidPlatform.h:135
#define check(expr)
Definition AssertionMacros.h:314
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
@ COMPRESS_None
Definition CompressionFlags.h:15
@ COMPRESS_Custom_DEPRECATED
Definition CompressionFlags.h:22
@ COMPRESS_GZIP_DEPRECATED
Definition CompressionFlags.h:20
@ COMPRESS_ZLIB_DEPRECATED
Definition CompressionFlags.h:18
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TYPE_OF_NULLPTR TYPE_OF_NULLPTR
The type of the C++ nullptr keyword.
Definition Platform.h:1157
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::ANSICHAR ANSICHAR
An ANSI character. Normally a signed type.
Definition Platform.h:1131
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
#define INC_DWORD_STAT(StatId)
Definition Stats.h:696
#define DEC_DWORD_STAT(StatId)
Definition Stats.h:701
#define DECLARE_DWORD_ACCUMULATOR_STAT_EXTERN(CounterName, StatId, GroupId, API)
Definition Stats.h:684
#define SCOPE_SECONDS_ACCUMULATOR(Stat)
Definition Stats.h:663
#define DECLARE_FLOAT_ACCUMULATOR_STAT_EXTERN(CounterName, StatId, GroupId, API)
Definition Stats.h:683
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
#define DECLARE_DELEGATE_RetVal_OneParam(ReturnValueType, DelegateName, Param1Type)
Definition DelegateCombinations.h:54
#define DECLARE_DELEGATE_ThreeParams(DelegateName, Param1Type, Param2Type, Param3Type)
Definition DelegateCombinations.h:66
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
return true
Definition ExternalRpcRegistry.cpp:601
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
ESymlinkResult
Definition GenericPlatformFile.h:90
EPlatformFileRead
Definition GenericPlatformFile.h:59
EPlatformFileWrite
Definition GenericPlatformFile.h:70
EAsyncIOPriorityAndFlags
Definition GenericPlatformFile.h:31
const TCHAR * LexToString(EAnalyticsRecordEventMode Mode)
Definition IAnalyticsProvider.cpp:5
void * FRSAKeyHandle
Definition IEngineCrypto.h:9
FArchive & operator<<(FArchive &Ar, FPakCompressedBlock &Block)
Definition IPlatformFilePak.h:376
PAKFILE_API TPakChunkHash ComputePakChunkHash(const void *InData, int64 InDataSizeInBytes)
Definition IPlatformFilePak.cpp:230
uint32 TPakChunkHash
Definition IPlatformFilePak.h:93
TFunction< FSharedPakReader()> TAcquirePakReaderFunction
Definition IPlatformFilePak.h:1679
FString ChunkHashToString(const TPakChunkHash &InHash)
Definition IPlatformFilePak.h:99
TMap< FUtf8String, FPakEntryLocation > FPakDirectory
Definition IPlatformFilePak.h:727
FPakPrincipalSignatureTableCheckFailureHandler FPakMasterSignatureTableCheckFailureHandler
Definition IPlatformFilePak.h:133
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
#define UE_LOG_ACTIVE(CategoryName, Verbosity)
Definition LogMacros.h:255
#define UE_LOG(CategoryName, Verbosity, Format,...)
Definition LogMacros.h:270
const bool
Definition NetworkReplayStreaming.h:178
#define MAX_int32
Definition NumericLimits.h:25
#define MIN_int32
Definition NumericLimits.h:16
#define TCHAR_TO_ANSI(str)
Definition StringConv.h:1019
::FCriticalSection FTransactionallySafeCriticalSection
Definition TransactionallySafeCriticalSection.h:16
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
uint32 Offset
Definition VulkanMemory.cpp:4033
uint32 Size
Definition VulkanMemory.cpp:4034
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
virtual void Serialize(void *V, int64 Length)
Definition Archive.h:1689
UE_FORCEINLINE_HINT bool IsLoading() const
Definition Archive.h:236
virtual int64 Tell()
Definition Archive.h:149
virtual int64 TotalSize()
Definition Archive.h:155
UE_FORCEINLINE_HINT bool IsSaving() const
Definition Archive.h:248
virtual void Seek(int64 InPos)
Definition Archive.h:1753
Definition SignedArchiveReader.h:103
Definition IoDispatcherFileBackend.h:109
Definition FilePackageStore.h:89
Definition IoStatus.h:60
Definition NameTypes.h:617
CORE_API FString ToString() const
Definition UnrealNames.cpp:3537
Definition UnrealTemplate.h:321
Definition UnrealType.h:3087
Definition OutputDevice.h:133
Definition IPlatformFilePak.h:1753
virtual int64 Size() override
Definition IPlatformFilePak.h:1845
virtual bool Truncate(int64 NewSize) override
Definition IPlatformFilePak.h:1854
virtual bool ReadAt(uint8 *Destination, int64 BytesToRead, int64 Offset) override
Definition IPlatformFilePak.h:1831
FPakFileHandle(const TRefCountPtr< const FPakFile > &InPakFile, const FPakEntry &InPakEntry, FArchive *InPakReader)
Definition IPlatformFilePak.h:1785
virtual int64 Tell() override
Definition IPlatformFilePak.h:1802
virtual bool SeekFromEnd(int64 NewPositionRelativeToEnd) override
Definition IPlatformFilePak.h:1815
virtual bool Flush(const bool bFullFlush=false) override
Definition IPlatformFilePak.h:1849
virtual bool Write(const uint8 *Source, int64 BytesToWrite) override
Definition IPlatformFilePak.h:1840
virtual bool Seek(int64 NewPosition) override
Definition IPlatformFilePak.h:1806
virtual ~FPakFileHandle()
Definition IPlatformFilePak.h:1796
FPakFileHandle(const TRefCountPtr< const FPakFile > &InPakFile, const FPakEntry &InPakEntry, TAcquirePakReaderFunction &InAcquirePakReaderFunction)
Definition IPlatformFilePak.h:1770
virtual bool Read(uint8 *Destination, int64 BytesToRead) override
Definition IPlatformFilePak.h:1819
Definition IPlatformFilePak.h:1162
FBaseIterator & operator=(FBaseIterator &&)=default
PAKFILE_API FPakEntryLocation GetPakEntryIndex() const
Definition PakFile.cpp:2596
PAKFILE_API ~FBaseIterator()
FBaseIterator(const FBaseIterator &)=delete
PAKFILE_API const FPakEntry & Info() const
Definition PakFile.cpp:2515
PAKFILE_API bool operator!() const
Definition PakFile.cpp:2510
FBaseIterator & operator=(const FBaseIterator &)=delete
FBaseIterator(FBaseIterator &&)=default
PAKFILE_API FBaseIterator & operator++()
Definition PakFile.cpp:2469
PAKFILE_API bool HasFilename() const
Definition PakFile.cpp:2521
PAKFILE_API const FString & Filename() const
Definition PakFile.cpp:2579
Definition IPlatformFilePak.h:1281
FFilenameIterator(const FPakFile &InPakFile, bool bInIncludeDeleted=false)
Definition IPlatformFilePak.h:1288
Definition IPlatformFilePak.h:1259
const FString * TryGetFilename() const
Definition IPlatformFilePak.h:1266
FPakEntryIterator(const FPakFile &InPakFile, bool bInIncludeDeleted=false)
Definition IPlatformFilePak.h:1261
Definition IPlatformFilePak.h:752
static PAKFILE_API void SaveIndexInternal_DirectoryIndex(FArchive &Ar, const FDirectoryIndex &DirectoryTMap)
Definition PakFile.cpp:764
const FString & GetFilename() const
Definition IPlatformFilePak.h:1005
PAKFILE_API void ReleaseOldReaders(double MaxAgeSeconds)
Definition PakFile.cpp:2261
const FDateTime & GetTimestamp() const
Definition IPlatformFilePak.h:1311
PAKFILE_API void ReturnSharedReader(FArchive *SharedReader)
Definition PakFile.cpp:2254
PAKFILE_API void GetPrunedFilenames(TArray< FString > &OutFileList) const
Definition PakFile.cpp:2050
TMap< uint64, FPakEntryLocation > FPathHashIndex
Definition IPlatformFilePak.h:755
ECacheType
Definition IPlatformFilePak.h:761
void SetIsMounted(bool bInIsMounted)
Definition IPlatformFilePak.h:946
void SetCacheType(ECacheType InCacheType)
Definition IPlatformFilePak.h:942
static PAKFILE_API void PruneDirectoryIndex(FDirectoryIndex &InOutDirectoryIndex, FDirectoryIndex *PrunedDirectoryIndex, const FString &MountPoint)
Definition PakFile.cpp:977
PAKFILE_API void GetPrunedFilenamesInChunk(const TArray< int32 > &InChunkIDs, TArray< FString > &OutFileList) const
Definition PakFile.cpp:2058
virtual int32 PakGetPakchunkIndex() const override
Definition IPlatformFilePak.h:920
ECacheType GetCacheType(void)
Definition IPlatformFilePak.h:943
virtual const FString & PakGetPakFilename() const override
Definition IPlatformFilePak.h:910
TMap< FString, FPakDirectory > FDirectoryIndex
Definition IPlatformFilePak.h:757
static bool SplitPathInline(FStringView &InOutPath, FStringView &OutFilename)
Definition PakFile.cpp:1329
const FString & GetMountPoint() const
Definition IPlatformFilePak.h:1077
PAKFILE_API bool PassedSignatureChecks() const
Definition PakFile.cpp:201
void ReadHashFromPayload(const FPakEntry &PakEntry, uint8 *OutBuffer)
Definition IPlatformFilePak.h:1334
int64 TotalSize() const
Definition IPlatformFilePak.h:1014
static PAKFILE_API bool IsPakWritePathHashIndex()
Definition PakFile.cpp:1459
static PAKFILE_API bool IsPakWriteFullDirectoryIndex()
Definition PakFile.cpp:1465
bool GetUnderlyingCacheTrimDisabled(void)
Definition IPlatformFilePak.h:940
bool DirectoryExistsInPruned(const TCHAR *InPath) const
Definition IPlatformFilePak.h:1134
void FindPrunedFilesAtPath(ContainerType &OutFiles, const TCHAR *InPath, bool bIncludeFiles=true, bool bIncludeDirectories=false, bool bRecursive=false) const
Definition IPlatformFilePak.h:1084
static bool SplitPathInline(FString &InOutPath, FString &OutFilename)
Definition IPlatformFilePak.h:1422
virtual const FString & PakGetMountPoint() const override
Definition IPlatformFilePak.h:933
bool IsValid() const
Definition IPlatformFilePak.h:988
PAKFILE_API FSharedPakReader GetSharedReader(IPlatformFile *LowerLevel)
Definition PakFile.cpp:2227
bool GetIsMounted() const
Definition IPlatformFilePak.h:947
EIteratorType
Definition IPlatformFilePak.h:1155
bool HasFilenames() const
Definition IPlatformFilePak.h:1321
virtual void PakVisitPrunedFilenames(IPlatformFile::FDirectoryVisitor &Visitor) const override
Definition IPlatformFilePak.h:925
static bool IsPathInDirectoryFormat(const FString &Path)
Definition IPlatformFilePak.h:1410
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)
Definition PakFile.cpp:921
static const TCHAR * GetRelativeFilePathFromMountPointer(const FString &Child, const FString &MountPoint)
Definition IPlatformFilePak.h:1456
static void MakeDirectoryFromPath(FString &Path)
Definition IPlatformFilePak.h:1402
PAKFILE_API bool RecreatePakReaders(IPlatformFile *LowerLevel)
Definition PakFile.cpp:2195
void SetCacheIndex(int32 InCacheIndex)
Definition IPlatformFilePak.h:944
int32 GetCacheIndex(void)
Definition IPlatformFilePak.h:945
static PAKFILE_API EFindResult GetPakEntry(const FPakEntryLocation &FPakEntryLocation, FPakEntry *OutEntry, const TArray< uint8 > &EncodedPakEntries, const TArray< FPakEntry > &Files, const FPakInfo &Info)
Definition PakFile.cpp:1384
static PAKFILE_API const FPakEntryLocation * FindLocationFromIndex(const FString &FullPath, const FString &MountPoint, const FPathHashIndex &PathHashIndex, uint64 PathHashSeed, int32 PakFileVersion)
Definition PakFile.cpp:2288
EFindResult
Definition IPlatformFilePak.h:1054
const FPakDirectory * FindPrunedDirectory(const TCHAR *InPath) const
Definition IPlatformFilePak.h:1116
static FString PakPathCombine(FStringView Parent, FStringView Child)
Definition PakFile.cpp:1319
static PAKFILE_API uint64 HashPath(const TCHAR *RelativePathFromMount, uint64 Seed, int32 PakFileVersion)
Definition PakFile.cpp:907
void SetUnderlyingCacheTrimDisabled(bool InUnderlyingCacheTrimDisabled)
Definition IPlatformFilePak.h:939
static PAKFILE_API bool IsPakKeepFullDirectory()
Definition PakFile.cpp:1437
void SetMountPoint(const TCHAR *Path)
Definition IPlatformFilePak.h:1066
static bool GetRelativePathFromMountInline(FString &Child, const FString &MountPoint)
Definition IPlatformFilePak.h:1436
PAKFILE_API bool Check()
Definition PakFile.cpp:1941
FName GetFilenameName() const
Definition IPlatformFilePak.h:1009
virtual bool PakContains(const FString &FullPath) const override
Definition IPlatformFilePak.h:915
const FPakInfo & GetInfo() const
Definition IPlatformFilePak.h:1301
virtual int32 GetNumFiles() const override
Definition IPlatformFilePak.h:1022
Definition IPlatformFilePak.h:1658
@ Alignment
Definition IPlatformFilePak.h:1662
static void DecryptBlock(void *Data, int64 Size, const FGuid &EncryptionKeyGuid)
Definition IPlatformFilePak.h:1670
static int64 AlignReadRequest(int64 Size)
Definition IPlatformFilePak.h:1665
Definition IPlatformFilePak.h:1914
FString ConvertToAbsolutePathForExternalAppForRead(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2537
virtual PAKFILE_API IFileHandle * OpenRead(const TCHAR *Filename, bool bAllowWrite=false) override
Definition IPlatformFilePak.cpp:6584
static PAKFILE_API const TCHAR * GetMountStartupPaksWildCard()
Definition IPlatformFilePak.cpp:6637
PAKFILE_API void Tick() override
Definition IPlatformFilePak.cpp:4733
static PAKFILE_API bool bMountFailOnMissingUtoc
Definition IPlatformFilePak.h:2071
static PAKFILE_API FCriticalSection PakSignatureFileCacheLock
Definition IPlatformFilePak.h:2646
virtual PAKFILE_API FFileStatData GetStatData(const TCHAR *FilenameOrDirectory) override
Definition IPlatformFilePak.cpp:5417
virtual FString GetFilenameOnDisk(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2442
virtual PAKFILE_API ~FPakPlatformFile()
Definition IPlatformFilePak.cpp:4524
PAKFILE_API void OptimizeMemoryUsageForMountedPaks()
Definition IPlatformFilePak.cpp:5815
PAKFILE_API void GetPrunedFilenamesInPakFile(const FString &InPakFilename, TArray< FString > &OutFileList)
Definition IPlatformFilePak.cpp:5004
virtual const TCHAR * GetName() const override
Definition IPlatformFilePak.h:2200
static PAKFILE_API bool FindFileInPakFiles(TArray< FPakListEntry > &Paks, const TCHAR *Filename, TRefCountPtr< FPakFile > *OutPakFile, FPakEntry *OutEntry=nullptr)
Definition IPlatformFilePak.cpp:5314
virtual PAKFILE_API IAsyncReadFileHandle * OpenAsyncRead(const TCHAR *Filename, bool bAllowWrite=false) override
Definition IPlatformFilePak.cpp:4685
virtual PAKFILE_API void FindFilesRecursively(TArray< FString > &FoundFiles, const TCHAR *Directory, const TCHAR *FileExtension) override
Definition IPlatformFilePak.cpp:4932
virtual IPlatformFile * GetLowerLevel() override
Definition IPlatformFilePak.h:2191
virtual bool FileExists(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2267
virtual bool IsReadOnly(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2316
virtual PAKFILE_API bool IterateDirectoryStat(const TCHAR *Directory, IPlatformFile::FDirectoryStatVisitor &Visitor) override
Definition IPlatformFilePak.cpp:4883
virtual FOpenMappedResult OpenMappedEx(const TCHAR *Filename, EOpenReadFlags OpenOptions=EOpenReadFlags::None, int64 MaximumSize=0) override
Definition IPlatformFilePak.cpp:4637
static PAKFILE_API void BroadcastPakChunkSignatureCheckFailure(const FPakChunkSignatureCheckFailedData &InData)
Definition IPlatformFilePak.cpp:5225
virtual PAKFILE_API bool IterateDirectoryRecursively(const TCHAR *Directory, IPlatformFile::FDirectoryVisitor &Visitor) override
Definition IPlatformFilePak.cpp:5188
PAKFILE_API void HandlePakCorruptCommand(const TCHAR *Cmd, FOutputDevice &Ar)
Definition IPlatformFilePak.cpp:4488
void GetMountedPakFilenames(TSet< FString > &PakFilenames)
Definition IPlatformFilePak.h:2123
static PAKFILE_API TSharedPtr< const struct FPakSignatureFile, ESPMode::ThreadSafe > GetPakSignatureFile(const TCHAR *InFilename)
Definition IPlatformFilePak.cpp:4798
virtual PAKFILE_API bool CreateDirectoryTree(const TCHAR *Directory) override
Definition IPlatformFilePak.cpp:4998
virtual ESymlinkResult IsSymlink(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2490
virtual PAKFILE_API bool DirectoryExists(const TCHAR *Directory) override
Definition IPlatformFilePak.cpp:5386
virtual FDateTime GetAccessTimeStamp(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2425
static PAKFILE_API FPakSetIndexSettings & GetPakSetIndexSettingsDelegate()
Definition IPlatformFilePak.cpp:5247
FString ConvertToPakRelativePath(const TCHAR *Filename, const FPakFile *Pak)
Definition IPlatformFilePak.h:2531
virtual void SetLowerLevel(IPlatformFile *NewLowerLevel) override
Definition IPlatformFilePak.h:2195
virtual PAKFILE_API bool ShouldBeUsed(IPlatformFile *Inner, const TCHAR *CmdLine) const override
Definition IPlatformFilePak.cpp:5566
PAKFILE_API FPakPlatformFile()
Definition IPlatformFilePak.cpp:4517
virtual PAKFILE_API bool IterateDirectory(const TCHAR *Directory, IPlatformFile::FDirectoryVisitor &Visitor) override
Definition IPlatformFilePak.cpp:5091
virtual int64 FileSize(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2283
virtual PAKFILE_API void FindFiles(TArray< FString > &FoundFiles, const TCHAR *Directory, const TCHAR *FileExtension) override
Definition IPlatformFilePak.cpp:4921
PAKFILE_API void ReleaseOldReaders()
Definition IPlatformFilePak.cpp:5801
virtual PAKFILE_API bool DeleteDirectoryRecursively(const TCHAR *Directory) override
Definition IPlatformFilePak.cpp:4987
static PAKFILE_API void GetFilenamesFromIostoreContainer(const FString &InContainerName, TArray< FString > &OutFileList)
Definition IPlatformFilePak.cpp:5019
virtual bool DeleteFile(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2300
PAKFILE_API bool AnyChunksAvailable() const
Definition IPlatformFilePak.cpp:6671
FString ConvertToAbsolutePathForExternalAppForWrite(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2551
virtual bool SetReadOnly(const TCHAR *Filename, bool bNewReadOnlyValue) override
Definition IPlatformFilePak.h:2348
virtual PAKFILE_API void SetAsyncMinimumPriority(EAsyncIOPriorityAndFlags Priority) override
Definition IPlatformFilePak.cpp:4721
virtual PAKFILE_API void MakeUniquePakFilesForTheseFiles(const TArray< TArray< FString > > &InFiles)
Definition IPlatformFilePak.cpp:6749
virtual PAKFILE_API bool IterateDirectoryStatRecursively(const TCHAR *Directory, IPlatformFile::FDirectoryStatVisitor &Visitor) override
Definition IPlatformFilePak.cpp:4915
virtual PAKFILE_API bool CreateDirectory(const TCHAR *Directory) override
Definition IPlatformFilePak.cpp:5398
static PAKFILE_API void GetPakEncryptionKey(FAES::FAESKey &OutKey, const FGuid &InEncryptionKeyGuid)
Definition IPlatformFilePak.cpp:4866
static PAKFILE_API FFilenameSecurityDelegate & GetFilenameSecurityDelegate()
Definition IPlatformFilePak.cpp:5207
static PAKFILE_API bool CheckIfPakFilesExist(IPlatformFile *LowLevelFile, const TArray< FString > &PakFolders)
Definition IPlatformFilePak.cpp:5559
static PAKFILE_API void BroadcastPakPrincipalSignatureTableCheckFailure(const FString &InFilename)
Definition IPlatformFilePak.cpp:5232
void GetMountedChunkIds(TSet< int32 > &OutChunkIds)
Definition IPlatformFilePak.h:2136
static PAKFILE_API FPakCustomEncryptionDelegate & GetPakCustomEncryptionDelegate()
Definition IPlatformFilePak.cpp:5213
static PAKFILE_API void ForeachPackageInIostoreWhile(TFunctionRef< bool(FName)> Predicate)
Definition IPlatformFilePak.cpp:5045
virtual PAKFILE_API bool DeleteDirectory(const TCHAR *Directory) override
Definition IPlatformFilePak.cpp:5404
static PAKFILE_API void RemoveCachedPakSignaturesFile(const TCHAR *InFilename)
Definition IPlatformFilePak.cpp:4859
virtual void SetTimeStamp(const TCHAR *Filename, FDateTime DateTime) override
Definition IPlatformFilePak.h:2413
PAKFILE_API void HandleReloadPakReadersCommand(const TCHAR *Cmd, FOutputDevice &Ar)
Definition IPlatformFilePak.cpp:4495
virtual PAKFILE_API IFileHandle * OpenWrite(const TCHAR *Filename, bool bAppend=false, bool bAllowRead=false) override
Definition IPlatformFilePak.cpp:6626
virtual bool MoveFile(const TCHAR *To, const TCHAR *From) override
Definition IPlatformFilePak.h:2332
PAKFILE_API int32 MountAllPakFiles(const TArray< FString > &PakFolders)
Definition IPlatformFilePak.cpp:6317
PAKFILE_API void HandleUnmountCommand(const TCHAR *Cmd, FOutputDevice &Ar)
Definition IPlatformFilePak.cpp:4469
static PAKFILE_API FPakSigningFailureHandlerData & GetPakSigningFailureHandlerData()
Definition IPlatformFilePak.cpp:5219
void GetMountedPakFilenames(TArray< FString > &PakFilenames)
Definition IPlatformFilePak.h:2110
static PAKFILE_API void SetMountStartupPaksWildCard(const FString &WildCard)
Definition IPlatformFilePak.cpp:6642
PAKFILE_API bool ReloadPakReaders()
Definition IPlatformFilePak.cpp:6264
PAKFILE_API void HandlePakListCommand(const TCHAR *Cmd, FOutputDevice &Ar)
Definition IPlatformFilePak.cpp:4478
static PAKFILE_API void GetFilenamesFromIostoreByBlockIndex(const FString &InContainerName, const TArray< int32 > &InBlockIndex, TArray< FString > &OutFileList)
Definition IPlatformFilePak.cpp:5268
PAKFILE_API EChunkLocation::Type GetPakChunkLocation(int32 InPakchunkIndex) const
Definition IPlatformFilePak.cpp:6648
virtual PAKFILE_API void InitializeNewAsyncIO() override
Definition IPlatformFilePak.cpp:5744
static const TCHAR * GetTypeName()
Definition IPlatformFilePak.h:2082
virtual PAKFILE_API bool CopyFile(const TCHAR *To, const TCHAR *From, EPlatformFileRead ReadFlags=EPlatformFileRead::None, EPlatformFileWrite WriteFlags=EPlatformFileWrite::None) override
Definition IPlatformFilePak.cpp:6714
static PAKFILE_API void BroadcastPakMasterSignatureTableCheckFailure(const FString &InFilename)
Definition IPlatformFilePak.cpp:5240
virtual FDateTime GetTimeStamp(const TCHAR *Filename) override
Definition IPlatformFilePak.h:2365
static PAKFILE_API void GetPakFolders(const TCHAR *CmdLine, TArray< FString > &OutPakFolders)
Definition IPlatformFilePak.cpp:5539
virtual void GetTimeStampPair(const TCHAR *FilenameA, const TCHAR *FilenameB, FDateTime &OutTimeStampA, FDateTime &OutTimeStampB) override
Definition IPlatformFilePak.h:2384
PAKFILE_API void RefreshPakChunkIndicies()
Definition IPlatformFilePak.cpp:5193
PAKFILE_API void HandleMountCommand(const TCHAR *Cmd, FOutputDevice &Ar)
Definition IPlatformFilePak.cpp:4459
PAKFILE_API void GetPrunedFilenamesInChunk(const FString &InPakFilename, const TArray< int32 > &InChunkIDs, TArray< FString > &OutFileList)
Definition IPlatformFilePak.cpp:5253
static PAKFILE_API TMap< FName, TSharedPtr< const struct FPakSignatureFile, ESPMode::ThreadSafe > > PakSignatureFileCache
Definition IPlatformFilePak.h:2645
Definition IPlatformFilePak.h:1683
TAcquirePakReaderFunction AcquirePakReader
Definition IPlatformFilePak.h:1690
const FPakFile & PakFile
Definition IPlatformFilePak.h:1686
FPakReaderPolicy(const FPakFile &InPakFile, const FPakEntry &InPakEntry, TAcquirePakReaderFunction &InAcquirePakReader)
Definition IPlatformFilePak.h:1694
FPakEntry PakEntry
Definition IPlatformFilePak.h:1688
int64 OffsetToFile
Definition IPlatformFilePak.h:1692
void Serialize(int64 DesiredPosition, void *V, int64 Length) const
Definition IPlatformFilePak.h:1707
int64 FileSize() const
Definition IPlatformFilePak.h:1702
static CORE_API FString GetPath(const FString &InPath)
Definition Paths.cpp:1043
Definition RefCounting.h:213
static CORE_API void HashBuffer(const void *Data, uint64 DataSize, uint8 *OutHash)
Definition SecureHash.cpp:1281
Definition SecureHash.h:226
FString ToString() const
Definition SecureHash.h:242
uint8 Hash[20]
Definition SecureHash.h:228
Definition IPlatformFilePak.h:699
bool operator==(TYPE_OF_NULLPTR)
Definition IPlatformFilePak.h:716
FSharedPakReader & operator=(const FSharedPakReader &Other)=delete
FArchive * operator->()
Definition IPlatformFilePak.h:718
FSharedPakReader(const FSharedPakReader &Other)=delete
bool operator!=(TYPE_OF_NULLPTR)
Definition IPlatformFilePak.h:717
FArchive & GetArchive()
Definition IPlatformFilePak.h:722
PAKFILE_API ~FSharedPakReader()
Definition IPlatformFilePak.cpp:4379
Definition AsyncFileHandle.h:211
Definition GenericPlatformFile.h:117
Definition MappedFileHandle.h:115
Definition GenericPlatformFile.h:1020
Definition GenericPlatformFile.h:623
Definition GenericPlatformFile.h:576
Definition GenericPlatformFile.h:342
virtual CORE_API bool IterateDirectoryRecursively(const TCHAR *Directory, FDirectoryVisitor &Visitor)
Definition GenericPlatformFile.cpp:677
virtual CORE_API FString ConvertToAbsolutePathForExternalAppForWrite(const TCHAR *Filename)
Definition GenericPlatformFile.cpp:998
virtual bool IterateDirectoryStat(const TCHAR *Directory, FDirectoryStatVisitor &Visitor)=0
virtual bool MoveFile(const TCHAR *To, const TCHAR *From)=0
virtual ESymlinkResult IsSymlink(const TCHAR *Filename)
Definition GenericPlatformFile.h:469
virtual bool IterateDirectory(const TCHAR *Directory, FDirectoryVisitor &Visitor)=0
virtual bool IsReadOnly(const TCHAR *Filename)=0
virtual CORE_API void GetTimeStampPair(const TCHAR *PathA, const TCHAR *PathB, FDateTime &OutTimeStampA, FDateTime &OutTimeStampB)
Definition GenericPlatformFile.cpp:592
virtual void SetTimeStamp(const TCHAR *Filename, FDateTime DateTime)=0
virtual bool DeleteFile(const TCHAR *Filename)=0
virtual bool SetReadOnly(const TCHAR *Filename, bool bNewReadOnlyValue)=0
virtual bool FileExists(const TCHAR *Filename)=0
virtual int64 FileSize(const TCHAR *Filename)=0
EOpenReadFlags
Definition GenericPlatformFile.h:496
virtual CORE_API FString ConvertToAbsolutePathForExternalAppForRead(const TCHAR *Filename)
Definition GenericPlatformFile.cpp:993
virtual FString GetFilenameOnDisk(const TCHAR *Filename)=0
virtual CORE_API bool IterateDirectoryStatRecursively(const TCHAR *Directory, FDirectoryStatVisitor &Visitor)
Definition GenericPlatformFile.cpp:734
virtual FDateTime GetTimeStamp(const TCHAR *Filename)=0
virtual FDateTime GetAccessTimeStamp(const TCHAR *Filename)=0
Definition PakFile.Build.cs:6
Definition ArrayView.h:139
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void Reset(SizeType NewSize=0)
Definition Array.h:2246
UE_NODEBUG UE_FORCEINLINE_HINT ElementType * GetData() UE_LIFETIMEBOUND
Definition Array.h:1027
void SetNum(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2308
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
void Append(const TArray< OtherElementType, OtherAllocatorType > &Source)
Definition Array.h:2412
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition DirectoryTree.h:85
Definition AssetRegistryState.h:50
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition RefCounting.h:454
Definition SharedPointer.h:692
Definition UniquePtr.h:107
Definition ValueOrError.h:58
Definition CriticalSection.h:14
Definition IPlatformFilePak.cpp:302
Definition ScopeLock.h:21
Type
Definition GenericPlatformChunkInstall.h:32
NO_LOGGING.
Definition Client.h:20
Definition IPlatformFilePak.cpp:246
TDirectoryTree< FPakDirectory > FDirectoryTreeIndex
Definition IPlatformFilePak.h:732
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition AES.h:27
static double Seconds()
Definition AndroidPlatformTime.h:20
Definition DateTime.h:76
static FDateTime MinValue()
Definition DateTime.h:668
Definition GenericPlatformFile.h:195
Definition Guid.h:109
void Invalidate()
Definition Guid.h:305
Definition IoContainerHeader.h:110
static UE_FORCEINLINE_HINT void * Memzero(void *Dest, SIZE_T Count)
Definition UnrealMemory.h:131
static UE_FORCEINLINE_HINT int32 Memcmp(const void *Buf1, const void *Buf2, SIZE_T Count)
Definition UnrealMemory.h:114
static UE_FORCEINLINE_HINT void * Memcpy(void *Dest, const void *Src, SIZE_T Count)
Definition UnrealMemory.h:160
static UE_FORCEINLINE_HINT void * Memset(void *Dest, uint8 Char, SIZE_T Count)
Definition UnrealMemory.h:119
Definition IPlatformFilePak.h:109
TPakChunkHash ReceivedHash
Definition IPlatformFilePak.h:120
int32 ChunkIndex
Definition IPlatformFilePak.h:118
FPakChunkSignatureCheckFailedData(const FString &InPakFilename, const TPakChunkHash &InExpectedHash, const TPakChunkHash &InReceivedHash, int32 InChunkIndex)
Definition IPlatformFilePak.h:110
FString PakFilename
Definition IPlatformFilePak.h:117
TPakChunkHash ExpectedHash
Definition IPlatformFilePak.h:119
FPakChunkSignatureCheckFailedData()
Definition IPlatformFilePak.h:122
Definition IPlatformFilePak.h:359
int64 CompressedStart
Definition IPlatformFilePak.h:361
bool operator!=(const FPakCompressedBlock &B) const
Definition IPlatformFilePak.h:370
bool operator==(const FPakCompressedBlock &B) const
Definition IPlatformFilePak.h:365
int64 CompressedEnd
Definition IPlatformFilePak.h:363
Definition IPlatformFilePak.h:600
static FPakEntryLocation CreateFromListIndex(int32 ListIndex)
Definition IPlatformFilePak.h:628
FPakEntryLocation(const FPakEntryLocation &Other)=default
bool IsInvalid() const
Definition IPlatformFilePak.h:634
int32 GetAsOffsetIntoEncoded() const
Definition IPlatformFilePak.h:649
static const int32 Invalid
Definition IPlatformFilePak.h:608
int32 GetAsListIndex() const
Definition IPlatformFilePak.h:660
bool IsListIndex() const
Definition IPlatformFilePak.h:644
static FPakEntryLocation CreateInvalid()
Definition IPlatformFilePak.h:617
FPakEntryLocation & operator=(const FPakEntryLocation &other)=default
static FPakEntryLocation CreateFromOffsetIntoEncoded(int32 Offset)
Definition IPlatformFilePak.h:622
static const int32 MaxIndex
Definition IPlatformFilePak.h:609
bool IsOffsetIntoEncoded() const
Definition IPlatformFilePak.h:639
void Serialize(FArchive &Ar)
Definition IPlatformFilePak.h:672
bool operator==(const FPakEntryLocation &Other) const
Definition IPlatformFilePak.h:677
FPakEntryLocation()
Definition IPlatformFilePak.h:611
Definition IPlatformFilePak.h:743
FString Filename
Definition IPlatformFilePak.h:744
FPakEntry Info
Definition IPlatformFilePak.h:745
Definition IPlatformFilePak.h:396
void SetEncrypted(bool bEncrypted)
Definition IPlatformFilePak.h:580
int64 Offset
Definition IPlatformFilePak.h:402
bool operator!=(const FPakEntry &B) const
Definition IPlatformFilePak.h:474
static const uint8 Flag_Deleted
Definition IPlatformFilePak.h:399
int64 Size
Definition IPlatformFilePak.h:404
uint32 CompressionMethodIndex
Definition IPlatformFilePak.h:414
bool IsDeleteRecord() const
Definition IPlatformFilePak.h:582
void Serialize(FArchive &Ar, int32 Version)
Definition IPlatformFilePak.h:511
bool IsEncrypted() const
Definition IPlatformFilePak.h:579
bool GetFlag(uint8 InFlag) const
Definition IPlatformFilePak.h:574
void Reset()
Definition IPlatformFilePak.h:492
int64 GetSerializedSize(int32 Version) const
Definition IPlatformFilePak.h:433
uint8 Flags
Definition IPlatformFilePak.h:416
static const uint8 Flag_Encrypted
Definition IPlatformFilePak.h:398
void SetDeleteRecord(bool bDeleteRecord)
Definition IPlatformFilePak.h:583
static bool VerifyPakEntriesMatch(const FPakEntry &FileEntryA, const FPakEntry &FileEntryB)
Definition IPlatformFilePak.cpp:4344
TArray< FPakCompressedBlock > CompressionBlocks
Definition IPlatformFilePak.h:410
uint8 Hash[20]
Definition IPlatformFilePak.h:408
void SetFlag(uint8 InFlag, bool bValue)
Definition IPlatformFilePak.h:562
bool operator==(const FPakEntry &B) const
Definition IPlatformFilePak.h:465
bool IndexDataEquals(const FPakEntry &B) const
Definition IPlatformFilePak.h:479
int64 UncompressedSize
Definition IPlatformFilePak.h:406
bool Verified
Definition IPlatformFilePak.h:418
static const uint8 Flag_None
Definition IPlatformFilePak.h:397
FPakEntry()
Definition IPlatformFilePak.h:423
uint32 CompressionBlockSize
Definition IPlatformFilePak.h:412
Definition IPlatformFilePak.h:799
TUniquePtr< FArchive > Archive
Definition IPlatformFilePak.h:800
double LastAccessTime
Definition IPlatformFilePak.h:801
Definition IPlatformFilePak.h:768
bool bRequiresDirectoryIndexLock
Definition IPlatformFilePak.h:791
~FScopedPakDirectoryIndexAccess()
Definition IPlatformFilePak.h:783
const FPakFile & PakFile
Definition IPlatformFilePak.h:790
FScopedPakDirectoryIndexAccess(const FPakFile &InPakFile)
Definition IPlatformFilePak.h:769
Definition IPlatformFilePak.h:138
FGuid EncryptionKeyGuid
Definition IPlatformFilePak.h:186
@ PakFile_Version_NoTimestamps
Definition IPlatformFilePak.h:155
@ PakFile_Version_Initial
Definition IPlatformFilePak.h:154
@ PakFile_Version_Invalid
Definition IPlatformFilePak.h:169
@ PakFile_Version_FNameBasedCompressionMethod
Definition IPlatformFilePak.h:161
@ PakFile_Version_Last
Definition IPlatformFilePak.h:168
@ PakFile_Version_CompressionEncryption
Definition IPlatformFilePak.h:156
void Serialize(FArchive &Ar, int32 InVersion)
Definition IPlatformFilePak.h:231
int32 GetCompressionMethodIndex(FName CompressionMethod)
Definition IPlatformFilePak.h:321
uint8 bEncryptedIndex
Definition IPlatformFilePak.h:184
int64 GetSerializedSize(int32 InVersion=PakFile_Version_Latest) const
Definition IPlatformFilePak.h:209
int64 IndexOffset
Definition IPlatformFilePak.h:178
int64 HasRelativeCompressedChunkOffsets() const
Definition IPlatformFilePak.h:221
FPakInfo()
Definition IPlatformFilePak.h:193
FSHAHash IndexHash
Definition IPlatformFilePak.h:182
TOptional< FName > TryGetCompressionMethod(uint32 Index) const
Definition IPlatformFilePak.h:345
FName GetCompressionMethod(uint32 Index) const
Definition IPlatformFilePak.h:340
int64 IndexSize
Definition IPlatformFilePak.h:180
TArray< FName > CompressionMethods
Definition IPlatformFilePak.h:188
int32 Version
Definition IPlatformFilePak.h:176
uint32 Magic
Definition IPlatformFilePak.h:174
Definition IPlatformFilePak.h:1897
uint32 PakOrder
Definition IPlatformFilePak.h:1901
bool bLoadIndex
Definition IPlatformFilePak.h:1907
const TCHAR * Path
Definition IPlatformFilePak.h:1903
const TCHAR * PakFilename
Definition IPlatformFilePak.h:1899
FPakMountOptions MountOptions
Definition IPlatformFilePak.h:1905
Definition GenericPlatformFile.h:1041
Definition IPlatformFilePak.h:2579
FPakChunkSignatureCheckFailedHandler & GetPakChunkSignatureCheckFailedDelegate()
Definition IPlatformFilePak.h:2582
FPakChunkSignatureCheckFailedHandler ChunkSignatureCheckFailedDelegate
Definition IPlatformFilePak.h:2590
PRAGMA_DISABLE_DEPRECATION_WARNINGS FCriticalSection & GetLock()
Definition IPlatformFilePak.h:2581
PRAGMA_ENABLE_DEPRECATION_WARNINGS FCriticalSection Lock
Definition IPlatformFilePak.h:2587
FPakPrincipalSignatureTableCheckFailureHandler & GetPrincipalSignatureTableCheckFailedDelegate()
Definition IPlatformFilePak.h:2583
FPakPrincipalSignatureTableCheckFailureHandler MasterSignatureTableCheckFailedDelegate
Definition IPlatformFilePak.h:2593
Definition IPlatformFilePak.h:2663
void Serialize(FArchive &Ar)
Definition IPlatformFilePak.h:2709
bool DecryptSignatureAndValidate(const FRSAKeyHandle InKey, const FString &InFilename)
Definition IPlatformFilePak.h:2730
TArray< uint8 > EncryptedHash
Definition IPlatformFilePak.h:2680
FSHAHash DecryptedHash
Definition IPlatformFilePak.h:2683
EVersion
Definition IPlatformFilePak.h:2668
TArray< uint8 > SignatureData
Definition IPlatformFilePak.h:2686
FSHAHash ComputeCurrentPrincipalHash() const
Definition IPlatformFilePak.h:2766
TArray< TPakChunkHash > ChunkHashes
Definition IPlatformFilePak.h:2689
void SetChunkHashesAndSign(const TArray< TPakChunkHash > &InChunkHashes, const TArrayView< uint8 > &InSignatureData, const FRSAKeyHandle InKey)
Definition IPlatformFilePak.h:2694
static RSA_API int32 DecryptPublic(const TArrayView< const uint8 > InSource, TArray< uint8 > &OutDestination, const FRSAKeyHandle InKey)
Definition RSA.cpp:74
static RSA_API int32 EncryptPrivate(const TArrayView< const uint8 > InSource, TArray< uint8 > &OutDestination, const FRSAKeyHandle InKey)
Definition RSA.cpp:64
static CharType * Strncpy(CharType *Dest, const CharType *Src, SIZE_T MaxLen)
Definition CString.h:991
Definition DirectoryTree.h:216
Definition Optional.h:131
Definition IPlatformFilePak.cpp:4512
Definition IPlatformFilePak.cpp:6436