Add InsertPlatformFile to FPlatformFileManager to support adding an IPlatformFile after initial startup (for example, from a plugin)

[REVIEW] [at]Graeme.Thornton [at]Mitchell.Fisher [at]Daniel.Lamb

#preflight https://horde.devtools.epicgames.com/job/6319f901967ffc68fbd7a05e

[CL 21916052 by justin marcus in ue5-main branch]
This commit is contained in:
justin marcus
2022-09-09 00:55:01 -04:00
parent e264a741c6
commit a3edb20a8f
2 changed files with 45 additions and 2 deletions

View File

@@ -115,6 +115,39 @@ void FPlatformFileManager::RemovePlatformFile(IPlatformFile* PlatformFileToRemov
}
}
bool FPlatformFileManager::InsertPlatformFile(IPlatformFile* NewPlatformFile)
{
check(TopmostPlatformFile != nullptr);
check(NewPlatformFile != nullptr);
if (FindPlatformFile(NewPlatformFile->GetName()))
{
return false;
}
if (NewPlatformFile->GetLowerLevel() == nullptr)
{
return false; // Physical layer must be at the bottom
}
if (NewPlatformFile->GetLowerLevel() == TopmostPlatformFile)
{
SetPlatformFile(*NewPlatformFile);
return true;
}
for (IPlatformFile* ChainElement = TopmostPlatformFile; ChainElement; ChainElement = ChainElement->GetLowerLevel())
{
if (ChainElement->GetLowerLevel() == NewPlatformFile->GetLowerLevel())
{
ChainElement->SetLowerLevel(NewPlatformFile);
return true;
}
}
return false;
}
void FPlatformFileManager::InitializeNewAsyncIO()
{
// Removed the cached file wrapper because it doesn't work well with EDL

View File

@@ -79,9 +79,19 @@ public:
* THIS IS EXTREMELY DANGEROUS AFTER THE ENGINE HAS BEEN INITIALIZED AS WE MAY BE MODIFYING
* THE WRAPPER CHAIN WHILE THINGS ARE BEING LOADED
*
* @param Name of the platform file to create.
* @return Platform file instance of the platform file type was found, nullptr otherwise.
* @param The platform file to remove.
*/
void RemovePlatformFile(IPlatformFile* PlatformFileToRemove);
/**
* Inserts a new platform file into the platform file wrapper chain.
* The file is inserted before NewPlatformFile->GetLowerLevel().
*
* THIS IS EXTREMELY DANGEROUS AFTER THE ENGINE HAS BEEN INITIALIZED AS WE MAY BE MODIFYING
* THE WRAPPER CHAIN WHILE THINGS ARE BEING LOADED
*
* @param The platform file to insert.
* @return true if the platform file was inserted.
*/
bool InsertPlatformFile(IPlatformFile* NewPlatformFile);
};