ff7tk  0.02
Toolkit for making FF7 Tools
Lgp Class Reference

#include <Lgp.h>

Inheritance diagram for Lgp:
Archive

Public Types

enum  LgpError {
  NoError, ReadError, WriteError, OpenError,
  AbortError, RemoveError, RenameError, PositionError,
  ResizeError, PermissionsError, CopyError, InvalidError,
  FileNotFoundError
}
 
- Public Types inherited from Archive
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...
 
- Public Member Functions inherited from Archive
 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 ()
 
LgpHeaderEntryheaderEntry (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

- Protected Member Functions inherited from Archive
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
 

Detailed Description

Definition at line 55 of file Lgp.h.

Member Enumeration Documentation

Enumerator
NoError 
ReadError 
WriteError 
OpenError 
AbortError 
RemoveError 
RenameError 
PositionError 
ResizeError 
PermissionsError 
CopyError 
InvalidError 
FileNotFoundError 

Definition at line 59 of file Lgp.h.

Constructor & Destructor Documentation

Lgp::Lgp ( )

Constructs a new empty lgp archive.

Definition at line 148 of file Lgp.cpp.

Lgp::Lgp ( const QString &  name)
explicit

Constructs a new lgp archive object to represent the lgp archive with the given name.

Definition at line 156 of file Lgp.cpp.

Lgp::Lgp ( QFile *  device)
explicit

Constructs a new lgp archive object to represent the lgp archive with the given device.

Definition at line 164 of file Lgp.cpp.

Lgp::~Lgp ( )
virtual

Destroys the lgp archive object, closing it if necessary.

Definition at line 172 of file Lgp.cpp.

References _files.

Member Function Documentation

bool Lgp::addFile ( const QString &  filePath,
QIODevice *  data 
)
virtual

Add a new file named filePath with data.

Returns false if the file exists; otherwise returns true.

See also
addFileData()

Implements Archive.

Definition at line 277 of file Lgp.cpp.

References _files, LgpToc::addEntry(), Archive::archiveIO(), headerEntry(), and LgpHeaderEntry::setModifiedFile().

void Lgp::clear ( )
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.

See also
setCompanyName()

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.

See also
unsetError(), errorString()

Definition at line 852 of file Lgp.cpp.

References _error.

Referenced by setError().

QIODevice * Lgp::file ( const QString &  filePath)
virtual

Returns the data for the file named filePath.

See also
fileData(), modifiedFile(), modifiedFileData()

Implements Archive.

Definition at line 235 of file Lgp.cpp.

References Archive::archiveIO(), LgpHeaderEntry::file(), and headerEntry().

int Lgp::fileCount ( ) const
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().

bool Lgp::fileExists ( const QString &  filePath) const
virtual

Returns true if the file named filePath exists; otherwise false.

Implements Archive.

Definition at line 226 of file Lgp.cpp.

References headerEntry().

QStringList Lgp::fileList ( ) const
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().

LgpHeaderEntry * Lgp::headerEntry ( const QString &  filePath) const
private

Definition at line 404 of file Lgp.cpp.

References _files, and LgpToc::entry().

Referenced by addFile(), file(), fileExists(), modifiedFile(), pack(), and setFile().

bool Lgp::isNameValid ( const QString &  filePath) const
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.

QIODevice * Lgp::modifiedFile ( const QString &  filePath)
virtual

Returns the data, modified by setData if modified, for the file named filePath.

See also
file(), fileData(), modifiedFileData()

Implements Archive.

Definition at line 247 of file Lgp.cpp.

References Archive::archiveIO(), headerEntry(), and LgpHeaderEntry::modifiedFile().

Referenced by pack().

bool Lgp::openCompanyName ( )
private

Definition at line 321 of file Lgp.cpp.

References _companyName, Archive::archiveIO(), Archive::isOpen(), and LGP_COMPANY_NAME_SIZE.

Referenced by companyName().

bool Lgp::openProductName ( )
private

Definition at line 367 of file Lgp.cpp.

References _productName, Archive::archiveIO(), Archive::isOpen(), and LGP_PRODUCT_NAME_SIZE.

Referenced by productName().

const QString & Lgp::productName ( )

Returns the product name (like "FINAL FANTASY7") or a null string if there is an error.

See also
setProductName()

Definition at line 387 of file Lgp.cpp.

References _productName, and openProductName().

Referenced by MainWindow::on_btn_lgpSelect_clicked(), and pack().

bool Lgp::removeFile ( const QString &  filePath)
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().

bool Lgp::renameFile ( const QString &  filePath,
const QString &  newFilePath 
)
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.

See also
companyName()

Definition at line 362 of file Lgp.cpp.

References _companyName, and LGP_COMPANY_NAME_SIZE.

void Lgp::setError ( LgpError  error,
const QString &  errorString = QString() 
)
private

Definition at line 857 of file Lgp.cpp.

References _error, error(), and Archive::setErrorString().

Referenced by openHeader(), pack(), and unsetError().

bool Lgp::setFile ( const QString &  filePath,
QIODevice *  data 
)
virtual

Change the data for the file named filePath.

Returns false if the file doesn't exists; otherwise returns true.

See also
setFileData()

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.

See also
productName()

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.

See also
error(), errorString()

Definition at line 867 of file Lgp.cpp.

References NoError, and setError().

Friends And Related Function Documentation

friend class LgpIterator
friend

Definition at line 57 of file Lgp.h.

Referenced by iterator().

Member Data Documentation

QString Lgp::_companyName
private

Definition at line 106 of file Lgp.h.

Referenced by clear(), companyName(), openCompanyName(), and setCompanyName().

LgpError Lgp::_error
private

Definition at line 109 of file Lgp.h.

Referenced by error(), and setError().

LgpToc* Lgp::_files
private
QString Lgp::_productName
private

Definition at line 108 of file Lgp.h.

Referenced by clear(), openProductName(), productName(), and setProductName().


The documentation for this class was generated from the following files: