Files
UnrealEngineUWP/Engine/Source/Developer/Virtualization/Private/VirtualizationUtilities.h
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

45 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/StringFwd.h"
#include "Containers/UnrealString.h"
namespace UE::Virtualization
{
class FPayloadId;
} // namespace UE::Virtualization
namespace UE::Virtualization::Utils
{
/**
* Converts a FPayloadId into a file path.
*
* This utility will take a FPayloadId and return a file path that is
* 3 directories deep. The first six characters of the id will be used to
* create the directory names, with each directory using two characters.
* The remaining thirty four characters will be used as the file name.
* Lastly the extension '.payload' will be applied to complete the path/
* Example: FPayloadId 0139d6d5d477e32dfd2abd3c5bc8ea8507e8eef8 becomes
* 01/39/d6/d5d477e32dfd2abd3c5bc8ea8507e8eef8.payload'
*
* @param Id The payload identifier used to create the file path.
* @param OutPath Will be reset and then assigned the resulting file path.
* The string builder must have a capacity of at least 52 characters
to avoid reallocation.
*/
void PayloadIdToPath(const FPayloadId& Id, FStringBuilderBase& OutPath);
/**
* Converts a FPayloadId into a file path.
*
* See above for further details
*
* @param Id The payload identifier used to create the file path.
* @return The resulting file path.
*/
FString PayloadIdToPath(const FPayloadId& Id);
} // namespace UE::Virtualization::Utils