Files
UnrealEngineUWP/Engine/Source/Developer/Virtualization/Private/VirtualizationUtilities.cpp
paul chipchase d1060bb972 Change the file path to be three directories deep from the root, with each directory being named 00->ff, we then attempt to place each file in a directory based on a hash of the PayloadId, ideally evenly distributing between all available leaf directories.
- Cleaned up some allocations caused by string manipulation.

*Add a place for shared utility code that could have use in multiple places in the virtualization system.
- First utility is a function to generate a file path based off a FPayloadId.
- The path produced is similar to how we organize files in the DDC but instead of 0->9 we use the range 0->ff in hex.
- To generate the path we take the string form of FPayloadId and then use the first 6 characters to create the directories (each directory using 2 characters) and then the remaining 34 characters becomes the filename.

#rb Stefan.Boberg
#rnx

#ushell-cherrypick of 16167644 by paul.chipchase
#preflight 608f9330f5b27a0001b2d5ab

[CL 16182581 by paul chipchase in ue5-main branch]
2021-05-03 02:47:29 -04:00

35 lines
745 B
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "VirtualizationUtilities.h"
#include "Misc/StringBuilder.h"
#include "Virtualization/PayloadId.h"
namespace UE::Virtualization::Utils
{
void PayloadIdToPath(const FPayloadId& Id, FStringBuilderBase& OutPath)
{
OutPath.Reset();
OutPath << Id;
TStringBuilder<10> Directory;
Directory << OutPath.ToView().Left(2) << TEXT("/");
Directory << OutPath.ToView().Mid(2, 2) << TEXT("/");
Directory << OutPath.ToView().Mid(4, 2) << TEXT("/");
OutPath.ReplaceAt(0, 6, Directory);
OutPath << TEXT(".payload");
}
FString PayloadIdToPath(const FPayloadId& Id)
{
TStringBuilder<52> Path;
PayloadIdToPath(Id, Path);
return FString(Path);
}
} // namespace UE::Virtualization::Utils