Updated the GameApplication to mount the engine.pak (#4128)

* Updated the GameApplication to mount the engine.pak

This allows loading the autoexec.cfg and bootstrap.game.<config>.<platform>.setreg from the engine.pak files
The engine.pak is searched for in the following order: <ExecutableDirectory>/engine.pak, followed by <ProjectCacheRoot>/engine.pak

Removed a lot of unused APIs from the AZ::IO::Archive feature suite
Updated many of the AZ::IO::Archive classes to use AZ::IO::Path internally.
The logic to search for files within an Archive has been updated to use AZ::IO::Path and to remove case-insensitve string comparisons
Somehow removed the CryFile dependency on anything Cry

Updated the Settings Registry to support reading from the FileIOBase and therefore Archive files in the GameLauncher via the `SetUseFileIO` function

Removed AzFramework Dependency on md5 3rdParty library

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Linux build fix

Added an include of <stdio.h> before the <rapidxml/rapidxml.h> include as it usesnprintf.

Added `static` to the constexpr constants in ExtractFileDescription in SettingsRegistryImpl.cpp to fix clang compile issue

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Updated the case used to mount the Engine PAK file in the GameApplication to be Engine.pak to match the other locations where it is mounted

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Updated the proper FFont call to FileIOBase::Size to supply the correct
integer type of AZ::u64 instead of size_t
This fixes building on platforms where size_t is type defined to be
unsigned long

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fixed segmentation fault in Archive::Unregister when outputing the filename of the Archive file being closed

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Fix calls to OpenPack in the Legacy LevelSystem

The LevelSystem was calling the incorrect overload of OpenPack that
accepts BindRoot for the mounted level.pak instead of the overload that
that passes a memory block object.

This was causing the level pak files to be mounted using an invalid
directory, causing file accesses inside the level pak to fail.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Updated the error messages in the ZipDir CacheFactory class to use AZ_Warning directly

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Updated the ArchiveFileIO m_trackedFiles container to store mapped type as an AZ::IO::Path

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
This commit is contained in:
lumberyard-employee-dm
2021-09-16 11:01:00 -05:00
committed by GitHub
parent b95e170f9e
commit 447832dd81
57 changed files with 992 additions and 1998 deletions
+29 -95
View File
@@ -9,11 +9,11 @@
// Description : File wrapper.
#pragma once
#include <CryPath.h>
#include <ISystem.h>
#include <AzFramework/Archive/IArchive.h>
#include <IConsole.h>
#include <AzCore/Console/IConsole.h>
#include <AzCore/Interface/Interface.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/Path/Path.h>
#include <AzFramework/Archive/IArchive.h>
//////////////////////////////////////////////////////////////////////////
#define CRYFILE_MAX_PATH 260
@@ -28,7 +28,7 @@ public:
CCryFile(const char* filename, const char* mode);
~CCryFile();
bool Open(const char* filename, const char* mode, int nOpenFlagsEx = 0);
bool Open(const char* filename, const char* mode);
void Close();
// Summary:
@@ -58,15 +58,7 @@ public:
// Description:
// Retrieves the filename of the selected file.
const char* GetFilename() const { return m_filename; };
// Description:
// Retrieves the filename after adjustment to the real relative to engine root path.
// Example:
// Original filename "textures/red.dds" adjusted filename will look like "game/textures/red.dds"
// Return:
// Adjusted filename, this is a pointer to a static string, copy return value if you want to keep it.
const char* GetAdjustedFilename() const;
const char* GetFilename() const { return m_filename.c_str(); };
// Summary:
// Checks if file is opened from Archive file.
@@ -74,12 +66,11 @@ public:
// Summary:
// Gets path of archive this file is in.
const char* GetPakPath() const;
AZ::IO::PathView GetPakPath() const;
private:
char m_filename[CRYFILE_MAX_PATH];
AZ::IO::FixedMaxPath m_filename;
AZ::IO::HandleType m_fileHandle;
AZ::IO::IArchive* m_pIArchive;
};
// Summary:
@@ -87,14 +78,12 @@ private:
inline CCryFile::CCryFile()
{
m_fileHandle = AZ::IO::InvalidHandle;
m_pIArchive = gEnv ? gEnv->pCryPak : NULL;
}
//////////////////////////////////////////////////////////////////////////
inline CCryFile::CCryFile(const char* filename, const char* mode)
{
m_fileHandle = AZ::IO::InvalidHandle;
m_pIArchive = gEnv ? gEnv->pCryPak : NULL;
Open(filename, mode);
}
@@ -109,22 +98,17 @@ inline CCryFile::~CCryFile()
// For nOpenFlagsEx see IArchive::EFOpenFlags
// See also:
// IArchive::EFOpenFlags
inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlagsEx)
inline bool CCryFile::Open(const char* filename, const char* mode)
{
char tempfilename[CRYFILE_MAX_PATH] = "";
azstrcpy(tempfilename, CRYFILE_MAX_PATH, filename);
m_filename = filename;
#if !defined (_RELEASE)
if (gEnv && gEnv->IsEditor() && gEnv->pConsole)
if (auto console = AZ::Interface<AZ::IConsole>::Get(); console != nullptr)
{
ICVar* const pCvar = gEnv->pConsole->GetCVar("ed_lowercasepaths");
if (pCvar)
if (bool lowercasePaths{}; console->GetCvarValue("ed_lowercasepaths", lowercasePaths) == AZ::GetValueResult::Success)
{
const int lowercasePaths = pCvar->GetIVal();
if (lowercasePaths)
{
const AZStd::string lowerString = PathUtil::ToLower(tempfilename);
azstrcpy(tempfilename, CRYFILE_MAX_PATH, lowerString.c_str());
AZStd::to_lower(m_filename.Native().begin(), m_filename.Native().end());
}
}
}
@@ -133,16 +117,8 @@ inline bool CCryFile::Open(const char* filename, const char* mode, int nOpenFlag
{
Close();
}
azstrcpy(m_filename, CRYFILE_MAX_PATH, tempfilename);
if (m_pIArchive)
{
m_fileHandle = m_pIArchive->FOpen(tempfilename, mode, nOpenFlagsEx);
}
else
{
AZ::IO::FileIOBase::GetInstance()->Open(tempfilename, AZ::IO::GetOpenModeFromStringMode(mode), m_fileHandle);
}
AZ::IO::FileIOBase::GetInstance()->Open(m_filename.c_str(), AZ::IO::GetOpenModeFromStringMode(mode), m_fileHandle);
return m_fileHandle != AZ::IO::InvalidHandle;
}
@@ -152,27 +128,17 @@ inline void CCryFile::Close()
{
if (m_fileHandle != AZ::IO::InvalidHandle)
{
if (m_pIArchive)
{
m_pIArchive->FClose(m_fileHandle);
}
else
{
AZ::IO::FileIOBase::GetInstance()->Close(m_fileHandle);
}
AZ::IO::FileIOBase::GetInstance()->Close(m_fileHandle);
m_fileHandle = AZ::IO::InvalidHandle;
m_filename[0] = 0;
m_filename.clear();
}
}
//////////////////////////////////////////////////////////////////////////
inline size_t CCryFile::Write(const void* lpBuf, size_t nSize)
{
assert(m_fileHandle != AZ::IO::InvalidHandle);
if (m_pIArchive)
{
return m_pIArchive->FWrite(lpBuf, 1, nSize, m_fileHandle);
}
AZ_Assert(m_fileHandle != AZ::IO::InvalidHandle, "File Handle is invalid. Cannot Write");
if (AZ::IO::FileIOBase::GetInstance()->Write(m_fileHandle, lpBuf, nSize))
{
@@ -185,11 +151,7 @@ inline size_t CCryFile::Write(const void* lpBuf, size_t nSize)
//////////////////////////////////////////////////////////////////////////
inline size_t CCryFile::ReadRaw(void* lpBuf, size_t nSize)
{
assert(m_fileHandle != AZ::IO::InvalidHandle);
if (m_pIArchive)
{
return m_pIArchive->FReadRaw(lpBuf, 1, nSize, m_fileHandle);
}
AZ_Assert(m_fileHandle != AZ::IO::InvalidHandle, "File Handle is invalid. Cannot Read");
AZ::u64 bytesRead = 0;
AZ::IO::FileIOBase::GetInstance()->Read(m_fileHandle, lpBuf, nSize, false, &bytesRead);
@@ -200,11 +162,7 @@ inline size_t CCryFile::ReadRaw(void* lpBuf, size_t nSize)
//////////////////////////////////////////////////////////////////////////
inline size_t CCryFile::GetLength()
{
assert(m_fileHandle != AZ::IO::InvalidHandle);
if (m_pIArchive)
{
return m_pIArchive->FGetSize(m_fileHandle);
}
AZ_Assert(m_fileHandle != AZ::IO::InvalidHandle, "File Handle is invalid. Cannot query file length");
//long curr = ftell(m_file);
AZ::u64 size = 0;
AZ::IO::FileIOBase::GetInstance()->Size(m_fileHandle, size);
@@ -214,11 +172,7 @@ inline size_t CCryFile::GetLength()
//////////////////////////////////////////////////////////////////////////
inline size_t CCryFile::Seek(size_t seek, int mode)
{
assert(m_fileHandle != AZ::IO::InvalidHandle);
if (m_pIArchive)
{
return m_pIArchive->FSeek(m_fileHandle, long(seek), mode);
}
AZ_Assert(m_fileHandle != AZ::IO::InvalidHandle, "File Handle is invalid. Cannot seek in unopen file");
if (AZ::IO::FileIOBase::GetInstance()->Seek(m_fileHandle, seek, AZ::IO::GetSeekTypeFromFSeekMode(mode)))
{
@@ -230,45 +184,25 @@ inline size_t CCryFile::Seek(size_t seek, int mode)
//////////////////////////////////////////////////////////////////////////
inline bool CCryFile::IsInPak() const
{
if (m_fileHandle != AZ::IO::InvalidHandle && m_pIArchive)
if (auto archive = AZ::Interface<AZ::IO::IArchive>::Get();
m_fileHandle != AZ::IO::InvalidHandle && archive != nullptr)
{
return m_pIArchive->GetFileArchivePath(m_fileHandle) != NULL;
return !archive->GetFileArchivePath(m_fileHandle).empty();
}
return false;
}
//////////////////////////////////////////////////////////////////////////
inline const char* CCryFile::GetPakPath() const
inline AZ::IO::PathView CCryFile::GetPakPath() const
{
if (m_fileHandle != AZ::IO::InvalidHandle && m_pIArchive)
if (auto archive = AZ::Interface<AZ::IO::IArchive>::Get();
m_fileHandle != AZ::IO::InvalidHandle && archive != nullptr)
{
const char* sPath = m_pIArchive->GetFileArchivePath(m_fileHandle);
if (sPath != NULL)
if (AZ::IO::PathView sPath(archive->GetFileArchivePath(m_fileHandle)); sPath.empty())
{
return sPath;
}
}
return "";
return {};
}
//////////////////////////////////////////////////////////////////////////
inline const char* CCryFile::GetAdjustedFilename() const
{
static char szAdjustedFile[AZ::IO::IArchive::MaxPath];
assert(m_pIArchive);
if (!m_pIArchive)
{
return "";
}
// Gets mod path to file.
const char* gameUrl = m_pIArchive->AdjustFileName(m_filename, szAdjustedFile, AZ::IO::IArchive::MaxPath, 0);
// Returns standard path otherwise.
if (gameUrl != &szAdjustedFile[0])
{
azstrcpy(szAdjustedFile, AZ::IO::IArchive::MaxPath, gameUrl);
}
return szAdjustedFile;
}
+1
View File
@@ -19,6 +19,7 @@
#include <IConsole.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/string/conversions.h>
#include <AzCore/StringFunc/StringFunc.h>
#include "platform.h"
+14 -35
View File
@@ -10,6 +10,7 @@
#include <AzTest/AzTest.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/IO/Path/Path.h>
#include <AzFramework/Archive/INestedArchive.h>
#include <AzFramework/Archive/IArchive.h>
@@ -20,35 +21,23 @@ struct CryPakMock
MOCK_METHOD5(AdjustFileName, const char*(AZStd::string_view src, char* dst, size_t dstSize, uint32_t nFlags, bool skipMods));
MOCK_METHOD1(Init, bool(AZStd::string_view szBasePath));
MOCK_METHOD0(Release, void());
MOCK_CONST_METHOD1(IsInstalledToHDD, bool(AZStd::string_view acFilePath));
MOCK_METHOD5(OpenPack, bool(AZStd::string_view, uint32_t, AZStd::intrusive_ptr<AZ::IO::MemoryBlock>, AZStd::fixed_string<AZ::IO::IArchive::MaxPath>*, bool));
MOCK_METHOD6(OpenPack, bool(AZStd::string_view, AZStd::string_view, uint32_t, AZStd::intrusive_ptr<AZ::IO::MemoryBlock>, AZStd::fixed_string<AZ::IO::IArchive::MaxPath>*, bool));
MOCK_METHOD3(OpenPacks, bool(AZStd::string_view pWildcard, uint32_t nFlags, AZStd::vector<AZStd::fixed_string<AZ::IO::IArchive::MaxPath>>* pFullPaths));
MOCK_METHOD4(OpenPacks, bool(AZStd::string_view pBindingRoot, AZStd::string_view pWildcard, uint32_t nFlags, AZStd::vector<AZStd::fixed_string<AZ::IO::IArchive::MaxPath>>* pFullPaths));
MOCK_METHOD2(ClosePack, bool(AZStd::string_view pName, uint32_t nFlags));
MOCK_METHOD2(ClosePacks, bool(AZStd::string_view pWildcard, uint32_t nFlags));
MOCK_METHOD4(OpenPack, bool(AZStd::string_view, AZStd::intrusive_ptr<AZ::IO::MemoryBlock>, AZ::IO::FixedMaxPathString*, bool));
MOCK_METHOD5(OpenPack, bool(AZStd::string_view, AZStd::string_view, AZStd::intrusive_ptr<AZ::IO::MemoryBlock>, AZ::IO::FixedMaxPathString*, bool));
MOCK_METHOD2(OpenPacks, bool(AZStd::string_view pWildcard, AZStd::vector<AZ::IO::FixedMaxPathString>* pFullPaths));
MOCK_METHOD3(OpenPacks, bool(AZStd::string_view pBindingRoot, AZStd::string_view pWildcard, AZStd::vector<AZ::IO::FixedMaxPathString>* pFullPaths));
MOCK_METHOD1(ClosePack, bool(AZStd::string_view pName));
MOCK_METHOD1(ClosePacks, bool(AZStd::string_view pWildcard));
MOCK_METHOD1(FindPacks, bool(AZStd::string_view pWildcardIn));
MOCK_METHOD3(SetPacksAccessible, bool(bool bAccessible, AZStd::string_view pWildcard, uint32_t nFlags));
MOCK_METHOD3(SetPackAccessible, bool(bool bAccessible, AZStd::string_view pName, uint32_t nFlags));
MOCK_METHOD3(LoadPakToMemory, bool(AZStd::string_view pName, EInMemoryArchiveLocation eLoadToMemory, AZStd::intrusive_ptr<AZ::IO::MemoryBlock> pMemoryBlock));
MOCK_METHOD2(LoadPaksToMemory, void(int nMaxPakSize, bool bLoadToMemory));
MOCK_METHOD1(GetMod, const char*(int index));
MOCK_METHOD1(ParseAliases, void(AZStd::string_view szCommandLine));
MOCK_METHOD3(SetAlias, void(AZStd::string_view szName, AZStd::string_view szAlias, bool bAdd));
MOCK_METHOD2(GetAlias, const char*(AZStd::string_view szName, bool bReturnSame));
MOCK_METHOD0(Lock, void());
MOCK_METHOD0(Unlock, void());
MOCK_METHOD2(SetPacksAccessible, bool(bool bAccessible, AZStd::string_view pWildcard));
MOCK_METHOD2(SetPackAccessible, bool(bool bAccessible, AZStd::string_view pName));
MOCK_METHOD1(SetLocalizationFolder, void(AZStd::string_view sLocalizationFolder));
MOCK_CONST_METHOD0(GetLocalizationFolder, const char*());
MOCK_CONST_METHOD0(GetLocalizationRoot, const char*());
MOCK_METHOD3(FOpen, AZ::IO::HandleType(AZStd::string_view pName, const char* mode, uint32_t nFlags));
MOCK_METHOD4(FReadRaw, size_t(void* data, size_t length, size_t elems, AZ::IO::HandleType handle));
MOCK_METHOD3(FReadRawAll, size_t(void* data, size_t nFileSize, AZ::IO::HandleType handle));
MOCK_METHOD2(FGetCachedFileData, void*(AZ::IO::HandleType handle, size_t & nFileSize));
MOCK_METHOD4(FWrite, size_t(const void* data, size_t length, size_t elems, AZ::IO::HandleType handle));
MOCK_METHOD3(FGets, char*(char*, int, AZ::IO::HandleType));
MOCK_METHOD1(Getc, int(AZ::IO::HandleType));
MOCK_METHOD2(FOpen, AZ::IO::HandleType(AZStd::string_view pName, const char* mode));
MOCK_METHOD2(FGetCachedFileData, void*(AZ::IO::HandleType handle, size_t& nFileSize));
MOCK_METHOD3(FRead, size_t(void* data, size_t bytesToRead, AZ::IO::HandleType handle));
MOCK_METHOD3(FWrite, size_t(const void* data, size_t bytesToWrite, AZ::IO::HandleType handle));
MOCK_METHOD1(FGetSize, size_t(AZ::IO::HandleType f));
MOCK_METHOD2(FGetSize, size_t(AZStd::string_view pName, bool bAllowUseFileSystem));
MOCK_METHOD1(IsInPak, bool(AZ::IO::HandleType handle));
@@ -70,9 +59,8 @@ struct CryPakMock
MOCK_METHOD2(IsFileExist, bool(AZStd::string_view sFilename, EFileSearchLocation));
MOCK_METHOD1(IsFolder, bool(AZStd::string_view sPath));
MOCK_METHOD1(GetFileSizeOnDisk, AZ::IO::IArchive::SignedFileSize(AZStd::string_view filename));
MOCK_METHOD1(MakeDir, bool(AZStd::string_view szPath));
MOCK_METHOD4(OpenArchive, AZStd::intrusive_ptr<AZ::IO::INestedArchive> (AZStd::string_view szPath, AZStd::string_view bindRoot, uint32_t nFlags, AZStd::intrusive_ptr<AZ::IO::MemoryBlock> pData));
MOCK_METHOD1(GetFileArchivePath, const char* (AZ::IO::HandleType f));
MOCK_METHOD1(GetFileArchivePath, AZ::IO::PathView (AZ::IO::HandleType f));
MOCK_METHOD5(RawCompress, int(const void* pUncompressed, size_t* pDestSize, void* pCompressed, size_t nSrcSize, int nLevel));
MOCK_METHOD4(RawUncompress, int(void* pUncompressed, size_t* pDestSize, const void* pCompressed, size_t nSrcSize));
MOCK_METHOD1(RecordFileOpen, void(ERecordFileOpenList eList));
@@ -80,24 +68,15 @@ struct CryPakMock
MOCK_METHOD1(GetResourceList, AZ::IO::IResourceList * (ERecordFileOpenList eList));
MOCK_METHOD2(SetResourceList, void(ERecordFileOpenList eList, AZ::IO::IResourceList * pResourceList));
MOCK_METHOD0(GetRecordFileOpenList, AZ::IO::IArchive::ERecordFileOpenList());
MOCK_METHOD2(ComputeCRC, uint32_t(AZStd::string_view szPath, uint32_t nFileOpenFlags));
MOCK_METHOD4(ComputeMD5, bool(AZStd::string_view szPath, uint8_t* md5, uint32_t nFileOpenFlags, bool useDirectAccess));
MOCK_METHOD1(RegisterFileAccessSink, void(AZ::IO::IArchiveFileAccessSink * pSink));
MOCK_METHOD1(UnregisterFileAccessSink, void(AZ::IO::IArchiveFileAccessSink * pSink));
MOCK_METHOD1(DisableRuntimeFileAccess, void(bool status));
MOCK_METHOD2(DisableRuntimeFileAccess, bool(bool status, AZStd::thread_id threadId));
MOCK_METHOD2(CheckFileAccessDisabled, bool(AZStd::string_view name, const char* mode));
MOCK_METHOD1(SetRenderThreadId, void(AZStd::thread_id renderThreadId));
MOCK_CONST_METHOD0(GetPakPriority, AZ::IO::ArchiveLocationPriority());
MOCK_CONST_METHOD1(GetFileOffsetOnMedia, uint64_t(AZStd::string_view szName));
MOCK_CONST_METHOD1(GetFileMediaType, EStreamSourceMediaType(AZStd::string_view szName));
MOCK_METHOD0(GetLevelPackOpenEvent, auto()->LevelPackOpenEvent*);
MOCK_METHOD0(GetLevelPackCloseEvent, auto()->LevelPackCloseEvent*);
// Implementations required for variadic functions
virtual int FPrintf([[maybe_unused]] AZ::IO::HandleType handle, [[maybe_unused]] const char* format, ...) PRINTF_PARAMS(3, 4)
{
return 0;
}
};
+3 -3
View File
@@ -91,15 +91,15 @@ bool CConsoleBatchFile::ExecuteConfigFile(const char* sFilename)
AZStd::string filenameLog;
AZStd::string sfn = PathUtil::GetFile(filename);
if (file.Open(filename.c_str(), "rb", AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK))
if (file.Open(filename.c_str(), "rb"))
{
filenameLog = AZStd::string("game/") + sfn;
}
else if (file.Open((AZStd::string("config/") + sfn).c_str(), "rb", AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK))
else if (file.Open((AZStd::string("config/") + sfn).c_str(), "rb"))
{
filenameLog = AZStd::string("game/config/") + sfn;
}
else if (file.Open((AZStd::string("./") + sfn).c_str(), "rb", AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK))
else if (file.Open((AZStd::string("./") + sfn).c_str(), "rb"))
{
filenameLog = AZStd::string("./") + sfn;
}
@@ -50,12 +50,11 @@ bool CLevelInfo::OpenLevelPak()
return false;
}
AZStd::string levelpak(m_levelPath);
levelpak += "/level.pak";
AZStd::fixed_string<AZ::IO::IArchive::MaxPath> fullLevelPakPath;
bool bOk = gEnv->pCryPak->OpenPack(
levelpak.c_str(), m_isPak ? AZ::IO::IArchive::FLAGS_LEVEL_PAK_INSIDE_PAK : (unsigned)0, NULL, &fullLevelPakPath, false);
m_levelPakFullPath.assign(fullLevelPakPath.c_str());
AZ::IO::Path levelPak(m_levelPath);
levelPak /= "level.pak";
AZ::IO::FixedMaxPathString fullLevelPakPath;
bool bOk = gEnv->pCryPak->OpenPack(levelPak.Native(), nullptr, &fullLevelPakPath, false);
m_levelPakFullPath.assign(fullLevelPakPath.c_str(), fullLevelPakPath.size());
return bOk;
}
@@ -74,7 +73,7 @@ void CLevelInfo::CloseLevelPak()
if (!m_levelPakFullPath.empty())
{
gEnv->pCryPak->ClosePack(m_levelPakFullPath.c_str(), AZ::IO::IArchive::FLAGS_PATH_REAL);
gEnv->pCryPak->ClosePack(m_levelPakFullPath.c_str());
m_levelPakFullPath.clear();
}
}
@@ -324,8 +323,7 @@ void CLevelSystem::ScanFolder(const char* subfolder, bool modFolder)
// Open all the available paks found in the levels folder
for (auto iter = pakList.begin(); iter != pakList.end(); iter++)
{
AZStd::fixed_string<AZ::IO::IArchive::MaxPath> fullLevelPakPath;
gEnv->pCryPak->OpenPack(iter->c_str(), (unsigned)0, nullptr, &fullLevelPakPath, false);
gEnv->pCryPak->OpenPack(iter->c_str(), nullptr, nullptr, false);
}
// Levels in bundles now take priority over levels outside of bundles.
+9 -9
View File
@@ -272,14 +272,12 @@ static bool ParseSystemConfig(const AZStd::string& strSysConfigFilePath, ILoadCo
CCryFile file;
AZStd::string filenameLog;
{
int flags = AZ::IO::IArchive::FOPEN_HINT_QUIET | AZ::IO::IArchive::FOPEN_ONDISK;
if (filename[0] == '@')
{
// this is used when theres a very specific file to read, like @user@/game.cfg which is read
// IN ADDITION to the one in the game folder, and afterwards to override values in it.
// if the file is missing and its already prefixed with an alias, there is no need to look any further.
if (!(file.Open(filename.c_str(), "rb", flags)))
if (!(file.Open(filename.c_str(), "rb")))
{
if (warnIfMissing)
{
@@ -293,11 +291,11 @@ static bool ParseSystemConfig(const AZStd::string& strSysConfigFilePath, ILoadCo
// otherwise, if the file isn't prefixed with an alias, then its likely one of the convenience mappings
// to either root or assets/config. this is done so that code can just request a simple file name and get its data
if (
!(file.Open(filename.c_str(), "rb", flags)) &&
!(file.Open((AZStd::string("@root@/") + filename).c_str(), "rb", flags)) &&
!(file.Open((AZStd::string("@assets@/") + filename).c_str(), "rb", flags)) &&
!(file.Open((AZStd::string("@assets@/config/") + filename).c_str(), "rb", flags)) &&
!(file.Open((AZStd::string("@assets@/config/spec/") + filename).c_str(), "rb", flags))
!(file.Open(filename.c_str(), "rb")) &&
!(file.Open((AZStd::string("@root@/") + filename).c_str(), "rb")) &&
!(file.Open((AZStd::string("@assets@/") + filename).c_str(), "rb")) &&
!(file.Open((AZStd::string("@assets@/config/") + filename).c_str(), "rb")) &&
!(file.Open((AZStd::string("@assets@/config/spec/") + filename).c_str(), "rb"))
)
{
if (warnIfMissing)
@@ -308,7 +306,9 @@ static bool ParseSystemConfig(const AZStd::string& strSysConfigFilePath, ILoadCo
}
}
filenameLog = file.GetAdjustedFilename();
AZ::IO::FixedMaxPath resolvedFilePath;
AZ::IO::FileIOBase::GetInstance()->ResolvePath(resolvedFilePath, file.GetFilename());
filenameLog = resolvedFilePath.String();
}
INDENT_LOG_DURING_SCOPE();
+1 -25
View File
@@ -588,25 +588,6 @@ bool CSystem::InitFileSystem()
m_env.pCryPak->RecordFileOpen(AZ::IO::IArchive::RFOM_EngineStartup);
}
//init crypak
if (m_env.pCryPak->Init(""))
{
#if !defined(_RELEASE)
const ICmdLineArg* pakalias = m_pCmdLine->FindArg(eCLAT_Pre, "pakalias");
#else
const ICmdLineArg* pakalias = nullptr;
#endif // !defined(_RELEASE)
if (pakalias && strlen(pakalias->GetValue()) > 0)
{
m_env.pCryPak->ParseAliases(pakalias->GetValue());
}
}
else
{
AZ_Assert(false, "Failed to initialize CryPak.");
return false;
}
// Now that file systems are init, we will clear any events that have arrived
// during file system init, so that systems do not reload assets that were already compiled in the
// critical compilation section.
@@ -844,9 +825,6 @@ void CSystem::OpenBasicPaks()
#endif //AZ_PLATFORM_ANDROID
InlineInitializationProcessing("CSystem::OpenBasicPaks OpenPacks( Engine... )");
// Load paks required for game init to mem
gEnv->pCryPak->LoadPakToMemory("Engine.pak", AZ::IO::IArchive::eInMemoryPakLocale_GPU);
}
//////////////////////////////////////////////////////////////////////////
@@ -891,8 +869,6 @@ void CSystem::OpenLanguageAudioPak([[maybe_unused]] const char* sLanguage)
// Initialize languages.
int nPakFlags = 0;
// Omit the trailing slash!
AZStd::string sLocalizationFolder(AZStd::string().assign(PathUtil::GetLocalizationFolder(), 0, PathUtil::GetLocalizationFolder().size() - 1));
@@ -904,7 +880,7 @@ void CSystem::OpenLanguageAudioPak([[maybe_unused]] const char* sLanguage)
// load localized pak with crc32 filenames on consoles to save memory.
AZStd::string sLocalizedPath = "loc.pak";
if (!m_env.pCryPak->OpenPacks(sLocalizationFolder.c_str(), sLocalizedPath.c_str(), nPakFlags))
if (!m_env.pCryPak->OpenPacks(sLocalizationFolder.c_str(), sLocalizedPath.c_str()))
{
// make sure the localized language is found - not really necessary, for TC
AZ_Error(AZ_TRACE_SYSTEM_WINDOW, false, "Localized language content(%s) not available or modified from the original installation.", sLanguage);
@@ -101,8 +101,11 @@ LONG WINAPI CryEngineExceptionFilterWER(struct _EXCEPTION_POINTERS* pExceptionPo
{
if (g_cvars.sys_WER > 1)
{
char szScratch [_MAX_PATH];
const char* szDumpPath = gEnv->pCryPak->AdjustFileName("@log@/CE2Dump.dmp", szScratch, AZ_ARRAY_SIZE(szScratch), 0);
AZ::IO::FixedMaxPath dumpPath{ "@log@/CE2Dump.dmp" };
if (auto fileIoBase = AZ::IO::FileIOBase::GetInstance(); fileIoBase != nullptr)
{
dumpPath = fileIoBase->ResolvePath(dumpPath, "@log@/CE2Dump.dmp");
}
MINIDUMP_TYPE mdumpValue = (MINIDUMP_TYPE)(MiniDumpNormal);
if (g_cvars.sys_WER > 1)
@@ -110,7 +113,7 @@ LONG WINAPI CryEngineExceptionFilterWER(struct _EXCEPTION_POINTERS* pExceptionPo
mdumpValue = (MINIDUMP_TYPE)(g_cvars.sys_WER - 2);
}
return CryEngineExceptionFilterMiniDump(pExceptionPointers, szDumpPath, mdumpValue);
return CryEngineExceptionFilterMiniDump(pExceptionPointers, dumpPath.c_str(), mdumpValue);
}
LONG lRet = EXCEPTION_CONTINUE_SEARCH;
+2 -2
View File
@@ -257,12 +257,12 @@ public:
void Set(const char* s) override;
void Set(float f) override
{
stack_string s = stack_string::format("%g", f);
AZStd::fixed_string<32> s = AZStd::fixed_string<32>::format("%g", f);
Set(s.c_str());
}
void Set(int i) override
{
stack_string s = stack_string::format("%d", i);
AZStd::fixed_string<32> s = AZStd::fixed_string<32>::format("%d", i);
Set(s.c_str());
}
int GetType() override { return CVAR_STRING; }
+1 -1
View File
@@ -169,7 +169,7 @@ public:
{
if (m_fileHandle != AZ::IO::InvalidHandle)
{
gEnv->pCryPak->FWrite(pData, size, 1, m_fileHandle);
gEnv->pCryPak->FWrite(pData, size, m_fileHandle);
}
}
private:
+18 -7
View File
@@ -948,10 +948,12 @@ void CXmlNode::AddToXmlString(XmlString& xml, int level, AZ::IO::HandleType file
{
if (fileHandle != AZ::IO::InvalidHandle && chunkSize > 0)
{
auto fileIoBase = AZ::IO::FileIOBase::GetInstance();
AZ_Assert(fileIoBase != nullptr, "FileIOBase is expected to be initialized for CXmlNode");
size_t len = xml.length();
if (len >= chunkSize)
{
gEnv->pCryPak->FWrite(xml.c_str(), len, 1, fileHandle);
fileIoBase->Write(fileHandle, xml.c_str(), len);
xml.assign (""); // should not free memory and does not!
}
}
@@ -1258,7 +1260,8 @@ bool CXmlNode::saveToFile([[maybe_unused]] const char* fileName, size_t chunkSiz
XmlString xml;
xml.assign ("");
xml.reserve(chunkSize * 2); // we reserve double memory, as writing in chunks is not really writing in fixed blocks but a bit fuzzy
auto pCryPak = gEnv->pCryPak;
auto fileIoBase = AZ::IO::FileIOBase::GetInstance();
AZ_Assert(fileIoBase != nullptr, "FileIOBase is expected to be initialized for CXmlNode");
if (fileHandle == AZ::IO::InvalidHandle)
{
return false;
@@ -1267,7 +1270,7 @@ bool CXmlNode::saveToFile([[maybe_unused]] const char* fileName, size_t chunkSiz
size_t len = xml.length();
if (len > 0)
{
pCryPak->FWrite(xml.c_str(), len, 1, fileHandle);
fileIoBase->Write(fileHandle, xml.c_str(), len);
}
xml.clear(); // xml.resize(0) would not reclaim memory
return true;
@@ -1639,10 +1642,18 @@ XmlNodeRef XmlParserImp::ParseFile(const char* filename, XmlString& errorString,
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_WARNING, "%s", str);
return 0;
}
adjustedFilename = xmlFile.GetAdjustedFilename();
AZStd::replace(adjustedFilename.begin(), adjustedFilename.end(), '\\', '/');
pakPath = xmlFile.GetPakPath();
AZStd::replace(pakPath.begin(), pakPath.end(), '\\', '/');
AZ::IO::FixedMaxPath resolvedPath(AZ::IO::PosixPathSeparator);
auto fileIoBase = AZ::IO::FileIOBase::GetInstance();
AZ_Assert(fileIoBase != nullptr, "FileIOBase is expected to be initialized for CXmlNode");
if (fileIoBase->ResolvePath(resolvedPath, xmlFile.GetFilename()))
{
adjustedFilename = resolvedPath.MakePreferred().Native();
}
if (fileIoBase->ResolvePath(resolvedPath, xmlFile.GetPakPath()))
{
pakPath = resolvedPath.MakePreferred().Native();
}
}
XMLBinary::XMLBinaryReader reader;