ff7tk  0.02
Toolkit for making FF7 Tools
Archive Class Referenceabstract

The Archive class is a device list in a file system or an archive file. More...

#include <Archive.h>

Inheritance diagram for Archive:
Lgp

Public Types

enum  ArchiveError {
  NoError, ReadError, WriteError, OpenError,
  AbortError, RemoveError, RenameError, PositionError,
  ResizeError, PermissionsError, CopyError, InvalidError,
  FileNotFoundError
}
 

Public Member Functions

 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...
 
virtual void clear ()
 
virtual QStringList fileList () const =0
 
virtual int fileCount () const =0
 
virtual bool fileExists (const QString &filePath) const =0
 
virtual QIODevice * file (const QString &filePath)=0
 
QByteArray fileData (const QString &filePath)
 Returns the data for the file named filePath. More...
 
virtual QIODevice * modifiedFile (const QString &filePath)=0
 
QByteArray modifiedFileData (const QString &filePath)
 Returns the data, modified by setData if modified, for the file named filePath. More...
 
virtual bool setFile (const QString &filePath, QIODevice *data)=0
 
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...
 
virtual bool addFile (const QString &filePath, QIODevice *data)=0
 
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 removeFile (const QString &filePath)=0
 
virtual bool isNameValid (const QString &filePath) const =0
 
virtual bool renameFile (const QString &filePath, const QString &newFilePath)=0
 
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...
 
virtual bool pack (const QString &destination=QString(), ArchiveObserver *observer=NULL)=0
 
ArchiveError error () const
 Returns the last error status. More...
 
QString errorString () const
 Returns the last error message. More...
 

Protected Member Functions

virtual bool openHeader ()=0
 
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
 

Private Attributes

QString _errorString
 
ArchiveError _error
 
QFile * _archiveIO
 

Detailed Description

The Archive class is a device list in a file system or an archive file.

See also
QIODevice

Definition at line 31 of file Archive.h.

Member Enumeration Documentation

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

Definition at line 34 of file Archive.h.

Constructor & Destructor Documentation

Archive::Archive ( )

Constructs a new empty archive.

Definition at line 32 of file Archive.cpp.

Archive::Archive ( const QString &  filename)
explicit

Constructs a new archive object to represent the archive with the given filename.

Definition at line 40 of file Archive.cpp.

Archive::Archive ( QFile *  device)
explicit

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

Definition at line 48 of file Archive.cpp.

Archive::~Archive ( )
virtual

Destroys the archive object, closing it if necessary.

Definition at line 56 of file Archive.cpp.

References _archiveIO.

Member Function Documentation

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

Implemented in Lgp.

Referenced by addFileData().

bool Archive::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.

Returns false if the file exists; otherwise returns true.

See also
addFile()

Definition at line 116 of file Archive.cpp.

References addFile().

QFile* Archive::archiveIO ( ) const
inlineprotected
virtual void Archive::clear ( )
inlinevirtual

Reimplemented in Lgp.

Definition at line 54 of file Archive.h.

void Archive::close ( )
virtual

Closes the file.

See also
open(), isOpen()

Definition at line 149 of file Archive.cpp.

References _archiveIO.

Archive::ArchiveError Archive::error ( ) const

Returns the last error status.

See also
unsetError(), errorString()

Definition at line 189 of file Archive.cpp.

References _error.

Referenced by setError().

QString Archive::errorString ( ) const

Returns the last error message.

See also
unsetError(), error()

Definition at line 178 of file Archive.cpp.

References _errorString.

virtual QIODevice* Archive::file ( const QString &  filePath)
pure virtual

Implemented in Lgp.

Referenced by fileData().

virtual int Archive::fileCount ( ) const
pure virtual

Implemented in Lgp.

QByteArray Archive::fileData ( const QString &  filePath)

Returns the data for the file named filePath.

See also
file(), modifiedFile(), modifiedFileData()

Definition at line 65 of file Archive.cpp.

References file().

Referenced by MainWindow::on_btnExtractLgp_clicked().

virtual bool Archive::fileExists ( const QString &  filePath) const
pure virtual

Implemented in Lgp.

virtual QStringList Archive::fileList ( ) const
pure virtual

Implemented in Lgp.

QString Archive::fileName ( void  ) const

Returns the name set by setFileName() or to the constructors.

See also
setFileName(), QFile::fileName()

Definition at line 159 of file Archive.cpp.

References _archiveIO.

virtual bool Archive::isNameValid ( const QString &  filePath) const
pure virtual

Implemented in Lgp.

bool Archive::isOpen ( ) const
virtual

Returns true if the archive is open; returns false otherwise.

See also
open(), close()

Definition at line 140 of file Archive.cpp.

References _archiveIO.

Referenced by Lgp::openCompanyName(), Lgp::openHeader(), and Lgp::openProductName().

virtual QIODevice* Archive::modifiedFile ( const QString &  filePath)
pure virtual

Implemented in Lgp.

Referenced by modifiedFileData().

QByteArray Archive::modifiedFileData ( const QString &  filePath)

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

See also
file(), fileData(), modifiedFile()

Definition at line 81 of file Archive.cpp.

References modifiedFile().

bool Archive::open ( )
virtual

Opens the archive, returning true if successful; otherwise false.

See also
isOpen(), close()

Definition at line 128 of file Archive.cpp.

References _archiveIO, and openHeader().

Referenced by MainWindow::on_btn_lgpSelect_clicked().

virtual bool Archive::openHeader ( )
protectedpure virtual

Implemented in Lgp.

Referenced by open().

virtual bool Archive::pack ( const QString &  destination = QString(),
ArchiveObserver observer = NULL 
)
pure virtual

Implemented in Lgp.

virtual bool Archive::removeFile ( const QString &  filePath)
pure virtual

Implemented in Lgp.

virtual bool Archive::renameFile ( const QString &  filePath,
const QString &  newFilePath 
)
pure virtual

Implemented in Lgp.

void Archive::setError ( ArchiveError  error,
const QString &  errorString = QString() 
)
protected

Sets the file's error type and text.

See also
error(), errorString()

Definition at line 198 of file Archive.cpp.

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

void Archive::setErrorString ( const QString &  errorString)
inlineprotected

Definition at line 79 of file Archive.h.

Referenced by setError(), and Lgp::setError().

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

Implemented in Lgp.

Referenced by setFileData().

bool Archive::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.

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

See also
setFile()

Definition at line 101 of file Archive.cpp.

References setFile().

void Archive::setFileName ( const QString &  fileName)

Sets the name of the file.

Do not call this function if the file has already been opened.

See also
fileName(), QFile::setFileName()

Definition at line 169 of file Archive.cpp.

References _archiveIO.

Referenced by Lgp::pack().

Member Data Documentation

QFile* Archive::_archiveIO
private

Definition at line 91 of file Archive.h.

Referenced by close(), fileName(), isOpen(), open(), setFileName(), and ~Archive().

ArchiveError Archive::_error
private

Definition at line 90 of file Archive.h.

Referenced by error(), and setError().

QString Archive::_errorString
private

Definition at line 89 of file Archive.h.

Referenced by errorString().


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