ff7tk
0.02
Toolkit for making FF7 Tools
|
#include <Lgp.h>
Public Types | |
enum | LgpError { NoError, ReadError, WriteError, OpenError, AbortError, RemoveError, RenameError, PositionError, ResizeError, PermissionsError, CopyError, InvalidError, FileNotFoundError } |
![]() | |
enum | ArchiveError { NoError, ReadError, WriteError, OpenError, AbortError, RemoveError, RenameError, PositionError, ResizeError, PermissionsError, CopyError, InvalidError, FileNotFoundError } |
Public Member Functions | |
Lgp () | |
Constructs a new empty lgp archive. More... | |
Lgp (const QString &name) | |
Constructs a new lgp archive object to represent the lgp archive with the given name. More... | |
Lgp (QFile *device) | |
Constructs a new lgp archive object to represent the lgp archive with the given device. More... | |
virtual | ~Lgp () |
Destroys the lgp archive object, closing it if necessary. More... | |
void | clear () |
Clears the contents of the lgp. More... | |
QStringList | fileList () const |
Returns a list of file paths sorted by file position. More... | |
int | fileCount () const |
Returns the number of files in the archive, or -1 if there is an error. More... | |
LgpIterator | iterator () |
Returns an iterator to iterate over the files. More... | |
bool | fileExists (const QString &filePath) const |
Returns true if the file named filePath exists; otherwise false. More... | |
QIODevice * | file (const QString &filePath) |
Returns the data for the file named filePath. More... | |
QIODevice * | modifiedFile (const QString &filePath) |
Returns the data, modified by setData if modified, for the file named filePath. More... | |
bool | setFile (const QString &filePath, QIODevice *data) |
Change the data for the file named filePath. More... | |
bool | addFile (const QString &filePath, QIODevice *data) |
Add a new file named filePath with data. More... | |
bool | removeFile (const QString &filePath) |
Remove the file named filePath. More... | |
bool | isNameValid (const QString &filePath) const |
Check if the filePath is a valid name. More... | |
bool | renameFile (const QString &filePath, const QString &newFilePath) |
Rename the file named filePath by newFilePath. More... | |
const QString & | companyName () |
Returns the company name (like "SQUARESOFT") or a null string if there is an error. More... | |
void | setCompanyName (const QString &companyName) |
Change the company name. More... | |
const QString & | productName () |
Returns the product name (like "FINAL FANTASY7") or a null string if there is an error. More... | |
void | setProductName (const QString &productName) |
Change the product name. More... | |
bool | pack (const QString &destination=QString(), ArchiveObserver *observer=NULL) |
Save the lgp into destination (or overwrite the current archive if destination is empty). More... | |
LgpError | error () const |
Returns the last error status. More... | |
void | unsetError () |
Sets the file's error to Lgp::NoError. More... | |
![]() | |
Archive () | |
Constructs a new empty archive. More... | |
Archive (const QString &filename) | |
Constructs a new archive object to represent the archive with the given filename. More... | |
Archive (QFile *device) | |
Constructs a new archive object to represent the archive with the given device. More... | |
virtual | ~Archive () |
Destroys the archive object, closing it if necessary. More... | |
QByteArray | fileData (const QString &filePath) |
Returns the data for the file named filePath. More... | |
QByteArray | modifiedFileData (const QString &filePath) |
Returns the data, modified by setData if modified, for the file named filePath. More... | |
bool | setFileData (const QString &filePath, const QByteArray &data) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Change the data for the file named filePath. More... | |
bool | addFileData (const QString &filePath, const QByteArray &data) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Add a new file named filePath with data. More... | |
virtual bool | open () |
Opens the archive, returning true if successful; otherwise false. More... | |
virtual bool | isOpen () const |
Returns true if the archive is open; returns false otherwise. More... | |
virtual void | close () |
Closes the file. More... | |
QString | fileName () const |
Returns the name set by setFileName() or to the constructors. More... | |
void | setFileName (const QString &fileName) |
Sets the name of the file. More... | |
ArchiveError | error () const |
Returns the last error status. More... | |
QString | errorString () const |
Returns the last error message. More... | |
Private Member Functions | |
bool | openHeader () |
bool | openCompanyName () |
bool | openProductName () |
LgpHeaderEntry * | headerEntry (const QString &filePath) const |
void | setError (LgpError error, const QString &errorString=QString()) |
Private Attributes | |
QString | _companyName |
LgpToc * | _files |
QString | _productName |
LgpError | _error |
Friends | |
class | LgpIterator |
Additional Inherited Members | |
![]() | |
void | setErrorString (const QString &errorString) |
void | setError (ArchiveError error, const QString &errorString=QString()) |
Sets the file's error type and text. More... | |
QFile * | archiveIO () const |
enum Lgp::LgpError |
|
explicit |
|
explicit |
|
virtual |
|
virtual |
Add a new file named filePath with data.
Returns false if the file exists; otherwise returns true.
Implements Archive.
Definition at line 277 of file Lgp.cpp.
References _files, LgpToc::addEntry(), Archive::archiveIO(), headerEntry(), and LgpHeaderEntry::setModifiedFile().
|
virtual |
Clears the contents of the lgp.
Reimplemented from Archive.
Definition at line 180 of file Lgp.cpp.
References _companyName, _files, _productName, and LgpToc::clear().
const QString & Lgp::companyName | ( | ) |
Returns the company name (like "SQUARESOFT") or a null string if there is an error.
Definition at line 350 of file Lgp.cpp.
References _companyName, and openCompanyName().
Referenced by MainWindow::on_btn_lgpSelect_clicked(), and pack().
Lgp::LgpError Lgp::error | ( | ) | const |
Returns the last error status.
Definition at line 852 of file Lgp.cpp.
References _error.
Referenced by setError().
|
virtual |
Returns the data for the file named filePath.
Implements Archive.
Definition at line 235 of file Lgp.cpp.
References Archive::archiveIO(), LgpHeaderEntry::file(), and headerEntry().
|
virtual |
Returns the number of files in the archive, or -1 if there is an error.
Implements Archive.
Definition at line 208 of file Lgp.cpp.
References _files, and LgpToc::size().
Referenced by openHeader().
|
virtual |
Returns true if the file named filePath exists; otherwise false.
Implements Archive.
Definition at line 226 of file Lgp.cpp.
References headerEntry().
|
virtual |
Returns a list of file paths sorted by file position.
Implements Archive.
Definition at line 190 of file Lgp.cpp.
References _files, LgpHeaderEntry::filePath(), LgpToc::filesSortedByPosition(), and LgpToc::isEmpty().
Referenced by MainWindow::on_btn_lgpSelect_clicked(), and MainWindow::on_btnExtractLgp_clicked().
|
private |
Definition at line 404 of file Lgp.cpp.
References _files, and LgpToc::entry().
Referenced by addFile(), file(), fileExists(), modifiedFile(), pack(), and setFile().
|
virtual |
Check if the filePath is a valid name.
Returns true if filePath is a valid name, false otherwise.
Implements Archive.
Definition at line 307 of file Lgp.cpp.
References LgpToc::isNameValid().
LgpIterator Lgp::iterator | ( | ) |
Returns an iterator to iterate over the files.
You can not know if there is an error or not.
Definition at line 217 of file Lgp.cpp.
References _files, Archive::archiveIO(), and LgpIterator.
|
virtual |
Returns the data, modified by setData if modified, for the file named filePath.
Implements Archive.
Definition at line 247 of file Lgp.cpp.
References Archive::archiveIO(), headerEntry(), and LgpHeaderEntry::modifiedFile().
Referenced by pack().
|
private |
Definition at line 321 of file Lgp.cpp.
References _companyName, Archive::archiveIO(), Archive::isOpen(), and LGP_COMPANY_NAME_SIZE.
Referenced by companyName().
|
privatevirtual |
Implements Archive.
Definition at line 409 of file Lgp.cpp.
References _files, LgpToc::addEntry(), Archive::archiveIO(), LgpToc::clear(), fileCount(), LgpConflictEntry::fileDir, LgpHeaderEntry::fileName(), InvalidError, Archive::isOpen(), LGP_COMPANY_NAME_SIZE, LOOKUP_TABLE_ENTRIES, OpenError, PositionError, ReadError, setError(), LgpHeaderEntry::setFileDir(), and LgpConflictEntry::tocIndex.
|
private |
Definition at line 367 of file Lgp.cpp.
References _productName, Archive::archiveIO(), Archive::isOpen(), and LGP_PRODUCT_NAME_SIZE.
Referenced by productName().
|
virtual |
Save the lgp into destination (or overwrite the current archive if destination is empty).
The archive is closed after this operation. observer is used to notify the progression of the save. It can be NULL.
Implements Archive.
Definition at line 578 of file Lgp.cpp.
References _files, AbortError, LgpToc::addEntry(), Archive::archiveIO(), companyName(), LgpTocEntry::conflict, LgpToc::entries(), LgpConflictEntry::fileDir, LgpHeaderEntry::fileDir(), LgpHeaderEntry::fileName(), FileNotFoundError, LgpHeaderEntry::filePath(), LgpHeaderEntry::filePosition(), LgpToc::filesSortedByPosition(), headerEntry(), LGP_COMPANY_NAME_SIZE, LGP_PRODUCT_NAME_SIZE, LOOKUP_TABLE_ENTRIES, modifiedFile(), NoError, ArchiveObserver::observerWasCanceled(), OpenError, PositionError, productName(), RemoveError, RenameError, ResizeError, setError(), LgpHeaderEntry::setFile(), Archive::setFileName(), LgpHeaderEntry::setFilePosition(), LgpHeaderEntry::setModifiedFile(), ArchiveObserver::setObserverMaximum(), ArchiveObserver::setObserverValue(), LgpToc::size(), LgpConflictEntry::tocIndex, LgpTocEntry::tocIndex, and WriteError.
const QString & Lgp::productName | ( | ) |
Returns the product name (like "FINAL FANTASY7") or a null string if there is an error.
Definition at line 387 of file Lgp.cpp.
References _productName, and openProductName().
Referenced by MainWindow::on_btn_lgpSelect_clicked(), and pack().
|
virtual |
Remove the file named filePath.
Returns true if the file is successfully removed.
Implements Archive.
Definition at line 298 of file Lgp.cpp.
References _files, and LgpToc::removeEntry().
|
virtual |
Rename the file named filePath by newFilePath.
Returns true if the file is successfully renamed.
Implements Archive.
Definition at line 316 of file Lgp.cpp.
References _files, and LgpToc::renameEntry().
void Lgp::setCompanyName | ( | const QString & | companyName | ) |
Change the company name.
Definition at line 362 of file Lgp.cpp.
References _companyName, and LGP_COMPANY_NAME_SIZE.
|
private |
Definition at line 857 of file Lgp.cpp.
References _error, error(), and Archive::setErrorString().
Referenced by openHeader(), pack(), and unsetError().
|
virtual |
Change the data for the file named filePath.
Returns false if the file doesn't exists; otherwise returns true.
Implements Archive.
Definition at line 261 of file Lgp.cpp.
References headerEntry(), and LgpHeaderEntry::setModifiedFile().
void Lgp::setProductName | ( | const QString & | productName | ) |
Change the product name.
Definition at line 399 of file Lgp.cpp.
References _productName, and LGP_PRODUCT_NAME_SIZE.
void Lgp::unsetError | ( | ) |
Sets the file's error to Lgp::NoError.
Definition at line 867 of file Lgp.cpp.
References NoError, and setError().
|
friend |
Definition at line 57 of file Lgp.h.
Referenced by iterator().
|
private |
Definition at line 106 of file Lgp.h.
Referenced by clear(), companyName(), openCompanyName(), and setCompanyName().
|
private |
Definition at line 109 of file Lgp.h.
Referenced by error(), and setError().
|
private |
Definition at line 107 of file Lgp.h.
Referenced by addFile(), clear(), fileCount(), fileList(), headerEntry(), iterator(), openHeader(), pack(), removeFile(), renameFile(), and ~Lgp().
|
private |
Definition at line 108 of file Lgp.h.
Referenced by clear(), openProductName(), productName(), and setProductName().