Qt 4.8
qabstractfileengine.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QABSTRACTFILEENGINE_H
43 #define QABSTRACTFILEENGINE_H
44 
45 #include <QtCore/qdir.h>
46 
47 #ifdef open
48 #error qabstractfileengine.h must be included before any header file that defines open
49 #endif
50 
52 
54 
55 QT_MODULE(Core)
56 
57 class QFileExtension;
58 class QFileExtensionResult;
59 class QVariant;
62 
64 {
65 public:
66  enum FileFlag {
67  //perms (overlaps the QFile::Permission)
68  ReadOwnerPerm = 0x4000, WriteOwnerPerm = 0x2000, ExeOwnerPerm = 0x1000,
69  ReadUserPerm = 0x0400, WriteUserPerm = 0x0200, ExeUserPerm = 0x0100,
70  ReadGroupPerm = 0x0040, WriteGroupPerm = 0x0020, ExeGroupPerm = 0x0010,
71  ReadOtherPerm = 0x0004, WriteOtherPerm = 0x0002, ExeOtherPerm = 0x0001,
72 
73  //types
74  LinkType = 0x10000,
75  FileType = 0x20000,
76  DirectoryType = 0x40000,
77  BundleType = 0x80000,
78 
79  //flags
80  HiddenFlag = 0x0100000,
81  LocalDiskFlag = 0x0200000,
82  ExistsFlag = 0x0400000,
83  RootFlag = 0x0800000,
84  Refresh = 0x1000000,
85 
86  //masks
87  PermsMask = 0x0000FFFF,
88  TypesMask = 0x000F0000,
89  FlagsMask = 0x0FF00000,
90  FileInfoAll = FlagsMask | PermsMask | TypesMask
91  };
92  Q_DECLARE_FLAGS(FileFlags, FileFlag)
93 
94  enum FileName {
104  NFileNames = 9
105  };
106  enum FileOwner {
108  OwnerGroup
109  };
110  enum FileTime {
113  AccessTime
114  };
115 
116  virtual ~QAbstractFileEngine();
117 
118  virtual bool open(QIODevice::OpenMode openMode);
119  virtual bool close();
120  virtual bool flush();
121  virtual qint64 size() const;
122  virtual qint64 pos() const;
123  virtual bool seek(qint64 pos);
124  virtual bool isSequential() const;
125  virtual bool remove();
126  virtual bool copy(const QString &newName);
127  virtual bool rename(const QString &newName);
128  virtual bool link(const QString &newName);
129  virtual bool mkdir(const QString &dirName, bool createParentDirectories) const;
130  virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const;
131  virtual bool setSize(qint64 size);
132  virtual bool caseSensitive() const;
133  virtual bool isRelativePath() const;
134  virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const;
135  virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const;
136  virtual bool setPermissions(uint perms);
137  virtual QString fileName(FileName file=DefaultName) const;
138  virtual uint ownerId(FileOwner) const;
139  virtual QString owner(FileOwner) const;
140  virtual QDateTime fileTime(FileTime time) const;
141  virtual void setFileName(const QString &file);
142  virtual int handle() const;
143  bool atEnd() const;
144  uchar *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags);
145  bool unmap(uchar *ptr);
146 
148  virtual Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames);
149  virtual Iterator *endEntryList();
150 
151  virtual qint64 read(char *data, qint64 maxlen);
152  virtual qint64 readLine(char *data, qint64 maxlen);
153  virtual qint64 write(const char *data, qint64 len);
154 
155  QFile::FileError error() const;
156  QString errorString() const;
157 
158  enum Extension {
162  UnMapExtension
163  };
165  {};
167  {};
168 
170  public:
174  };
176  public:
178  };
179 
181  public:
183  };
184 
185  virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0);
186  virtual bool supportsExtension(Extension extension) const;
187 
188  // Factory
189  static QAbstractFileEngine *create(const QString &fileName);
190 
191 protected:
192  void setError(QFile::FileError error, const QString &str);
193 
196 
198 private:
201 };
202 
203 Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFileEngine::FileFlags)
204 
206 {
207 public:
208  QAbstractFileEngineHandler();
209  virtual ~QAbstractFileEngineHandler();
210  virtual QAbstractFileEngine *create(const QString &fileName) const = 0;
211 };
212 
215 {
216 public:
217  QAbstractFileEngineIterator(QDir::Filters filters, const QStringList &nameFilters);
218  virtual ~QAbstractFileEngineIterator();
219 
220  virtual QString next() = 0;
221  virtual bool hasNext() const = 0;
222 
223  QString path() const;
224  QStringList nameFilters() const;
225  QDir::Filters filters() const;
226 
227  virtual QString currentFileName() const = 0;
228  virtual QFileInfo currentFileInfo() const;
229  QString currentFilePath() const;
230 
231 protected:
233  };
234  virtual QVariant entryInfo(EntryInfoType type) const;
235 
236 private:
240  void setPath(const QString &path);
242 };
243 
245 
247 
248 #endif // QABSTRACTFILEENGINE_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
#define error(msg)
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
FileName
These values are used to request a file name in a particular format.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
FileFlag
The permissions and types of a file, suitable for OR&#39;ing together.
The QDirIterator class provides an iterator for directory entrylists.
Definition: qdiriterator.h:54
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QWidget * owner
provides an extended output argument to QAbstractFileEngine&#39;s extension support.
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
unsigned char uchar
Definition: qglobal.h:994
QFuture< void > map(Sequence &sequence, MapFunction function)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
Extension
This enum describes the types of extensions that the file engine can support.
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
provides an extended input argument to QAbstractFileEngine&#39;s extension support.
The QAbstractFileEngine class provides an abstraction for accessing the filesystem.
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
const T * ptr(const T &t)
__int64 qint64
Definition: qglobal.h:942
FileTime
These are used by the fileTime() function.
static const char *const filters[3]
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
QScopedPointer< QAbstractFileEnginePrivate > d_ptr
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines...
Q_CORE_EXPORT QTextStream & flush(QTextStream &s)
QAbstractFileEngineIterator Iterator
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
MemoryMapFlags
This enum describes special options that may be used by the map() function.
Definition: qfile.h:180
FileError
This enum describes the errors that may be returned by the error() function.
Definition: qfile.h:74
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
#define class
#define QT_END_HEADER
Definition: qglobal.h:137
EntryInfoType
This enum describes the different types of information that can be requested through the QAbstractFil...
static QString fileName(const QString &fileUrl)
int open(const char *, int,...)
The QAbstractFileEngineHandler class provides a way to register custom file engines with your applica...