ff7tk  0.02
Toolkit for making FF7 Tools
Archive.h
Go to the documentation of this file.
1 /****************************************************************************
2  ** Makou Reactor Final Fantasy VII Field Script Editor
3  ** Copyright (C) 2009-2013 Arzel Jérôme <myst6re@gmail.com>
4  **
5  ** This program is free software: you can redistribute it and/or modify
6  ** it under the terms of the GNU General Public License as published by
7  ** the Free Software Foundation, either version 3 of the License, or
8  ** (at your option) any later version.
9  **
10  ** This program is distributed in the hope that it will be useful,
11  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  ** GNU General Public License for more details.
14  **
15  ** You should have received a copy of the GNU General Public License
16  ** along with this program. If not, see <http://www.gnu.org/licenses/>.
17  ****************************************************************************/
18 #ifndef ARCHIVE_H
19 #define ARCHIVE_H
20 
21 #include <QtCore>
22 
24 {
26  virtual bool observerWasCanceled() const=0;
27  virtual void setObserverMaximum(unsigned int max)=0;
28  virtual void setObserverValue(int value)=0;
29 };
30 
31 class Archive
32 {
33 public:
34  enum ArchiveError {
47  FileNotFoundError
48  };
49 
50  Archive();
51  explicit Archive(const QString &filename);
52  explicit Archive(QFile *device);
53  virtual ~Archive();
54  virtual inline void clear() {}
55  virtual QStringList fileList() const=0;
56  virtual int fileCount() const=0;
57  virtual bool fileExists(const QString &filePath) const=0;
58  virtual QIODevice *file(const QString &filePath)=0;
59  QByteArray fileData(const QString &filePath);
60  virtual QIODevice *modifiedFile(const QString &filePath)=0;
61  QByteArray modifiedFileData(const QString &filePath);
62  virtual bool setFile(const QString &filePath, QIODevice *data)=0;
63  bool setFileData(const QString &filePath, const QByteArray &data);
64  virtual bool addFile(const QString &filePath, QIODevice *data)=0;
65  bool addFileData(const QString &filePath, const QByteArray &data);
66  virtual bool removeFile(const QString &filePath)=0;
67  virtual bool isNameValid(const QString &filePath) const=0;
68  virtual bool renameFile(const QString &filePath, const QString &newFilePath)=0;
69  virtual bool open();
70  virtual bool isOpen() const;
71  virtual void close();
72  QString fileName() const;
73  void setFileName(const QString &fileName);
74  virtual bool pack(const QString &destination=QString(), ArchiveObserver *observer=NULL)=0;
75  ArchiveError error() const;
76  QString errorString() const;
77 protected:
78  virtual bool openHeader()=0;
79  inline void setErrorString(const QString &errorString) {
80  _errorString = errorString;
81  }
82  void setError(ArchiveError error, const QString &errorString=QString());
83  inline QFile *archiveIO() const {
84  return _archiveIO;
85  }
86 
87 private:
88  Q_DISABLE_COPY(Archive)
89  QString _errorString;
90  ArchiveError _error;
91  QFile *_archiveIO;
92 };
93 
94 #endif // ARCHIVE_H
virtual void clear()
Definition: Archive.h:54
QFile * archiveIO() const
Definition: Archive.h:83
virtual void setObserverMaximum(unsigned int max)=0
virtual void setObserverValue(int value)=0
virtual bool observerWasCanceled() const =0
The Archive class is a device list in a file system or an archive file.
Definition: Archive.h:31
ArchiveError
Definition: Archive.h:34
void setErrorString(const QString &errorString)
Definition: Archive.h:79