QtCore/qabstractfileengine.h Source File

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;
61 class QAbstractFileEnginePrivate;
62 
63 class Q_CORE_EXPORT QAbstractFileEngine
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;
145  bool unmap(uchar *ptr);
146 
147  typedef QAbstractFileEngineIterator Iterator;
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:
177  uchar *address;
178  };
179 
181  public:
182  uchar *address;
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 
194  QAbstractFileEngine();
195  QAbstractFileEngine(QAbstractFileEnginePrivate &);
196 
198 private:
199  Q_DECLARE_PRIVATE(QAbstractFileEngine)
200  Q_DISABLE_COPY(QAbstractFileEngine)
201 };
202 
203 Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFileEngine::FileFlags)
204 
205 class Q_CORE_EXPORT QAbstractFileEngineHandler
206 {
207 public:
208  QAbstractFileEngineHandler();
209  virtual ~QAbstractFileEngineHandler();
210  virtual QAbstractFileEngine *create(const QString &fileName) const = 0;
211 };
212 
213 class QAbstractFileEngineIteratorPrivate;
214 class Q_CORE_EXPORT QAbstractFileEngineIterator
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:
237  Q_DISABLE_COPY(QAbstractFileEngineIterator)
238  friend class QDirIterator;
239  friend class QDirIteratorPrivate;
240  void setPath(const QString &path);
241  QScopedPointer<QAbstractFileEngineIteratorPrivate> d;
242 };
243 
245 
247 
248 #endif // QABSTRACTFILEENGINE_H
GLuint GLuint GLsizei GLenum type
Definition: GLee.h:872
#define QT_END_NAMESPACE
Definition: qglobal.h:128
GLintptr offset
Definition: GLee.h:1562
#define QT_BEGIN_HEADER
Definition: qglobal.h:141
QFuture< void > map(Sequence &sequence, MapFunctor map)
long long qint64
Definition: qglobal.h:947
GLXDrawable GLXDrawable read
Definition: GLee.h:10243
#define QT_BEGIN_NAMESPACE
Definition: qglobal.h:127
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: GLee.h:880
MemoryMapFlags
Definition: qfile.h:180
FileError
Definition: qfile.h:74
QAbstractFileEngineIterator Iterator
Q_CORE_EXPORT QTextStream & flush(QTextStream &s)
GLenum GLsizei len
Definition: GLee.h:2695
QScopedPointer< QAbstractFileEnginePrivate > d_ptr
#define QT_END_HEADER
Definition: qglobal.h:142
GLsizeiptr size
Definition: GLee.h:1561