Files
UnrealEngineUWP/Engine/Source/Runtime/StorageServerClient/Private/StorageServerPlatformFile.h
zousar shaker 0832797d28 Ensure that Zen ProjectIds are unique for projects with the same name in differing roots (or in the same root) while attempting to maintain some easily recognizable desriptors for the project.
Staged builds are explicitly assigned a project id via the persistent UECommandline.txt file.  This works on mobile/consoles, but isn't implemented for Windows/Linux/Mac, so staged builds for those platforms don't have a persistent assignment of project id and instead rely on the launch by the editor including the appropriate commandlines.
Unstaged builds on Windows/Mac/Linux now determine project id independently after they have determined the project file path.  This happens after the project file has been determined and has had case corrected.  This ensures it is different/unique for multiple blueprint projects that share the same executable.
Fix a bug where second cook in editor to zen would stall because the queue thinks all additions are finished due to a boolean that isn't reset.

#rb devin.doucette
#rb per.larsson
#preflight 61b39a35a2562c8b1c40f81e

#ROBOMERGE-AUTHOR: zousar.shaker
#ROBOMERGE-SOURCE: CL 18432317 in //UE5/Release-5.0/... via CL 18435404
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v897-18405271)

[CL 18435895 by zousar shaker in ue5-release-engine-test branch]
2021-12-10 18:06:39 -05:00

123 lines
4.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GenericPlatform/GenericPlatformFile.h"
#include "Containers/StringView.h"
#include "IO/IoDispatcher.h"
#if !UE_BUILD_SHIPPING
class FStorageServerFileHandle;
class FStorageServerConnection;
class IPackageStore;
#if WITH_COTF
namespace UE::Cook
{
class FCookOnTheFlyMessage;
}
#endif
class FStorageServerFileSystemTOC
{
public:
~FStorageServerFileSystemTOC();
void AddFile(const FIoChunkId& FileChunkId, FStringView Path);
bool FileExists(const FString& Path);
bool DirectoryExists(const FString& Path);
const FIoChunkId* GetFileChunkId(const FString& Path);
bool IterateDirectory(const FString& Path, TFunctionRef<bool(const FIoChunkId&, const TCHAR*)> Callback);
private:
struct FDirectory
{
TArray<FString> Directories;
TArray<int32> Files;
};
struct FFile
{
FIoChunkId FileChunkId;
FString FilePath;
};
FDirectory* AddDirectoriesRecursive(const FString& DirectoryPath);
FDirectory Root;
TMap<FString, FDirectory*> Directories;
TMap<FString, int32> FilePathToIndexMap;
TArray<FFile> Files;
FRWLock TocLock;
};
class FStorageServerPlatformFile
: public IPlatformFile
{
public:
FStorageServerPlatformFile();
virtual ~FStorageServerPlatformFile();
virtual bool ShouldBeUsed(IPlatformFile* Inner, const TCHAR* CmdLine) const override;
virtual bool Initialize(IPlatformFile* Inner, const TCHAR* CmdLine) override;
virtual void InitializeAfterProjectFilePath() override;
virtual IPlatformFile* GetLowerLevel() override
{
return LowerLevel;
}
virtual void SetLowerLevel(IPlatformFile* NewLowerLevel) override
{
LowerLevel = NewLowerLevel;
}
virtual const TCHAR* GetName() const override
{
return TEXT("StorageServer");
}
virtual bool FileExists(const TCHAR* Filename) override;
virtual int64 FileSize(const TCHAR* Filename) override;
virtual bool IsReadOnly(const TCHAR* Filename) override;
virtual FDateTime GetTimeStamp(const TCHAR* Filename) override;
virtual FDateTime GetAccessTimeStamp(const TCHAR* Filename) override;
virtual IFileHandle* OpenRead(const TCHAR* Filename, bool bAllowWrite = false) override;
virtual bool DirectoryExists(const TCHAR* Directory) override;
virtual FFileStatData GetStatData(const TCHAR* FilenameOrDirectory) override;
virtual bool IterateDirectory(const TCHAR* Directory, FDirectoryVisitor& Visitor) override;
virtual bool IterateDirectoryStat(const TCHAR* Directory, FDirectoryStatVisitor& Visitor) override;
virtual FString GetFilenameOnDisk(const TCHAR* Filename) override;
virtual bool DeleteFile(const TCHAR* Filename) override;
virtual bool MoveFile(const TCHAR* To, const TCHAR* From) override;
virtual bool SetReadOnly(const TCHAR* Filename, bool bNewReadOnlyValue) override;
virtual void SetTimeStamp(const TCHAR* Filename, FDateTime DateTime) override;
virtual IFileHandle* OpenWrite(const TCHAR* Filename, bool bAppend = false, bool bAllowRead = false) override;
virtual bool CreateDirectory(const TCHAR* Directory) override;
virtual bool DeleteDirectory(const TCHAR* Directory) override;
private:
friend class FStorageServerFileHandle;
bool MakeStorageServerPath(const TCHAR* LocalFilenameOrDirectory, FStringBuilderBase& OutPath) const;
bool MakeLocalPath(const TCHAR* ServerFilenameOrDirectory, FStringBuilderBase& OutPath) const;
IFileHandle* InternalOpenFile(const FIoChunkId& FileChunkId, const TCHAR* LocalFilename);
bool SendGetFileListMessage();
FFileStatData SendGetStatDataMessage(const FIoChunkId& FileChunkId);
int64 SendReadMessage(uint8* Destination, const FIoChunkId& FileChunkId, int64 Offset, int64 BytesToRead);
#if WITH_COTF
void OnCookOnTheFlyMessage(const UE::Cook::FCookOnTheFlyMessage& Message);
#endif
IPlatformFile* LowerLevel = nullptr;
FStringView ServerEngineDirView = FStringView(TEXT("/{engine}/"));
FStringView ServerProjectDirView = FStringView(TEXT("/{project}/"));
TUniquePtr<FStorageServerConnection> Connection;
FStorageServerFileSystemTOC ServerToc;
FString ServerProject;
FString ServerPlatform;
mutable TArray<FString> HostAddrs;
};
#endif