447832dd81
* 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>
85 lines
4.3 KiB
C++
85 lines
4.3 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include <AzCore/IO/FileIO.h>
|
|
#include <AzCore/Memory/OSAllocator.h>
|
|
#include <AzCore/RTTI/RTTI.h>
|
|
#include <AzCore/std/containers/unordered_map.h>
|
|
#include <AzCore/std/containers/fixed_vector.h>
|
|
#include <AzCore/std/parallel/mutex.h>
|
|
|
|
|
|
namespace AZ::IO
|
|
{
|
|
inline constexpr size_t ArchiveFileIoMaxBuffersize = 16 * 1024;
|
|
struct IArchive;
|
|
//! ArchiveFileIO
|
|
//! An implementation of the FileIOBase which pipes all operations via Archive,
|
|
//! which itself pipes all operations via Local or RemoteFileIO.
|
|
//! this allows us to talk to files inside packfiles, without having to change the interface.
|
|
|
|
class ArchiveFileIO
|
|
: public AZ::IO::FileIOBase
|
|
{
|
|
public:
|
|
AZ_RTTI(ArchiveFileIO, "{679F8DB8-CC61-4BC8-ADDB-170E3D428B5D}", FileIOBase);
|
|
AZ_CLASS_ALLOCATOR(ArchiveFileIO, OSAllocator, 0);
|
|
|
|
ArchiveFileIO(IArchive* archive);
|
|
~ArchiveFileIO();
|
|
|
|
void SetArchive(IArchive* archive);
|
|
IArchive* GetArchive() const;
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////
|
|
//implementation of FileIOBase
|
|
|
|
IO::Result Open(const char* filePath, IO::OpenMode mode, IO::HandleType& fileHandle) override;
|
|
IO::Result Close(IO::HandleType fileHandle) override;
|
|
IO::Result Tell(IO::HandleType fileHandle, AZ::u64& offset) override;
|
|
IO::Result Seek(IO::HandleType fileHandle, AZ::s64 offset, IO::SeekType type) override;
|
|
IO::Result Size(IO::HandleType fileHandle, AZ::u64& size) override;
|
|
IO::Result Read(IO::HandleType fileHandle, void* buffer, AZ::u64 size, bool failOnFewerThanSizeBytesRead = false, AZ::u64* bytesRead = nullptr) override;
|
|
IO::Result Write(IO::HandleType fileHandle, const void* buffer, AZ::u64 size, AZ::u64* bytesWritten = nullptr) override;
|
|
IO::Result Flush(IO::HandleType fileHandle) override;
|
|
bool Eof(IO::HandleType fileHandle) override;
|
|
AZ::u64 ModificationTime(IO::HandleType fileHandle) override;
|
|
bool Exists(const char* filePath) override;
|
|
IO::Result Size(const char* filePath, AZ::u64& size) override;
|
|
AZ::u64 ModificationTime(const char* filePath) override;
|
|
bool IsDirectory(const char* filePath) override;
|
|
bool IsReadOnly(const char* filePath) override;
|
|
IO::Result CreatePath(const char* filePath) override;
|
|
IO::Result DestroyPath(const char* filePath) override;
|
|
IO::Result Remove(const char* filePath) override;
|
|
IO::Result Copy(const char* sourceFilePath, const char* destinationFilePath) override;
|
|
IO::Result Rename(const char* sourceFilePath, const char* destinationFilePath) override;
|
|
IO::Result FindFiles(const char* filePath, const char* filter, FindFilesCallbackType callback) override;
|
|
void SetAlias(const char* alias, const char* path) override;
|
|
void ClearAlias(const char* alias) override;
|
|
AZStd::optional<AZ::u64> ConvertToAlias(char* inOutBuffer, AZ::u64 bufferLength) const override;
|
|
bool ConvertToAlias(AZ::IO::FixedMaxPath& convertedPath, const AZ::IO::PathView& path) const override;
|
|
using FileIOBase::ConvertToAlias;
|
|
const char* GetAlias(const char* alias) const override;
|
|
bool ResolvePath(const char* path, char* resolvedPath, AZ::u64 resolvedPathSize) const override;
|
|
bool ResolvePath(AZ::IO::FixedMaxPath& resolvedPath, const AZ::IO::PathView& path) const override;
|
|
using FileIOBase::ResolvePath;
|
|
bool ReplaceAlias(AZ::IO::FixedMaxPath& replacedAliasPath, const AZ::IO::PathView& path) const override;
|
|
bool GetFilename(IO::HandleType fileHandle, char* filename, AZ::u64 filenameSize) const override;
|
|
////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
protected:
|
|
// we keep a list of file names ever opened so that we can easily return it.
|
|
mutable AZStd::recursive_mutex m_operationGuard;
|
|
AZStd::unordered_map<IO::HandleType, AZ::IO::Path> m_trackedFiles;
|
|
AZStd::fixed_vector<char, ArchiveFileIoMaxBuffersize> m_copyBuffer;
|
|
IArchive* m_archive;
|
|
};
|
|
} // namespace AZ::IO
|