CopperSpice API  1.9.1
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 ()
 
QAbstractFileEngineIteratorbeginEntryList (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 >
 
- 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

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

Returns an instance of QAbstractFileEngineIterator using filters for entry filtering and filterNames for name filtering. This method is called by QDirIterator to initiate directory iteration. The caller takes ownership of the returned instance and must delete it.

See also
QDirIterator

Reimplemented from QAbstractFileEngine::beginEntryList()

bool QFSFileEngine::caseSensitive ( ) const
overridevirtual

Returns true for Windows and false for Unix.

Reimplemented from QAbstractFileEngine::caseSensitive()

bool QFSFileEngine::close ( )
overridevirtual

Reimplemented from QAbstractFileEngine::close()

bool QFSFileEngine::copy ( const QString newName)
overridevirtual

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

Reimplemented from QAbstractFileEngine::copy()

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. This method 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.

See also
setFileName()

Reimplemented from QAbstractFileEngine::entryList()

bool QFSFileEngine::extension ( Extension  extension,
const ExtensionOption *  option = nullptr,
ExtensionReturn *  output = nullptr 
)
override
FileFlags QFSFileEngine::fileFlags ( FileFlags  type) const
overridevirtual
QString QFSFileEngine::fileName ( FileName  file) const
overridevirtual

Reimplemented from QAbstractFileEngine::fileName()

QDateTime QFSFileEngine::fileTime ( FileTime  time) const
overridevirtual

Reimplemented from QAbstractFileEngine::fileTime()

bool QFSFileEngine::flush ( )
overridevirtual

Reimplemented from QAbstractFileEngine::flush()

int QFSFileEngine::handle ( ) const
overridevirtual

Reimplemented from QAbstractFileEngine::handle()

QString QFSFileEngine::homePath ( )
static

Returns the home path of the current user.

See also
rootPath()
bool QFSFileEngine::isRelativePath ( ) const
overridevirtual
bool QFSFileEngine::isSequential ( ) const
overridevirtual
bool QFSFileEngine::link ( const QString newName)
overridevirtual

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::link()

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

Reimplemented from QAbstractFileEngine::mkdir()

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

Reimplemented from QAbstractFileEngine::open()

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

Opens the file handle fh using the given openModee. Returns true on success, otherwise returns false.

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

Opens the file handle fh using the givne openMode. 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 using the given openMode. Returns true on success, otherwise returns false.

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

Opens the file descriptor fd using the given openMode. 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()

uint QFSFileEngine::ownerId ( FileOwner  own) const
overridevirtual

For Windows -2 is always returned.

On Unix systems 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::ownerId()

qint64 QFSFileEngine::pos ( ) const
overridevirtual

Reimplemented from QAbstractFileEngine::pos()

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

Reimplemented from QAbstractFileEngine::read()

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

Reimplemented from QAbstractFileEngine::readLine()

bool QFSFileEngine::remove ( )
overridevirtual

Reimplemented from QAbstractFileEngine::remove()

bool QFSFileEngine::rename ( const QString newName)
overridevirtual

Reimplemented from QAbstractFileEngine::rename()

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.

See also
setFileName()

Reimplemented from QAbstractFileEngine::renameOverwrite()

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

Reimplemented from QAbstractFileEngine::rmdir()

QString QFSFileEngine::rootPath ( )
static

Returns the root path.

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

Reimplemented from QAbstractFileEngine::seek()

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
bool QFSFileEngine::setPermissions ( uint  perms)
overridevirtual
bool QFSFileEngine::setSize ( qint64  size)
overridevirtual

Reimplemented from QAbstractFileEngine::setSize()

qint64 QFSFileEngine::size ( ) const
overridevirtual

Reimplemented from QAbstractFileEngine::size()

bool QFSFileEngine::supportsExtension ( Extension  extension) const
overridevirtual
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::syncToDisk()

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()