| 379 | void StampProjectIcon(FStringView ExePath, FStringView IconRecordPath, const TFunction<void(FStringView)>& LogFunc) |
| 380 | { |
| 381 | if (!Filesystem::Exists(IconRecordPath)) |
| 382 | { |
| 383 | return; |
| 384 | } |
| 385 | |
| 386 | Windowing::FWindowIcon Icon; |
| 387 | FString Error; |
| 388 | if (Windowing::LoadWindowIcon(IconRecordPath, Icon) && ExecutableIconStamp::Stamp(ExePath, Icon, Error)) |
| 389 | { |
| 390 | LogPackager(LogFunc, *Format("Stamped the project icon into {}", *FileNameOf(ExePath))); |
| 391 | return; |
| 392 | } |
| 393 | LogPackager(LogFunc, *Format("[warn] {} keeps the Lumina icon, since {}", *FileNameOf(ExePath), Error.IsEmpty() ? FString("the cooked icon is unreadable") : Error)); |
| 394 | } |
| 395 | |
| 396 | // Paks used to sit beside the exe, where the game would still mount them over the data folder's. |
| 397 | void RemoveOldPaks(FStringView OutDir, const TFunction<void(FStringView)>& LogFunc) |
| 398 | { |
| 399 | TVector<FString> Old; |
| 400 | Filesystem::IterateDirectory(OutDir, [&Old](const Filesystem::FDirectoryEntry& Entry) |
| 401 | { |
| 402 | if (!Entry.IsDirectory() && (Entry.GetExtension() == FStringView(".pak") || Entry.Name.EndsWith(".contents.txt"))) |
| 403 | { |
| 404 | Old.Emplace(Entry.FullPath.GetData(), Entry.FullPath.Len()); |
| 405 | } |
| 406 | }); |
| 407 | for (const FString& Path : Old) |
| 408 | { |
| 409 | if (Filesystem::RemoveFile(FStringView(*Path, Path.Len()))) |
| 410 | { |
| 411 | LogPackager(LogFunc, *Format(" - removed {} from the old layout", *FileNameOf(Path))); |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | // The runtime, managed code and third-party DLLs are restaged into the data folder, so earlier copies would only shadow them. |
| 417 | void RemoveOldPayload(const FPackagePlatformRules& Rules, FStringView OutDir, FStringView DataDir, const TFunction<void(FStringView)>& LogFunc) |
| 418 | { |
| 419 | const FStringView OldDirectories[] = { "DotNet", "External" }; |
| 420 | for (const FStringView Directory : OldDirectories) |
| 421 | { |
| 422 | const FFixedString Path = Paths::Combine(OutDir, Directory); |
| 423 | if (Filesystem::Exists(Path) && Filesystem::RemoveTree(Path)) |
| 424 | { |
| 425 | LogPackager(LogFunc, *Format(" - removed {}/ from the old layout", *FString(Directory.GetData(), Directory.Len()))); |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | const FStringView StagedDirectories[] = { "Managed", "Runtime", "Plugins" }; |
| 430 | for (const FStringView Directory : StagedDirectories) |
| 431 | { |
| 432 | const FFixedString Path = Paths::Combine(DataDir, Directory); |
| 433 | if (Filesystem::Exists(Path)) |
| 434 | { |
| 435 | Filesystem::RemoveTree(Path); |
| 436 | } |
| 437 | } |
| 438 |
nothing calls this directly
no test coverage detected