Files
UnrealEngineUWP/Engine/Source/Runtime/RuntimeAssetCache/Private/RuntimeAssetCacheFilesystemBackend.cpp
James Brinkerhoff 0f37066e3e Copying //UE4/Ocean-Staging to //UE4/Dev-Main (Source: //Ocean/Main @ 3355692)
#lockdown Nick.Penwarden

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3348195 on 2017/03/15 by James.Brinkerhoff

	Hotfix from CL 3347729 for variable shadow warning caused by CL 3347393

Change 3347935 on 2017/03/15 by James.Brinkerhoff

	Hotfix from CL 3347393 for a runtime asset crash

Change 3340537 on 2017/03/09 by James.Brinkerhoff

	Hotfix from CL 3338679 for arrow keys not working to navigate between elements in the details panel

Change 3335755 on 2017/03/07 by Ben.Marsh

	Pass bCreateStubIPA into PrepForUATPackageOrDeploy rather than setting it through a global configuration object (which is no longer accessible).

Change 3334652 on 2017/03/06 by James.Brinkerhoff

	Merging //UE4/Ocean-Staging to //Ocean/Main @ CL 3331740

Change 3332441 on 2017/03/03 by James.Brinkerhoff

	Hotfix from CL 3296668 for assert when creating memory reports
	#jira OCN-6087: [CRASH] Crash after entering the memreport command into the command line.

Change 3318933 on 2017/02/23 by Allan.Bentham

	Temp workaround for iOS metal sRGB capable render targets sRGB correcting twice.

Change 3314064 on 2017/02/21 by Richard.Fawcett

	Implement randomized manifest filenames for Ocean.

Change 3313139 on 2017/02/20 by James.Brinkerhoff

	Hotfix from CL 3262052 for UE-40782 Put back the skinxx workflow for the staticmesh

Change 3292678 on 2017/02/08 by Brian.Zaugg

	Back out changelist 3292455

Change 3292455 on 2017/02/08 by Brian.Zaugg

	Back out changelist 3292268

Change 3292268 on 2017/02/08 by Allan.Bentham

	Restore DestStride output value when locking compressed textures.

Change 3288925 on 2017/02/06 by Brian.Zaugg

	Change this error from a check to an error log: "Loading non-streamed mips from an external bulk file.  This is not desireable."

Change 3288441 on 2017/02/06 by James.Brinkerhoff

	Hotfix from CL 3255451 for UE-40384: Reference Viewer comment text is difficult to read
	#jira OCN-6059: CLONE - Comment boxes are turning opaque when the game is running

Change 3285501 on 2017/02/03 by Allan.Bentham

	Fix  for ring buffer not allocating sufficient space for large requests.

Change 3280062 on 2017/01/31 by Max.Chen

	Sequencer: Find object in any package. This fixes an issue where bound objects can't be found.

	#jira UE-39459

Change 3279375 on 2017/01/31 by Brian.Zaugg

	Increase TaskGraph thread stack size for non-shipping builds to prevent stack overflow on iOS.

Change 3279366 on 2017/01/31 by Brian.Zaugg

	Fix for iOS virtual keyboard.

Change 3275965 on 2017/01/27 by Max.Chen

	Sequencer: Only reset persistent evaluation data when the sequence has changed
	  - This ensures that we don't destroy persistent data that is assumed to still exist (i.e. it was created in ::Setup) from the same sequence

	Copy from Release-4.15

	#jira UE-40234

Change 3275963 on 2017/01/27 by Max.Chen

	Sequencer: Fixed crash caused by lingering persistent evaluation data

	Copy from Release-4.15

	#jira UE-40064

Change 3275962 on 2017/01/27 by Max.Chen

	Sequencer: Evaluation templates are now only fully rebuilt in PIE, and will not re-cycle track identifiers
	  - This addresses issues with newly compiled tracks recycling the persistent data of old stale tracks.
	  - This commit also ensures we don't fully rebuild templates in the editor when in Sequencer

	Copy from Release-4.15

	#jira UE-39882

Change 3275523 on 2017/01/27 by James.Brinkerhoff

	Fix issue with automation tool caused by a bad resolve

Change 3274292 on 2017/01/26 by James.Brinkerhoff

	Merging //UE4/Ocean-Staging to //Ocean/Main @ CL 3269883

Change 3252898 on 2017/01/10 by James.Brinkerhoff

	Hotfix from CL 3187276 for UE-39071: Crash on adding Actor Reference property to a Struct

Change 3248463 on 2017/01/05 by Aaron.McLeran

	Implementing UE-39421 fix into Ocean

Change 3247933 on 2017/01/05 by James.Brinkerhoff

	Hotfix from CL 3246828 for UE-39249: Particle effects only render in one eye for VR

Change 3242274 on 2016/12/21 by James.Brinkerhoff

	Hotfix from CL 3209235 for UE-16688 - Selection and selection highlight doesn't work on child actors

Change 3242273 on 2016/12/21 by James.Brinkerhoff

	Hotfix from CL 3209232 for making the function GetComponents optionally include components in child actors
	Also fixed a circular dependency due to the hotfix (already applied in UE4 Main)

Change 3240035 on 2016/12/19 by Jaren.Peterson

	MovieSceneEventTemplate - Renamed FEventData to FMovieSceneEventData to eliminate confusion and clear up a crash occuring in Ocean debug builds.

Change 3236490 on 2016/12/15 by Chad.Garyet

	Updating packaged build to not make a stub.  This was stopping all icons from making it into the .ipa and messing up the resolution settings.
	also cleaned up the local staging directories.

Change 3231487 on 2016/12/12 by Brian.Zaugg

	Maintain aspect ratio when render target is clamped.

Change 3229050 on 2016/12/09 by Brian.Zaugg

	#ocn - Hotfix from CL 3218104.  Fixes code signing errors related to iCloud support.

Change 3225632 on 2016/12/07 by Brian.Zaugg

	New Chair Entertainment Group iOS Distribution certificate .p12.

Change 3224015 on 2016/12/06 by Brian.Zaugg

	#ocn - Hotfix from CL 3223546 fixes iOS audio crash after last merge from main.

Change 3221665 on 2016/12/05 by James.Brinkerhoff

	Merging hotfixes from //UE4/Ocean-Staging to //Ocean/Main
	Hotfix from CL 3216832 for non-unity build failures
	Hotfix from CL 3217564 for fixing the FixDylib script being run on too many modules. Mac build farm is oversaturated right now.

Change 3217759 on 2016/12/01 by James.Brinkerhoff

	Merging //UE4/Ocean-Staging to //Ocean/Main @ 3215855

Change 3214085 on 2016/11/29 by Casey.Spencer

	Removed logic in K2Node_BaseAsyncTask that excluded properties defined on super classes. Check with engine team prior to making change.

[CL 3359832 by James Brinkerhoff in Main branch]
2017-03-23 02:04:59 -04:00

116 lines
3.9 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "RuntimeAssetCacheFilesystemBackend.h"
#include "GenericPlatform/GenericPlatformFile.h"
#include "HAL/FileManager.h"
#include "Misc/Paths.h"
#include "Misc/ConfigCacheIni.h"
#include "RuntimeAssetCacheBucket.h"
#include "RuntimeAssetCacheEntryMetadata.h"
FArchive* FRuntimeAssetCacheFilesystemBackend::CreateReadArchive(FName Bucket, const TCHAR* CacheKey)
{
FString Path = FPaths::Combine(*PathToRAC, *Bucket.ToString(), CacheKey);
return IFileManager::Get().CreateFileReader(*Path);
}
FArchive* FRuntimeAssetCacheFilesystemBackend::CreateWriteArchive(FName Bucket, const TCHAR* CacheKey)
{
FString Path = FPaths::Combine(*PathToRAC, *Bucket.ToString(), CacheKey);
return IFileManager::Get().CreateFileWriter(*Path);
}
FRuntimeAssetCacheFilesystemBackend::FRuntimeAssetCacheFilesystemBackend()
{
GConfig->GetString(TEXT("RuntimeAssetCache"), TEXT("PathToRAC"), PathToRAC, GEngineIni);
PathToRAC = FPaths::GameSavedDir() / PathToRAC;
}
bool FRuntimeAssetCacheFilesystemBackend::RemoveCacheEntry(const FName Bucket, const TCHAR* CacheKey)
{
FString Path = FPaths::Combine(*PathToRAC, *Bucket.ToString(), CacheKey);
return IFileManager::Get().Delete(*Path);
}
bool FRuntimeAssetCacheFilesystemBackend::ClearCache()
{
return IFileManager::Get().DeleteDirectory(*PathToRAC, false, true);
}
bool FRuntimeAssetCacheFilesystemBackend::ClearCache(FName Bucket)
{
return IFileManager::Get().DeleteDirectory(*FPaths::Combine(*PathToRAC, *Bucket.ToString()), false, true);
}
FRuntimeAssetCacheBucket* FRuntimeAssetCacheFilesystemBackend::PreLoadBucket(FName BucketName, int32 BucketSize)
{
FString Path = FPaths::Combine(*PathToRAC, *BucketName.ToString());
FRuntimeAssetCacheBucket* Result = new FRuntimeAssetCacheBucket(BucketSize);
class FRuntimeAssetCacheFilesystemBackendDirectoryVisitor : public IPlatformFile::FDirectoryVisitor
{
public:
FRuntimeAssetCacheFilesystemBackendDirectoryVisitor(FRuntimeAssetCacheBucket* InBucket, FName InBucketName, FRuntimeAssetCacheFilesystemBackend* InBackend)
: Bucket(InBucket)
, BucketName(InBucketName)
, Backend(InBackend)
{ }
virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory)
{
if (bIsDirectory)
{
return true;
}
FString CacheKey = FPaths::GetBaseFilename(FilenameOrDirectory);
FArchive* Ar = Backend->CreateReadArchive(BucketName, *CacheKey);
FCacheEntryMetadata* Metadata = Backend->PreloadMetadata(Ar);
Files.Add(TFilenameMetadataPair(*FPaths::GetBaseFilename(FilenameOrDirectory), Metadata));
delete Ar;
return true;
}
void Finalize()
{
Files.Sort([](const TFilenameMetadataPair& A, const TFilenameMetadataPair& B) { return A.Get<1>()->GetLastAccessTime() > B.Get<1>()->GetLastAccessTime(); });
int32 CurrentFileIndex = 0;
for (; CurrentFileIndex < Files.Num(); ++CurrentFileIndex)
{
FName Name = Files[CurrentFileIndex].Get<0>();
FCacheEntryMetadata* Metadata = Files[CurrentFileIndex].Get<1>();
if ((Bucket->GetCurrentSize() + Metadata->GetCachedAssetSize()) <= Bucket->GetSize())
{
Bucket->AddMetadataEntry(Name.ToString(), Metadata, true);
}
else
{
// No space left. Stop adding entries to the bucket, and all the rest of the older files
break;
}
}
for (; CurrentFileIndex < Files.Num(); ++CurrentFileIndex)
{
FName Name = Files[CurrentFileIndex].Get<0>();
FCacheEntryMetadata* Metadata = Files[CurrentFileIndex].Get<1>();
Backend->RemoveCacheEntry(BucketName, *Name.ToString());
delete Metadata;
}
}
private:
FRuntimeAssetCacheBucket* Bucket;
FName BucketName;
FRuntimeAssetCacheFilesystemBackend* Backend;
typedef TTuple<FName, FCacheEntryMetadata*> TFilenameMetadataPair;
TArray<TFilenameMetadataPair> Files;
} Visitor(Result, BucketName, this);
IFileManager::Get().IterateDirectory(*Path, Visitor);
Visitor.Finalize();
return Result;
}