CopperSpice API  1.7.2
QFSFileEngine Class Reference

The QFSFileEngine class implements the default file engine. More...

Inheritance diagram for QFSFileEngine:
QAbstractFileEngine

Public Methods

 QFSFileEngine ()
 
 QFSFileEngine (const QString &file)
 
 ~QFSFileEngine ()
 
IteratorbeginEntryList (QDir::Filters filters, const QStringList &filterNames) override
 
bool caseSensitive () const override
 
bool close () override
 
bool copy (const QString &newName) override
 
QStringList entryList (QDir::Filters filters, const QStringList &filterNames) const override
 
bool extension (Extension extension, const ExtensionOption *option=nullptr, ExtensionReturn *output=nullptr) override
 
FileFlags fileFlags (FileFlags type) const override
 
QString fileName (FileName file) const override
 
QDateTime fileTime (FileTime time) const override
 
bool flush () override
 
int handle () const override
 
bool isRelativePath () const override
 
bool isSequential () const override
 
bool link (const QString &newName) override
 
bool mkdir (const QString &dirName, bool createParentDirectories) const override
 
bool open (QIODevice::OpenMode openMode) override
 
bool open (QIODevice::OpenMode openMode, FILE *fh)
 
bool open (QIODevice::OpenMode openMode, FILE *fh, QFile::FileHandleFlags handleFlags)
 
bool open (QIODevice::OpenMode openMode, int fd)
 
bool open (QIODevice::OpenMode openMode, int fd, QFile::FileHandleFlags handleFlags)
 
QString owner (FileOwner own) const override
 
uint ownerId (FileOwner own) const override
 
qint64 pos () const override
 
qint64 read (char *data, qint64 maxlen) override
 
qint64 readLine (char *data, qint64 maxlen) override
 
bool remove () override
 
bool rename (const QString &newName) override
 
bool renameOverwrite (const QString &newName) override
 
bool rmdir (const QString &dirName, bool recurseParentDirectories) const override
 
bool seek (qint64 pos) override
 
void setFileName (const QString &file) override
 
bool setPermissions (uint perms) override
 
bool setSize (qint64 size) override
 
qint64 size () const override
 
bool supportsExtension (Extension extension) const override
 
bool syncToDisk () override
 
qint64 write (const char *data, qint64 len) override
 
- Public Methods inherited from QAbstractFileEngine
virtual ~QAbstractFileEngine ()
 
bool atEnd () const
 
QFile::FileError error () const
 
QString errorString () const
 
virtual bool extension (Extension extension, const ExtensionOption *option=nullptr, ExtensionReturn *output=nullptr)
 
ucharmap (qint64 offset, qint64 size, QFile::MemoryMapFlags flags)
 
bool unmap (uchar *address)
 

Static Public Methods

static QString currentPath (const QString &path=QString ())
 
static QFileInfoList drives ()
 
static QString homePath ()
 
static QString rootPath ()
 
static bool setCurrentPath (const QString &path)
 
static QString tempPath ()
 
- Static Public Methods inherited from QAbstractFileEngine
static QAbstractFileEngine * create (const QString &fileName)
 

Additional Inherited Members

- Public Typedefs inherited from QAbstractFileEngine
using FileFlags = QFlags< FileFlag >
 
typedef QAbstractFileEngineIterator Iterator
 
- Public Types inherited from QAbstractFileEngine
enum  Extension
 
enum  FileFlag
 
enum  FileName
 
enum  FileOwner
 
enum  FileTime
 
- Protected Methods inherited from QAbstractFileEngine
 QAbstractFileEngine ()
 
void setError (QFile::FileError error, const QString &errorString)
 

Detailed Description

The QFSFileEngine class implements the default file engine. If you only want to access files or directories, use QFile, QFileInfo or QDir instead.

QFSFileEngine is the default file engine for accessing regular files. It is provided for convenience; by subclassing this class, you can alter its behavior slightly, without having to write a complete QAbstractFileEngine subclass. To install your custom file engine, you must also subclass QAbstractFileEngineHandler and create an instance of your handler.

It can also be useful to create a QFSFileEngine object directly if you need to use the local file system inside QAbstractFileEngine::create(), in order to avoid recursion (as higher-level classes tend to call QAbstractFileEngine::create()).

See also
setCurrentPath()

Constructor & Destructor Documentation

QFSFileEngine::QFSFileEngine ( )

Constructs a new QFSFileEngine object.

QFSFileEngine::QFSFileEngine ( const QString file)
explicit

Constructs a QFSFileEngine for the file name file.

QFSFileEngine::~QFSFileEngine ( )

Destroys the object and frees any allocated resources.

Method Documentation

Iterator* QFSFileEngine::beginEntryList ( QDir::Filters  filters,
const QStringList filterNames 
)
overridevirtual

Returns an instance of a QAbstractFileEngineIterator using filters for entry filtering and filterNames for name filtering. This method is called by QDirIterator to initiate directory iteration.

QDirIterator takes ownership of the returned instance, and deletes it when it is done.

See also
QDirIterator

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::caseSensitive ( ) const
overridevirtual

Returns true for Windows and false for Unix.

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::close ( )
overridevirtual

Reimplemented from QAbstractFileEngine::close().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::copy ( const QString newName)
overridevirtual

For windows, copy the file to file newName. Not implemented for Unix.

Reimplemented from QAbstractFileEngine.

QString QFSFileEngine::currentPath ( const QString path = QString())
static

For Windows, returns the canonicalized form of the current path used by the file engine for the drive specified by path. On Windows, each drive has its own current directory, so a different path is returned for file names that include different drive names (e.g. A: or C:).

For Unix, returns the current working directory for the file engine.

See also
setCurrentPath()
QFileInfoList QFSFileEngine::drives ( )
static

For Windows, returns the list of drives in the file system as a list of QFileInfo objects. Returns all drive letters.

For Unix, the list contains just the root path "/".

QStringList QFSFileEngine::entryList ( QDir::Filters  filters,
const QStringList filterNames 
) const
overridevirtual

Requests that a list of all the files matching the filters list based on the filterNames in the file engine's directory are returned.

Should return an empty list if the file engine refers to a file rather than a directory, or if the directory is unreadable or does not exist or if nothing matches the specifications.

This virtual function must be reimplemented by all subclasses.

See also
setFileName()

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::extension ( Extension  extension,
const ExtensionOption *  option = nullptr,
ExtensionReturn *  output = nullptr 
)
override

Reimplemented from QAbstractFileEngine::extension().

FileFlags QFSFileEngine::fileFlags ( FileFlags  type) const
overridevirtual

Reimplemented from QAbstractFileEngine::fileFlags().

Reimplemented from QAbstractFileEngine.

QString QFSFileEngine::fileName ( FileName  file) const
overridevirtual

Reimplemented from QAbstractFileEngine::fileName().

See also
setFileName()

Reimplemented from QAbstractFileEngine.

QDateTime QFSFileEngine::fileTime ( FileTime  time) const
overridevirtual

Reimplemented from QAbstractFileEngine::fileTime().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::flush ( )
overridevirtual

Reimplemented from QAbstractFileEngine::flush().

Reimplemented from QAbstractFileEngine.

int QFSFileEngine::handle ( ) const
overridevirtual

Reimplemented from QAbstractFileEngine::handle().

Reimplemented from QAbstractFileEngine.

QString QFSFileEngine::homePath ( )
static

Returns the home path of the current user.

See also
rootPath()
bool QFSFileEngine::isRelativePath ( ) const
overridevirtual

Reimplemented from QAbstractFileEngine::isRelativePath().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::isSequential ( ) const
overridevirtual

Reimplemented from QAbstractFileEngine::isSequential().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::link ( const QString newName)
overridevirtual

Reimplemented from QAbstractFileEngine::link().

Creates a link from the file currently specified by fileName() to newName. What a link is depends on the underlying file system (be it a shortcut on Windows or a symbolic link on Unix). Returns true if successful, otherwise returns false.

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::mkdir ( const QString dirName,
bool  createParentDirectories 
) const
overridevirtual

Reimplemented from QAbstractFileEngine::mkdir().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::open ( QIODevice::OpenMode  openMode)
overridevirtual

Reimplemented from QAbstractFileEngine::open().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::open ( QIODevice::OpenMode  openMode,
FILE *  fh 
)

Opens the file handle>i> in openMode mode. Returns true on success, otherwise returns false.

bool QFSFileEngine::open ( QIODevice::OpenMode  openMode,
FILE *  fh,
QFile::FileHandleFlags  handleFlags 
)

Opens the file handle fh in openMode mode. Returns true on success, otherwise returns false. The handleFlags argument specifies whether the file handle will be closed by CopperSpice.

See also
QFile::FileHandleFlags
bool QFSFileEngine::open ( QIODevice::OpenMode  openMode,
int  fd 
)

Opens the file descriptor fd in openMode mode. Returns true on success, otherwise returns false.

bool QFSFileEngine::open ( QIODevice::OpenMode  openMode,
int  fd,
QFile::FileHandleFlags  handleFlags 
)

Opens the file descriptor fd in openMode mode. Returns true on success, otherwise returns false. The handleFlags argument specifies whether the file handle will be closed by CopperSpice.

See also
QFile::FileHandleFlags
QString QFSFileEngine::owner ( FileOwner  own) const
overridevirtual

Reimplemented from QAbstractFileEngine::owner().

Reimplemented from QAbstractFileEngine.

uint QFSFileEngine::ownerId ( FileOwner  own) const
overridevirtual

For Windows, -2 is always returned.

In Unix, if stat() is successful, the uid is returned if own is the owner. Otherwise the gid is returned. If stat() is unsuccessful, -2 is returned.

Reimplemented from QAbstractFileEngine.

qint64 QFSFileEngine::pos ( ) const
overridevirtual

Reimplemented from QAbstractFileEngine::pos().

Reimplemented from QAbstractFileEngine.

qint64 QFSFileEngine::read ( char *  data,
qint64  maxlen 
)
overridevirtual

Reimplemented from QAbstractFileEngine::read().

Reimplemented from QAbstractFileEngine.

qint64 QFSFileEngine::readLine ( char *  data,
qint64  maxlen 
)
overridevirtual

Reimplemented from QAbstractFileEngine::readLine().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::remove ( )
overridevirtual

Reimplemented from QAbstractFileEngine::remove().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::rename ( const QString newName)
overridevirtual

Reimplemented from QAbstractFileEngine::rename().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::renameOverwrite ( const QString newName)
overridevirtual

Requests that the file be renamed to newName in the file system. If the new name already exists, it must be overwritten. If the operation succeeds the method returns true, otherwise returns false.

This virtual function must be reimplemented by all subclasses.

See also
setFileName()

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::rmdir ( const QString dirName,
bool  recurseParentDirectories 
) const
overridevirtual

Reimplemented from QAbstractFileEngine::rmdir().

Reimplemented from QAbstractFileEngine.

QString QFSFileEngine::rootPath ( )
static

Returns the root path.

See also
homePath()
bool QFSFileEngine::seek ( qint64  pos)
overridevirtual

Reimplemented from QAbstractFileEngine::seek().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::setCurrentPath ( const QString path)
static

Sets the current path to path. Returns true if the new path exists, otherwise this method does nothing and returns false.

See also
currentPath()
void QFSFileEngine::setFileName ( const QString file)
overridevirtual

Reimplemented from QAbstractFileEngine::setFileName().

See also
fileName()

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::setPermissions ( uint  perms)
overridevirtual

Reimplemented from QAbstractFileEngine::setPermissions().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::setSize ( qint64  size)
overridevirtual

Reimplemented from QAbstractFileEngine::setSize().

See also
size()

Reimplemented from QAbstractFileEngine.

qint64 QFSFileEngine::size ( ) const
overridevirtual

Reimplemented from QAbstractFileEngine::size().

See also
setSize()

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::supportsExtension ( Extension  extension) const
overridevirtual

Reimplemented from QAbstractFileEngine::supportsExtension().

Reimplemented from QAbstractFileEngine.

bool QFSFileEngine::syncToDisk ( )
overridevirtual

Flushes and syncs the file to disk. Returns true if successful, otherwise returns false. The default implementation always returns false.

Reimplemented from QAbstractFileEngine.

QString QFSFileEngine::tempPath ( )
static

Returns the temporary path (i.e., a path in which it is safe to store temporary files).

qint64 QFSFileEngine::write ( const char *  data,
qint64  len 
)
overridevirtual

Reimplemented from QAbstractFileEngine::write().

Reimplemented from QAbstractFileEngine.