2021-11-27 00:53:57 +01:00
|
|
|
#pragma once
|
2018-10-24 23:31:26 +11:00
|
|
|
#include "SqPack.h"
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
2019-10-14 18:41:16 +11:00
|
|
|
#include <filesystem>
|
2018-10-24 23:31:26 +11:00
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
namespace xiv::dat
|
2018-10-24 23:31:26 +11:00
|
|
|
{
|
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
class File;
|
2018-10-24 23:31:26 +11:00
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
class Dat : public SqPack
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Full path to the dat file
|
|
|
|
Dat( const std::filesystem::path& i_path, uint32_t i_nb );
|
|
|
|
virtual ~Dat();
|
2018-10-24 23:31:26 +11:00
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
// Retrieves a file given the offset in the dat file
|
|
|
|
std::unique_ptr<File> getFile( uint32_t i_offset );
|
2018-10-24 23:31:26 +11:00
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
// Appends to the vector the data of this block, it is assumed to be preallocated
|
|
|
|
// Is it also assumed that the m_fileMutex is currently locked by this thread before the call
|
|
|
|
void extractBlock( uint32_t i_offset, std::vector<char>& o_data );
|
2018-10-24 23:31:26 +11:00
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
// Returns the dat number
|
|
|
|
uint32_t getNum() const;
|
2018-10-24 23:31:26 +11:00
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
protected:
|
|
|
|
// File reading mutex to have only one thread reading the file at a time
|
|
|
|
std::mutex m_fileMutex;
|
2018-10-24 23:31:26 +11:00
|
|
|
|
2020-02-10 14:05:04 +11:00
|
|
|
// Dat nb
|
|
|
|
uint32_t m_num;
|
|
|
|
};
|
2018-10-24 23:31:26 +11:00
|
|
|
|
|
|
|
}
|
|
|
|
|