ff7tk
1.2.0.13
Work with Final Fantasy 7 game data
|
Go to the documentation of this file.
10 #include <ff7tkformats_export.h>
12 #define MAX_ISO_READ 10000
13 #define MAX_FILENAME_LENGTH 207
14 #define SEPARATOR_1 '\x2E' // .
15 #define SEPARATOR_2 '\x3B' // ;
16 #define SECTOR_SIZE 2352
17 #define SECTOR_SIZE_HEADER 24
18 #define SECTOR_SIZE_DATA 2048
19 #define SECTOR_SIZE_FOOTER 280
104 quint8 volume_set_id[128];
105 quint8 publisher_id[128];
106 quint8 preparer_id[128];
107 quint8 application_id[128];
108 quint8 copyright_file_id[37];
109 quint8 abstract_file_id[37];
110 quint8 bibliographic_file_id[37];
117 quint8 application_data[512];
131 const QString &name()
const;
132 quint32 location()
const;
133 quint32 locationAfter()
const;
134 quint32 size()
const;
135 quint32 sectorCount()
const;
136 quint32 newLocation()
const;
137 quint32 newSize()
const;
138 quint32 newSectorCount()
const;
139 void setName(
const QString &name);
140 void setLocation(quint32 location);
141 virtual bool isDirectory()
const = 0;
143 virtual bool isModified()
const;
144 virtual void applyModifications();
145 bool isSpecial()
const;
147 void setPaddingAfter(quint8 after);
148 quint8 paddingAfter()
const;
151 IsoFileOrDirectory(
const QString &name, quint32 location, quint32 size, qint64 structPosition);
161 IsoFile(
const QString &name, quint32 location, quint32 size, qint64 structPosition,
IsoArchiveIO *io);
164 QByteArray data(quint32 maxSize = 0)
const;
165 QByteArray modifiedData(quint32 maxSize = 0)
const;
166 bool extract(
const QString &destination, quint32 maxSize = 0)
const;
167 QIODevice *file()
const;
168 QIODevice *modifiedFile()
const;
169 bool setModifiedFile(QIODevice *io);
170 bool setModifiedFile(
const QByteArray &data);
175 void setFile(QIODevice *io);
177 QIODevice *_io, *_newIO;
178 bool dataChanged, _newIOMustBeRemoved;
184 IsoDirectory(
const QString &name, quint32 location, quint32 size, qint64 structPosition);
187 const QMap<QString, IsoFileOrDirectory *> &filesAndDirectories()
const;
188 QList<IsoFile *> files()
const;
189 QList<IsoDirectory *> directories()
const;
191 IsoFile *file(
const QString &path)
const;
196 QMap<QString, IsoFileOrDirectory *> _filesAndDirectories;
207 bool open(QIODevice::OpenMode mode)
override;
208 qint64 posIso()
const;
209 bool seekIso(qint64 off);
210 qint64 sizeIso()
const;
212 qint64 readIso(
char *data, qint64 maxSize);
213 QByteArray readIso(qint64 maxSize);
215 qint64 writeIso(
const char *data, qint64 maxSize);
216 qint64 writeIso(
const QByteArray &byteArray);
224 h2 = dec2Hex(quint8(
id / 75 + 2));
225 h3 = dec2Hex(quint8(
id - 75 * (hex2Dec(h2) - 2)));
227 h1 = dec2Hex(quint8((
id + 150) / 4500));
228 h2 = dec2Hex(quint8((
id + 150 - hex2Dec(h1)*4500) / 75));
229 h3 = dec2Hex(quint8(
id + 150 - hex2Dec(h1)*4500 - hex2Dec(h2)*75));
232 return QByteArray().append(
char(h1)).append(
char(h2)).append(
char(h3));
234 static inline QByteArray
buildHeader(quint32 sector, quint8 type, quint8 mode = 2)
236 return QByteArray(
"\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00", 12)
237 .append(int2Header(sector)).append(
char(mode))
238 .append(
"\x00\x00", 2).append(
char(type)).append(
'\x00')
239 .append(
"\x00\x00", 2).append(
char(type)).append(
'\x00');
247 static inline void headerInfos(
const QByteArray &header, quint8 *type, quint8 *mode =
nullptr)
251 *type = quint8(header.at(18));
254 *mode = quint8(header.at(15));
259 QByteArray sectorHeader(quint32 num);
260 QByteArray sectorFooter(quint32 num);
261 quint32 currentSector()
const;
262 quint32 sectorCount()
const;
263 static quint32 sectorCountData(quint32 dataSize);
264 bool seekToSector(quint32 num);
265 bool writeSector(
const QByteArray &data, quint8 type, quint8 mode = 2);
268 static qint64 isoPos(qint64 pos);
269 static qint64 filePos(qint64 pos);
271 static inline quint8 hex2Dec(quint8 hex)
273 return 10 * (hex / 16) + hex % 16;
275 static inline quint8 dec2Hex(quint8 dec)
277 return 16 * (dec / 10) + dec % 10;
285 bool open(OpenMode mode)
override;
286 qint64 size()
const override;
287 bool canReadLine()
const override;
289 qint64 readData(
char *data, qint64 maxSize)
override;
290 qint64 writeData(
const char *data, qint64 maxSize)
override;
304 virtual bool open(QIODevice::OpenMode mode);
307 return _io.isOpen() && _rootDirectory;
309 virtual void close();
312 return _io.fileName();
316 _io.setFileName(fileName);
320 return _io.errorString();
330 QByteArray file(
const QString &path, quint32 maxSize = 0)
const;
331 QIODevice *fileDevice(
const QString &path)
const;
332 QByteArray modifiedFile(
const QString &path, quint32 maxSize = 0)
const;
333 QIODevice *modifiedFileDevice(
const QString &path)
const;
334 bool extract(
const QString &path,
const QString &destination, quint32 maxSize = 0)
const;
335 bool extractDir(
const QString &path,
const QString &destination)
const;
336 void extractAll(
const QString &destination)
const;
337 qint32 diffCountSectors(
const QString &path, quint32 newSize)
const;
346 virtual bool reorganizeModifiedFilesAfter(QMap<quint32, const IsoFile *> &writeToTheMain, QList<const IsoFile *> &writeToTheEnd);
350 bool openVolumeDescriptor(quint8 num = 0);
351 bool openRootDirectory(quint32 sector, quint32 dataSize =
SECTOR_SIZE_DATA);
356 static int findPadding(
const QList<IsoFileOrDirectory *> &filesWithPadding, quint32 minSectorCount);
358 QList<IsoFileOrDirectory *> getIntegrity();
361 void _extractAll(
const QString &destination,
IsoDirectory *directories, QString currentInternalDir = QString())
const;
362 void _getIntegrity(QMap<quint32, IsoFileOrDirectory *> &files,
IsoDirectory *directory)
const;
363 QMap<quint32, IsoFile *> getModifiedFiles(
IsoDirectory *directory)
const;
364 void getModifiedFiles(QMap<quint32, IsoFile *> &files,
IsoDirectory *directory)
const;
367 bool writeFile(QIODevice *in, quint32 sectorCount = 0,
ArchiveObserver *control =
nullptr);
378 #ifdef ISOARCHIVE_DEBUG
379 static QString isoTimeToString(
const IsoTime &time);
382 static QString pathTableToString(
const PathTable &pathTable,
bool bigEndian =
false);
quint16 logical_block_size
Definition: IsoArchive.h:93
quint32 position
Definition: IsoArchive.h:46
quint8 second
Definition: IsoArchive.h:59
qint8 GMT
Definition: IsoArchive.h:60
Definition: IsoArchive.h:40
DirectoryRecord dr
Definition: IsoArchive.h:123
Definition: IsoArchive.h:49
Definition: IsoArchive.h:181
#define SECTOR_SIZE_DATA
Definition: IsoArchive.h:18
quint8 minute
Definition: IsoArchive.h:58
quint8 hour
Definition: IsoArchive.h:57
quint32 location_extent2
Definition: IsoArchive.h:51
quint16 volume_sequence_number
Definition: IsoArchive.h:91
Definition: IsoArchive.h:69
quint8 length_dr
Definition: IsoArchive.h:70
virtual bool open(QIODevice::OpenMode mode)
Definition: IsoArchive.cpp:576
quint16 volume_sequence_number2
Definition: IsoArchive.h:65
quint32 data_length
Definition: IsoArchive.h:52
quint32 location_extent
Definition: IsoArchive.h:43
quint32 opt_type_path_table2
Definition: IsoArchive.h:100
Definition: IsoArchive.h:297
Definition: IsoArchive.h:127
quint8 length_fi
Definition: IsoArchive.h:66
virtual bool isModified() const
Definition: IsoArchive.cpp:75
quint32 opt_type_path_table
Definition: IsoArchive.h:98
Definition: IsoArchive.h:29
IsoTime expiration_date
Definition: IsoArchive.h:113
quint8 version
Definition: IsoArchive.h:81
ArchiveError
Definition: Archive.h:25
#define SECTOR_SIZE_HEADER
Definition: IsoArchive.h:17
virtual void applyModifications()
Definition: IsoArchive.cpp:80
quint32 location_extent
Definition: IsoArchive.h:50
quint32 path_table_size2
Definition: IsoArchive.h:96
quint8 _paddingAfter
Definition: IsoArchive.h:155
QString _name
Definition: IsoArchive.h:152
virtual bool isOpen() const
Definition: IsoArchive.h:305
static QByteArray int2Header(quint32 id)
Definition: IsoArchive.h:218
Definition: IsoArchive.h:103
quint16 volume_sequence_number2
Definition: IsoArchive.h:92
quint8 unused1
Definition: IsoArchive.h:82
quint32 type_path_table2
Definition: IsoArchive.h:99
quint16 volume_set_size
Definition: IsoArchive.h:89
quint32 _size
Definition: IsoArchive.h:153
virtual bool isDirectory() const =0
QString errorString() const
Definition: IsoArchive.h:318
quint8 interleave_grap_size
Definition: IsoArchive.h:63
Definition: IsoArchive.h:199
quint32 data_length2
Definition: IsoArchive.h:53
quint8 extended_attr_record_length
Definition: IsoArchive.h:71
QString name
Definition: IsoArchive.h:45
quint8 file_flags
Definition: IsoArchive.h:61
quint16 logical_block_size2
Definition: IsoArchive.h:94
quint8 length_di
Definition: IsoArchive.h:41
#define SECTOR_SIZE_FOOTER
Definition: IsoArchive.h:19
IsoTime creation_date
Definition: IsoArchive.h:111
quint32 type_path_table
Definition: IsoArchive.h:97
VolumeDescriptor1 vd1
Definition: IsoArchive.h:122
quint32 volume_space_size
Definition: IsoArchive.h:86
quint8 extended_attr_record_length
Definition: IsoArchive.h:42
qint8 GMT
Definition: IsoArchive.h:37
quint8 day
Definition: IsoArchive.h:56
Definition: IsoArchive.h:158
quint16 volume_sequence_number
Definition: IsoArchive.h:64
Definition: IsoArchive.h:78
DirectoryRecordHead drh
Definition: IsoArchive.h:72
qint64 structPosition
Definition: IsoArchive.h:146
static QByteArray buildHeader(quint32 sector, quint8 type, quint8 mode=2)
Definition: IsoArchive.h:234
static void headerInfos(const QByteArray &header, quint8 *type, quint8 *mode=nullptr)
Definition: IsoArchive.h:247
quint16 parent_directory_number
Definition: IsoArchive.h:44
void setFileName(const QString &fileName)
Definition: IsoArchive.h:314
quint8 file_unit_size
Definition: IsoArchive.h:62
quint32 _newSize
Definition: IsoArchive.h:154
QString fileName() const
Definition: IsoArchive.h:310
Definition: IsoArchive.h:281
quint32 volume_space_size2
Definition: IsoArchive.h:87
quint16 volume_set_size2
Definition: IsoArchive.h:90
const IsoArchiveIO & io() const
Definition: IsoArchive.h:322
quint8 month
Definition: IsoArchive.h:55
quint8 type
Definition: IsoArchive.h:79
VolumeDescriptor2 vd2
Definition: IsoArchive.h:124
QString version
Definition: IsoArchive.h:74
QString name
Definition: IsoArchive.h:73
quint32 path_table_size
Definition: IsoArchive.h:95
IsoTime effective_date
Definition: IsoArchive.h:114
quint8 unused4
Definition: IsoArchive.h:116
quint8 year
Definition: IsoArchive.h:54
static QByteArray buildFooter(quint32 sector)
Definition: IsoArchive.h:241
Definition: IsoArchive.h:121
IsoTime modification_date
Definition: IsoArchive.h:112
quint8 file_structure_version
Definition: IsoArchive.h:115