Files
o3de/Code/Framework/AzFramework/AzFramework/Archive/ZipDirTree.h
T
lumberyard-employee-dm 447832dd81 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>
2021-09-16 11:01:00 -05:00

84 lines
2.9 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/Casting/numeric_cast.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/std/containers/map.h>
#include <AzCore/std/string/string_view.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
namespace AZ::IO::ZipDir
{
class FileEntryTree
{
public:
AZ_CLASS_ALLOCATOR(FileEntryTree, AZ::SystemAllocator, 0);
~FileEntryTree () {Clear(); }
// adds a file to this directory
// Function can modify szPath input
ErrorEnum Add(AZ::IO::PathView szPath, const FileEntryBase& file);
// Adds or finds the file. Returns non-initialized structure if it was added,
// or an IsInitialized() structure if it was found
// Function can modify szPath input
FileEntry* Add(AZ::IO::PathView szPath);
// returns the number of files in this tree, including this and sublevels
uint32_t NumFilesTotal() const;
// Total number of directories
uint32_t NumDirsTotal() const;
void Clear();
void Swap(FileEntryTree& rThat)
{
m_mapDirs.swap(rThat.m_mapDirs);
m_mapFiles.swap(rThat.m_mapFiles);
}
bool IsOwnerOf(const FileEntry* pFileEntry) const;
// subdirectories
using SubdirMap = AZStd::map<AZ::IO::PathView, AZStd::unique_ptr<FileEntryTree>>;
// file entries
using FileMap = AZStd::map<AZ::IO::PathView, AZStd::unique_ptr<FileEntry>>;
FileEntryTree* FindDir(AZ::IO::PathView szDirName);
ErrorEnum RemoveDir(AZ::IO::PathView szDirName);
ErrorEnum RemoveAll();
FileMap::iterator FindFile(AZ::IO::PathView szFileName);
ErrorEnum RemoveFile(AZ::IO::PathView szFileName);
// the FileEntryTree is simultaneously an entry in the dir list AND the directory header
FileEntryTree* GetDirectory()
{
return this;
}
FileMap::iterator GetFileBegin() { return m_mapFiles.begin(); }
FileMap::iterator GetFileEnd() { return m_mapFiles.end(); }
uint32_t NumFiles() const { return aznumeric_cast<uint32_t>(m_mapFiles.size()); }
SubdirMap::iterator GetDirBegin() { return m_mapDirs.begin(); }
SubdirMap::iterator GetDirEnd() { return m_mapDirs.end(); }
uint32_t NumDirs() const { return aznumeric_cast<uint32_t>(m_mapDirs.size()); }
AZStd::string_view GetFileName(FileMap::iterator it) { return it->first.Native(); }
AZStd::string_view GetDirName(SubdirMap::iterator it) { return it->first.Native(); }
FileEntry* GetFileEntry(FileMap::iterator it);
FileEntryTree* GetDirEntry(SubdirMap::iterator it);
protected:
SubdirMap m_mapDirs;
FileMap m_mapFiles;
};
}