mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-23 02:07:45 +00:00

- Refactored datReader and several other files for code cleanliness - Enhanced runtime performance by optimizing select functions, utilizing std::string_view in place of std::string where appropriate - Removed deprecated filesystem implementation - Introduced Link Time Optimization (LTO) support for Linux builds - Enabled parallel builds for GCC/Clang compilers - Expanded and improved comments for various functions - Replaced version check failure with warning, allowing for continued use with a cautionary message Tested on MSVC/Windows and Clang/Ubuntu
66 lines
1.8 KiB
C++
66 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <filesystem>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace xiv::dat
|
|
{
|
|
|
|
class Index;
|
|
|
|
class Dat;
|
|
|
|
class File;
|
|
|
|
// A category represents an .index and its associated .datX
|
|
class Cat
|
|
{
|
|
public:
|
|
// basePath: Path to the folder containingthe datfiles
|
|
// catNum: The number of the category
|
|
// name: The name of the category, empty if not known
|
|
Cat( const std::filesystem::path& basePath, uint32_t catNum, const std::string& name );
|
|
|
|
// basePath: Path to the folder containingthe datfiles
|
|
// catNum: The number of the category
|
|
// name: The name of the category, empty if not known
|
|
// exNum: The number of the expansion to load from
|
|
// chunk: The chunk to load from
|
|
Cat( const std::filesystem::path& basePath, uint32_t catNum, const std::string& name, uint32_t exNum,
|
|
uint32_t chunk );
|
|
|
|
~Cat();
|
|
|
|
// Returns .index of the category
|
|
const Index& getIndex() const;
|
|
|
|
// Retrieve a file from the category given its hashes
|
|
std::unique_ptr< File > getFile( uint32_t dir_hash, uint32_t filename_hash ) const;
|
|
|
|
// Returns whether a file exists in the Cat based on the given directory and filename hashes
|
|
bool doesFileExist( uint32_t dir_hash, uint32_t filename_hash ) const;
|
|
|
|
// Returns whether a directory exists in the Cat based on the given directory hash
|
|
bool doesDirExist( uint32_t dir_hash ) const;
|
|
|
|
// Returns the name of the Cat object
|
|
const std::string& getName() const;
|
|
|
|
// Returns the category number of the Cat object
|
|
uint32_t getCatNum() const;
|
|
|
|
protected:
|
|
const std::string m_name;
|
|
const uint32_t m_catNum;
|
|
const uint32_t m_chunk;
|
|
|
|
// The .index
|
|
std::unique_ptr< Index > m_index;
|
|
|
|
// The .datXs such as dat nb X => m_dats[X]
|
|
std::vector< std::unique_ptr< Dat > > m_dats;
|
|
};
|
|
|
|
}
|
|
|