1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| bool ExecuteUnrealPak(const TCHAR* CmdLine) {
TArray<FPakInputPair> Entries; FPakCommandLineParameters CmdLineParameters; ProcessCommandLine(CmdLine, NonOptionArguments, Entries, CmdLineParameters);
if(NonOptionArguments.Num() > 0) { CheckAndReallocThreadPool();
FString PakFilename = GetPakPath(*NonOptionArguments[0], true);
TArray<FPakInputPair> Entries; FPakCommandLineParameters CmdLineParameters; ProcessCommandLine(CmdLine, NonOptionArguments, Entries, CmdLineParameters);
FPakOrderMap OrderMap; FString ResponseFile; if (FParse::Value(CmdLine, TEXT("-order="), ResponseFile) && !OrderMap.ProcessOrderFile(*ResponseFile)) { return false; }
FString SecondaryResponseFile; if (FParse::Value(CmdLine, TEXT("-secondaryOrder="), SecondaryResponseFile) && !OrderMap.ProcessOrderFile(*SecondaryResponseFile, true)) { return false; }
int32 LowestSourcePakVersion = 0; TMap<FString, FFileInfo> SourceFileHashes;
if (CmdLineParameters.GeneratePatch) { FString OutputPath; if (!FParse::Value(CmdLine, TEXT("TempFiles="), OutputPath)) { OutputPath = FPaths::GetPath(PakFilename) / FString(TEXT("TempFiles")); }
IFileManager::Get().DeleteDirectory(*OutputPath);
FString PatchReferenceCryptoKeysFilename; FKeyChain PatchKeyChain;
if (FParse::Value(FCommandLine::Get(), TEXT("PatchCryptoKeys="), PatchReferenceCryptoKeysFilename)) { LoadKeyChainFromFile(PatchReferenceCryptoKeysFilename, PatchKeyChain); ApplyEncryptionKeys(PatchKeyChain); }
UE_LOG(LogPakFile, Display, TEXT("Generating patch from %s."), *CmdLineParameters.SourcePatchPakFilename, true );
if (!GenerateHashesFromPak(*CmdLineParameters.SourcePatchPakFilename, *PakFilename, SourceFileHashes, true, PatchKeyChain, LowestSourcePakVersion)) { if (ExtractFilesFromPak(*CmdLineParameters.SourcePatchPakFilename, SourceFileHashes, *OutputPath, true, PatchKeyChain, nullptr) == false) { UE_LOG(LogPakFile, Warning, TEXT("Unable to extract files from source pak file for patch")); } else { CmdLineParameters.SourcePatchDiffDirectory = OutputPath; } }
ApplyEncryptionKeys(KeyChain); }
TArray<FPakInputPair> FilesToAdd; CollectFilesToAdd(FilesToAdd, Entries, OrderMap, CmdLineParameters);
if (CmdLineParameters.GeneratePatch) { TArray<FPakInputPair> DeleteRecords = GetNewDeleteRecords(FilesToAdd, SourceFileHashes);
if (LowestSourcePakVersion < FPakInfo::PakFile_Version_DeleteRecords) { int32 CurrentPatchChunkIndex = GetPakChunkIndexFromFilename(PakFilename);
UE_LOG(LogPakFile, Display, TEXT("Some patch source paks were generated with an earlier version of UnrealPak that didn't support delete records. checking for historic assets that have moved between chunks to avoid creating invalid delete records")); FString SourcePakFolder = FPaths::GetPath(CmdLineParameters.SourcePatchPakFilename);
ProcessLegacyFileMoves(DeleteRecords, SourceFileHashes, SourcePakFolder, FilesToAdd, CurrentPatchChunkIndex); } FilesToAdd.Append(DeleteRecords);
RemoveIdenticalFiles(FilesToAdd, CmdLineParameters.SourcePatchDiffDirectory, SourceFileHashes, CmdLineParameters.SeekOptParams, CmdLineParameters.ChangedFilesOutputFilename); }
bool bResult = CreatePakFile(*PakFilename, FilesToAdd, CmdLineParameters, KeyChain);
if (CmdLineParameters.GeneratePatch) { FString OutputPath = FPaths::GetPath(PakFilename) / FString(TEXT("TempFiles")); IFileManager::Get().DeleteDirectory(*OutputPath, false, true); }
GetDerivedDataCacheRef().WaitForQuiescence(true);
return bResult; }
}
|