67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
#ifndef COALESCED_H
|
|
#define COALESCED_H
|
|
|
|
#include <QString>
|
|
#include <QByteArray>
|
|
#include <QList>
|
|
|
|
struct IniEntry {
|
|
QString filename; // Relative path stored in file
|
|
QByteArray content; // Raw INI content
|
|
};
|
|
|
|
class CoalescedFile {
|
|
public:
|
|
CoalescedFile();
|
|
|
|
// Load and parse a coalesced file
|
|
bool load(const QString& path);
|
|
|
|
// Write back to coalesced format
|
|
bool save(const QString& path) const;
|
|
|
|
// Get list of contained files
|
|
QList<IniEntry> entries() const;
|
|
|
|
// Get entry by index
|
|
const IniEntry* entry(int index) const;
|
|
|
|
// Get entry by filename
|
|
const IniEntry* entry(const QString& filename) const;
|
|
|
|
// Check if loaded file is coalesced format
|
|
bool isCoalesced() const;
|
|
|
|
// Get number of entries
|
|
int count() const;
|
|
|
|
// Get total content size
|
|
qint64 totalSize() const;
|
|
|
|
// Get the path of the loaded file
|
|
QString loadedPath() const;
|
|
|
|
// Clear loaded data
|
|
void clear();
|
|
|
|
// Get last error message
|
|
QString lastError() const;
|
|
|
|
// Static check if file is coalesced format without full parse
|
|
static bool isCoalescedFile(const QString& path);
|
|
|
|
// Pack a directory of INI files into this object
|
|
bool packDirectory(const QString& dirPath, const QString& basePath = QString());
|
|
|
|
private:
|
|
QList<IniEntry> m_entries;
|
|
QString m_loadedPath;
|
|
QString m_lastError;
|
|
bool m_isCoalesced;
|
|
quint32 m_version; // Header value (often 0x1e for UE3)
|
|
|
|
void setError(const QString& error);
|
|
};
|
|
|
|
#endif // COALESCED_H
|