Qt 4.8
Public Functions | Static Public Functions | Protected Functions | List of all members
QFSFileEngine Class Reference

The QFSFileEngine class implements Qt's default file engine. More...

#include <qfsfileengine.h>

Inheritance diagram for QFSFileEngine:
QAbstractFileEngine QTemporaryFileEngine

Public Functions

IteratorbeginEntryList (QDir::Filters filters, const QStringList &filterNames)
 
bool caseSensitive () const
 Returns true for Windows, false for Unix. More...
 
bool close ()
 Reimplemented Function More...
 
bool copy (const QString &newName)
 For windows, copy the file to file copyName. More...
 
IteratorendEntryList ()
 
QStringList entryList (QDir::Filters filters, const QStringList &filterNames) const
 
bool extension (Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0)
 Reimplemented Function More...
 
FileFlags fileFlags (FileFlags type) const
 Reimplemented Function More...
 
QString fileName (FileName file) const
 Reimplemented Function More...
 
QDateTime fileTime (FileTime time) const
 Reimplemented Function More...
 
bool flush ()
 Reimplemented Function More...
 
int handle () const
 Reimplemented Function More...
 
bool isRelativePath () const
 Reimplemented Function More...
 
bool isSequential () const
 Reimplemented Function More...
 
bool link (const QString &newName)
 Creates a link from the file currently specified by fileName() to newName. More...
 
bool mkdir (const QString &dirName, bool createParentDirectories) const
 Reimplemented Function More...
 
bool open (QIODevice::OpenMode openMode)
 Reimplemented Function More...
 
bool open (QIODevice::OpenMode flags, FILE *fh)
 Opens the file handle fh in openMode mode. More...
 
bool open (QIODevice::OpenMode flags, int fd)
 Opens the file descriptor fd in openMode mode. More...
 
bool open (QIODevice::OpenMode flags, int fd, QFile::FileHandleFlags handleFlags)
 Opens the file descriptor fd in openMode mode. More...
 
bool open (QIODevice::OpenMode flags, FILE *fh, QFile::FileHandleFlags handleFlags)
 Opens the file handle fh in openMode mode. More...
 
QString owner (FileOwner) const
 Reimplemented Function More...
 
uint ownerId (FileOwner) const
 In Unix, if stat() is successful, the uid is returned if own is the owner. More...
 
qint64 pos () const
 Reimplemented Function More...
 
 QFSFileEngine ()
 Constructs a QFSFileEngine. More...
 
 QFSFileEngine (const QString &file)
 Constructs a QFSFileEngine for the file name file. More...
 
qint64 read (char *data, qint64 maxlen)
 Reimplemented Function More...
 
qint64 readLine (char *data, qint64 maxlen)
 Reimplemented Function More...
 
bool remove ()
 Reimplemented Function More...
 
bool rename (const QString &newName)
 Reimplemented Function More...
 
bool rmdir (const QString &dirName, bool recurseParentDirectories) const
 Reimplemented Function More...
 
bool seek (qint64)
 Reimplemented Function More...
 
void setFileName (const QString &file)
 Reimplemented Function More...
 
bool setPermissions (uint perms)
 Reimplemented Function More...
 
bool setSize (qint64 size)
 Reimplemented Function More...
 
qint64 size () const
 Reimplemented Function More...
 
bool supportsExtension (Extension extension) const
 Reimplemented Function More...
 
qint64 write (const char *data, qint64 len)
 Reimplemented Function More...
 
 ~QFSFileEngine ()
 Destructs the QFSFileEngine. More...
 
- Public Functions inherited from QAbstractFileEngine
bool atEnd () const
 Returns true if the current position is at the end of the file; otherwise, returns false. More...
 
QFile::FileError error () const
 Returns the QFile::FileError that resulted from the last failed operation. More...
 
QString errorString () const
 Returns the human-readable message appropriate to the current error reported by error(). More...
 
ucharmap (qint64 offset, qint64 size, QFile::MemoryMapFlags flags)
 Maps size bytes of the file into memory starting at offset. More...
 
bool unmap (uchar *ptr)
 Unmaps the memory address. More...
 
virtual ~QAbstractFileEngine ()
 Destroys the QAbstractFileEngine. More...
 

Static Public Functions

static QString currentPath (const QString &path=QString())
 For Unix, returns the current working directory for the file engine. More...
 
static QFileInfoList drives ()
 For Windows, returns the list of drives in the file system as a list of QFileInfo objects. More...
 
static QString homePath ()
 Returns the home path of the current user. More...
 
static QString rootPath ()
 Returns the root path. More...
 
static bool setCurrentPath (const QString &path)
 Sets the current path (e. More...
 
static QString tempPath ()
 Returns the temporary path (i. More...
 
- Static Public Functions inherited from QAbstractFileEngine
static QAbstractFileEnginecreate (const QString &fileName)
 Creates and returns a QAbstractFileEngine suitable for processing fileName. More...
 

Protected Functions

 QFSFileEngine (QFSFileEnginePrivate &dd)
 
- Protected Functions inherited from QAbstractFileEngine
 QAbstractFileEngine ()
 Constructs a new QAbstractFileEngine that does not refer to any file or directory. More...
 
 QAbstractFileEngine (QAbstractFileEnginePrivate &)
 Constructs a QAbstractFileEngine. More...
 
void setError (QFile::FileError error, const QString &str)
 Sets the error type to error, and the error string to errorString. More...
 

Additional Inherited Members

- Public Types inherited from QAbstractFileEngine
enum  Extension { AtEndExtension, FastReadLineExtension, MapExtension, UnMapExtension }
 This enum describes the types of extensions that the file engine can support. More...
 
enum  FileFlag {
  ReadOwnerPerm = 0x4000, WriteOwnerPerm = 0x2000, ExeOwnerPerm = 0x1000, ReadUserPerm = 0x0400,
  WriteUserPerm = 0x0200, ExeUserPerm = 0x0100, ReadGroupPerm = 0x0040, WriteGroupPerm = 0x0020,
  ExeGroupPerm = 0x0010, ReadOtherPerm = 0x0004, WriteOtherPerm = 0x0002, ExeOtherPerm = 0x0001,
  LinkType = 0x10000, FileType = 0x20000, DirectoryType = 0x40000, BundleType = 0x80000,
  HiddenFlag = 0x0100000, LocalDiskFlag = 0x0200000, ExistsFlag = 0x0400000, RootFlag = 0x0800000,
  Refresh = 0x1000000, PermsMask = 0x0000FFFF, TypesMask = 0x000F0000, FlagsMask = 0x0FF00000,
  FileInfoAll = FlagsMask | PermsMask | TypesMask
}
 The permissions and types of a file, suitable for OR'ing together. More...
 
enum  FileName {
  DefaultName, BaseName, PathName, AbsoluteName,
  AbsolutePathName, LinkName, CanonicalName, CanonicalPathName,
  BundleName, NFileNames = 9
}
 These values are used to request a file name in a particular format. More...
 
enum  FileOwner { OwnerUser, OwnerGroup }
 
enum  FileTime { CreationTime, ModificationTime, AccessTime }
 These are used by the fileTime() function. More...
 
typedef QAbstractFileEngineIterator Iterator
 
- Protected Variables inherited from QAbstractFileEngine
QScopedPointer< QAbstractFileEnginePrivated_ptr
 

Detailed Description

The QFSFileEngine class implements Qt's default file engine.

Since
4.1

This class is part of the file engine framework in Qt. 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()).

Definition at line 60 of file qfsfileengine.h.

Constructors and Destructors

◆ QFSFileEngine() [1/3]

QFSFileEngine::QFSFileEngine ( )

Constructs a QFSFileEngine.

Definition at line 158 of file qfsfileengine.cpp.

159 {
160 }
QAbstractFileEngine()
Constructs a new QAbstractFileEngine that does not refer to any file or directory.

◆ QFSFileEngine() [2/3]

QFSFileEngine::QFSFileEngine ( const QString file)
explicit

Constructs a QFSFileEngine for the file name file.

Definition at line 148 of file qfsfileengine.cpp.

150 {
152  d->fileEntry = QFileSystemEntry(file);
153 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QAbstractFileEngine()
Constructs a new QAbstractFileEngine that does not refer to any file or directory.
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ ~QFSFileEngine()

QFSFileEngine::~QFSFileEngine ( )

Destructs the QFSFileEngine.

Definition at line 173 of file qfsfileengine.cpp.

174 {
176  if (d->closeFileHandle) {
177  if (d->fh) {
178  int ret;
179  do {
180  ret = fclose(d->fh);
181  } while (ret == EOF && errno == EINTR);
182  } else if (d->fd != -1) {
183  int ret;
184  do {
185  ret = QT_CLOSE(d->fd);
186  } while (ret == -1 && errno == EINTR);
187  }
188  }
189  QList<uchar*> keys = d->maps.keys();
190  for (int i = 0; i < keys.count(); ++i)
191  unmap(keys.at(i));
192 }
double d
Definition: qnumeric_p.h:62
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
#define Q_D(Class)
Definition: qglobal.h:2482
QStringList keys
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool unmap(uchar *ptr)
Unmaps the memory address.
int errno
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60
#define QT_CLOSE
Definition: qcore_unix_p.h:304

◆ QFSFileEngine() [3/3]

QFSFileEngine::QFSFileEngine ( QFSFileEnginePrivate dd)
protected
Warning
This function is not part of the public interface.

Definition at line 165 of file qfsfileengine.cpp.

166  : QAbstractFileEngine(dd)
167 {
168 }
QAbstractFileEngine()
Constructs a new QAbstractFileEngine that does not refer to any file or directory.

Functions

◆ beginEntryList()

QAbstractFileEngine::Iterator * QFSFileEngine::beginEntryList ( QDir::Filters  filters,
const QStringList filterNames 
)
virtual
Warning
This function is not part of the public interface.

Reimplemented from QAbstractFileEngine.

Definition at line 787 of file qfsfileengine.cpp.

788 {
789  return new QFSFileEngineIterator(filters, filterNames);
790 }
static const char *const filters[3]

◆ caseSensitive()

bool QFSFileEngine::caseSensitive ( ) const
virtual

Returns true for Windows, false for Unix.

Reimplemented from QAbstractFileEngine.

Definition at line 725 of file qfsfileengine_unix.cpp.

Referenced by QExtendedInformation::isCaseSensitive(), and QFSFileEnginePrivate::longFileName().

726 {
727 #if defined(Q_OS_SYMBIAN)
728  return false;
729 #else
730  return true;
731 #endif
732 }

◆ close()

bool QFSFileEngine::close ( )
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Reimplemented in QTemporaryFileEngine.

Definition at line 377 of file qfsfileengine.cpp.

Referenced by QTemporaryFileEngine::remove(), QTemporaryFileEngine::rename(), QTemporaryFileEngine::setFileName(), and QTemporaryFileEngine::~QTemporaryFileEngine().

378 {
380  d->openMode = QIODevice::NotOpen;
381  return d->nativeClose();
382 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ copy()

bool QFSFileEngine::copy ( const QString copyName)
virtual

For windows, copy the file to file copyName.

Not implemented for Unix.

Reimplemented from QAbstractFileEngine.

Definition at line 659 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

660 {
663  bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), error);
664  if (!ret) {
666  }
667  return ret;
668 }
void setError(QFile::FileError error, const QString &str)
Sets the error type to error, and the error string to errorString.
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QFile::FileError error() const
Returns the QFile::FileError that resulted from the last failed operation.
QString toString()
static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ currentPath()

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

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

For Windows, returns the canonicalized form of the current path used by the file engine for the drive specified by fileName. 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:).

See also
setCurrentPath()

Definition at line 739 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

740 {
742 }
static QFileSystemEntry currentPath()
QString filePath() const

◆ drives()

QFileInfoList QFSFileEngine::drives ( )
static

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

On unix, Mac OS X and Windows CE, only the root path is returned. On Windows, this function returns all drives (A:\, C:\, D:\, etc.).

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

Definition at line 759 of file qfsfileengine_unix.cpp.

Referenced by QDir::drives(), and QFSFileEnginePrivate::longFileName().

760 {
761  QFileInfoList ret;
762 #if defined(Q_OS_SYMBIAN)
763  TDriveList driveList;
764  RFs rfs = qt_s60GetRFs();
765  TInt err = rfs.DriveList(driveList);
766  if (err == KErrNone) {
767  char driveName[] = "A:/";
768 
769  for (char i = 0; i < KMaxDrives; i++) {
770  if (driveList[i]) {
771  driveName[0] = 'A' + i;
772  ret.append(QFileInfo(QLatin1String(driveName)));
773  }
774  }
775  } else {
776  qWarning("QFSFileEngine::drives: Getting drives failed");
777  }
778 #else
779  ret.append(QFileInfo(rootPath()));
780 #endif
781  return ret;
782 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
Q_CORE_EXPORT void qWarning(const char *,...)
static QString rootPath()
Returns the root path.
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ endEntryList()

QAbstractFileEngine::Iterator * QFSFileEngine::endEntryList ( )
virtual
Warning
This function is not part of the public interface.

Reimplemented from QAbstractFileEngine.

Definition at line 795 of file qfsfileengine.cpp.

796 {
797  return 0;
798 }

◆ entryList()

QStringList QFSFileEngine::entryList ( QDir::Filters  filters,
const QStringList filterNames 
) const
virtual
Warning
This function is not part of the public interface.

Reimplemented from QAbstractFileEngine.

Definition at line 804 of file qfsfileengine.cpp.

805 {
806  return QAbstractFileEngine::entryList(filters, filterNames);
807 }
virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const
Requests that a list of all the files matching the filters list based on the filterNames in the file ...
static const char *const filters[3]

◆ extension()

bool QFSFileEngine::extension ( Extension  extension,
const ExtensionOption option = 0,
ExtensionReturn output = 0 
)
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 835 of file qfsfileengine.cpp.

836 {
838  if (extension == AtEndExtension && d->fh && isSequential())
839  return feof(d->fh);
840 
841  if (extension == MapExtension) {
842  const MapExtensionOption *options = (MapExtensionOption*)(option);
843  MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output);
844  returnValue->address = d->map(options->offset, options->size, options->flags);
845  return (returnValue->address != 0);
846  }
847  if (extension == UnMapExtension) {
848  UnMapExtensionOption *options = (UnMapExtensionOption*)option;
849  return d->unmap(options->address);
850  }
851 
852  return false;
853 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool isSequential() const
Reimplemented Function
bool extension(Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0)
Reimplemented Function
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ fileFlags()

QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags ( FileFlags  type) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 813 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

814 {
815  Q_D(const QFSFileEngine);
816 
817  if (type & Refresh)
818  d->metaData.clear();
819 
820  QAbstractFileEngine::FileFlags ret = 0;
821 
822  if (type & FlagsMask)
823  ret |= LocalDiskFlag;
824 
825  bool exists;
826  {
827  QFileSystemMetaData::MetaDataFlags queryFlags = 0;
828 
829  queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type))
831 
832  if (type & TypesMask)
833  queryFlags |= QFileSystemMetaData::AliasType
838 
839  if (type & FlagsMask)
842 
843  queryFlags |= QFileSystemMetaData::LinkType;
844 
845  exists = d->doStat(queryFlags);
846  }
847 
848  if (!exists && !d->metaData.isLink())
849  return ret;
850 
851  if (exists && (type & PermsMask))
852  ret |= FileFlags(uint(d->metaData.permissions()));
853 
854  if (type & TypesMask) {
855  if (d->metaData.isAlias()) {
856  ret |= LinkType;
857  } else {
858  if ((type & LinkType) && d->metaData.isLink())
859  ret |= LinkType;
860  if (exists) {
861  if (d->metaData.isFile()) {
862  ret |= FileType;
863  } else if (d->metaData.isDirectory()) {
864  ret |= DirectoryType;
865  if ((type & BundleType) && d->metaData.isBundle())
866  ret |= BundleType;
867  }
868  }
869  }
870  }
871 
872  if (type & FlagsMask) {
873  if (exists)
874  ret |= ExistsFlag;
875  if (d->fileEntry.isRoot())
876  ret |= RootFlag;
877  else if (d->metaData.isHidden())
878  ret |= HiddenFlag;
879  }
880 
881  return ret;
882 }
double d
Definition: qnumeric_p.h:62
int type
Definition: qmetatype.cpp:239
#define Q_D(Class)
Definition: qglobal.h:2482
unsigned int uint
Definition: qglobal.h:996
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ fileName()

QString QFSFileEngine::fileName ( FileName  file) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 884 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

885 {
886  Q_D(const QFSFileEngine);
887  if (file == BundleName) {
888  return QFileSystemEngine::bundleName(d->fileEntry);
889  } else if (file == BaseName) {
890  return d->fileEntry.fileName();
891  } else if (file == PathName) {
892  return d->fileEntry.path();
893  } else if (file == AbsoluteName || file == AbsolutePathName) {
895  if (file == AbsolutePathName) {
896  return entry.path();
897  }
898  return entry.filePath();
899  } else if (file == CanonicalName || file == CanonicalPathName) {
900  QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry, d->metaData));
901  if (file == CanonicalPathName)
902  return entry.path();
903  return entry.filePath();
904  } else if (file == LinkName) {
905  if (d->isSymlink()) {
906  QFileSystemEntry entry = QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData);
907  return entry.filePath();
908  }
909  return QString();
910  }
911  return d->fileEntry.filePath();
912 }
double d
Definition: qnumeric_p.h:62
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
static QFileSystemEntry absoluteName(const QFileSystemEntry &entry)
static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data)
static QString bundleName(const QFileSystemEntry &entry)
QString filePath() const
static QFileSystemEntry canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ fileTime()

QDateTime QFSFileEngine::fileTime ( FileTime  time) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 1012 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

1013 {
1014  Q_D(const QFSFileEngine);
1015 
1016  if (d->doStat(QFileSystemMetaData::Times))
1017  return d->metaData.fileTime(time);
1018 
1019  return QDateTime();
1020 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ flush()

bool QFSFileEngine::flush ( )
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 454 of file qfsfileengine.cpp.

Referenced by QFSFileEnginePrivate::longFileName(), read(), readLine(), size(), and write().

455 {
457  if ((d->openMode & QIODevice::WriteOnly) == 0) {
458  // Nothing in the write buffers, so flush succeeds in doing
459  // nothing.
460  return true;
461  }
462  return d->nativeFlush();
463 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ handle()

int QFSFileEngine::handle ( ) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 585 of file qfsfileengine.cpp.

586 {
587  Q_D(const QFSFileEngine);
588  return d->nativeHandle();
589 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ homePath()

QString QFSFileEngine::homePath ( )
static

Returns the home path of the current user.

See also
rootPath()

Definition at line 744 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

745 {
747 }

◆ isRelativePath()

bool QFSFileEngine::isRelativePath ( ) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 914 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

915 {
916  Q_D(const QFSFileEngine);
917 #if defined(Q_OS_SYMBIAN)
918  return isRelativePathSymbian(d->fileEntry.filePath());
919 #else
920  return d->fileEntry.filePath().length() ? d->fileEntry.filePath()[0] != QLatin1Char('/') : true;
921 #endif
922 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ isSequential()

bool QFSFileEngine::isSequential ( ) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 812 of file qfsfileengine.cpp.

Referenced by extension(), and supportsExtension().

813 {
814  Q_D(const QFSFileEngine);
815  if (d->is_sequential == 0)
816  d->is_sequential = d->nativeIsSequential() ? 1 : 2;
817  return d->is_sequential == 1;
818 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ link()

bool QFSFileEngine::link ( const QString newName)
virtual

Creates a link from the file currently specified by fileName() to newName.

What a link is depends on the underlying filesystem (be it a shortcut on Windows or a symbolic link on Unix). Returns true if successful; otherwise returns false.

Reimplemented from QAbstractFileEngine.

Definition at line 683 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

684 {
687  bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName), error);
688  if (!ret) {
690  }
691  return ret;
692 }
void setError(QFile::FileError error, const QString &str)
Sets the error type to error, and the error string to errorString.
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QFile::FileError error() const
Returns the QFile::FileError that resulted from the last failed operation.
static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
QString toString()
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ mkdir()

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

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 715 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

716 {
717  return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories);
718 }
const char * name
static bool createDirectory(const QFileSystemEntry &entry, bool createParents)

◆ open() [1/5]

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

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Reimplemented in QTemporaryFileEngine.

Definition at line 207 of file qfsfileengine.cpp.

Referenced by open(), QTemporaryFileEngine::open(), QFilePrivate::openExternalFile(), and setCloseOnExec().

208 {
210  if (d->fileEntry.isEmpty()) {
211  qWarning("QFSFileEngine::open: No file name specified");
212  setError(QFile::OpenError, QLatin1String("No file name specified"));
213  return false;
214  }
215 
216  // Append implies WriteOnly.
217  if (openMode & QFile::Append)
218  openMode |= QFile::WriteOnly;
219 
220  // WriteOnly implies Truncate if neither ReadOnly nor Append are sent.
221  if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append)))
222  openMode |= QFile::Truncate;
223 
224  d->openMode = openMode;
225  d->lastFlushFailed = false;
226  d->tried_stat = 0;
227  d->fh = 0;
228  d->fd = -1;
229 
230  return d->nativeOpen(openMode);
231 }
void setError(QFile::FileError error, const QString &str)
Sets the error type to error, and the error string to errorString.
double d
Definition: qnumeric_p.h:62
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
#define Q_D(Class)
Definition: qglobal.h:2482
Q_CORE_EXPORT void qWarning(const char *,...)
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ open() [2/5]

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

Opens the file handle fh in openMode mode.

Returns true on success; otherwise returns false.

Definition at line 237 of file qfsfileengine.cpp.

238 {
239  return open(openMode, fh, QFile::DontCloseHandle);
240 }
bool open(QIODevice::OpenMode openMode)
Reimplemented Function

◆ open() [3/5]

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

Opens the file descriptor fd in openMode mode.

Returns true on success; otherwise returns false.

Definition at line 306 of file qfsfileengine.cpp.

307 {
308  return open(openMode, fd, QFile::DontCloseHandle);
309 }
bool open(QIODevice::OpenMode openMode)
Reimplemented Function

◆ open() [4/5]

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 Qt. See the QFile::FileHandleFlags documentation for more information.

Definition at line 319 of file qfsfileengine.cpp.

320 {
322 
323  // Append implies WriteOnly.
324  if (openMode & QFile::Append)
325  openMode |= QFile::WriteOnly;
326 
327  // WriteOnly implies Truncate if neither ReadOnly nor Append are sent.
328  if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append)))
329  openMode |= QFile::Truncate;
330 
331  d->openMode = openMode;
332  d->lastFlushFailed = false;
333  d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle);
334  d->fileEntry.clear();
335  d->fh = 0;
336  d->fd = -1;
337  d->tried_stat = 0;
338 
339  return d->openFd(openMode, fd);
340 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ open() [5/5]

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 Qt. See the QFile::FileHandleFlags documentation for more information.

Definition at line 250 of file qfsfileengine.cpp.

251 {
253 
254  // Append implies WriteOnly.
255  if (openMode & QFile::Append)
256  openMode |= QFile::WriteOnly;
257 
258  // WriteOnly implies Truncate if neither ReadOnly nor Append are sent.
259  if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append)))
260  openMode |= QFile::Truncate;
261 
262  d->openMode = openMode;
263  d->lastFlushFailed = false;
264  d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle);
265  d->fileEntry.clear();
266  d->tried_stat = 0;
267  d->fd = -1;
268 
269  return d->openFh(openMode, fh);
270 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ owner()

QString QFSFileEngine::owner ( FileOwner  own) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 935 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

936 {
937 #ifndef Q_OS_SYMBIAN
938  if (own == OwnerUser)
941 #else
942  Q_UNUSED(own)
943  return QString();
944 #endif
945 }
static QString resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
uint ownerId(FileOwner) const
In Unix, if stat() is successful, the uid is returned if own is the owner.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ ownerId()

uint QFSFileEngine::ownerId ( FileOwner  own) const
virtual

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 reuturned.

For Windows, -2 is always returned.

Reimplemented from QAbstractFileEngine.

Definition at line 924 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

925 {
926  Q_D(const QFSFileEngine);
927  static const uint nobodyID = (uint) -2;
928 
929  if (d->doStat(QFileSystemMetaData::OwnerIds))
930  return d->metaData.ownerId(own);
931 
932  return nobodyID;
933 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
unsigned int uint
Definition: qglobal.h:996
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ pos()

qint64 QFSFileEngine::pos ( ) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 519 of file qfsfileengine.cpp.

Referenced by QFSFileEnginePrivate::seekFdFh().

520 {
521  Q_D(const QFSFileEngine);
522  return d->nativePos();
523 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ read()

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

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 594 of file qfsfileengine.cpp.

595 {
597 
598  // On Windows' stdlib implementation, the results of calling fread and
599  // fwrite are undefined if not called either in sequence, or if preceded
600  // with a call to fflush().
601  if (d->lastIOCommand != QFSFileEnginePrivate::IOReadCommand) {
602  flush();
603  d->lastIOCommand = QFSFileEnginePrivate::IOReadCommand;
604  }
605 
606  return d->nativeRead(data, maxlen);
607 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool flush()
Reimplemented Function
static const char * data(const QByteArray &arr)
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ readLine()

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

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 670 of file qfsfileengine.cpp.

671 {
673 
674  // On Windows' stdlib implementation, the results of calling fread and
675  // fwrite are undefined if not called either in sequence, or if preceded
676  // with a call to fflush().
677  if (d->lastIOCommand != QFSFileEnginePrivate::IOReadCommand) {
678  flush();
679  d->lastIOCommand = QFSFileEnginePrivate::IOReadCommand;
680  }
681 
682  return d->nativeReadLine(data, maxlen);
683 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool flush()
Reimplemented Function
static const char * data(const QByteArray &arr)
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ remove()

bool QFSFileEngine::remove ( )
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Reimplemented in QTemporaryFileEngine.

Definition at line 647 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName(), and QTemporaryFileEngine::remove().

648 {
651  bool ret = QFileSystemEngine::removeFile(d->fileEntry, error);
652  d->metaData.clear();
653  if (!ret) {
655  }
656  return ret;
657 }
void setError(QFile::FileError error, const QString &str)
Sets the error type to error, and the error string to errorString.
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
QFile::FileError error() const
Returns the QFile::FileError that resulted from the last failed operation.
static bool removeFile(const QFileSystemEntry &entry, QSystemError &error)
QString toString()
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ rename()

bool QFSFileEngine::rename ( const QString newName)
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Reimplemented in QTemporaryFileEngine.

Definition at line 670 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName(), and QTemporaryFileEngine::rename().

671 {
674  bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error);
675 
676  if (!ret) {
678  }
679 
680  return ret;
681 }
void setError(QFile::FileError error, const QString &str)
Sets the error type to error, and the error string to errorString.
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
QFile::FileError error() const
Returns the QFile::FileError that resulted from the last failed operation.
QString toString()
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ rmdir()

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

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 720 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

721 {
722  return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories);
723 }
static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents)
const char * name

◆ rootPath()

QString QFSFileEngine::rootPath ( )
static

Returns the root path.

See also
homePath()

Definition at line 749 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

750 {
752 }

◆ seek()

bool QFSFileEngine::seek ( qint64  pos)
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 538 of file qfsfileengine.cpp.

Referenced by QTemporaryFileEngine::close().

539 {
541  return d->nativeSeek(pos);
542 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
qint64 pos() const
Reimplemented Function
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ setCurrentPath()

bool QFSFileEngine::setCurrentPath ( const QString path)
static

Sets the current path (e.

g., for QDir), to path. Returns true if the new path exists; otherwise this function does nothing, and returns false.

See also
currentPath()

Definition at line 734 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

735 {
737 }
static bool setCurrentPath(const QFileSystemEntry &entry)

◆ setFileName()

void QFSFileEngine::setFileName ( const QString file)
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Reimplemented in QTemporaryFileEngine.

Definition at line 197 of file qfsfileengine.cpp.

Referenced by QTemporaryFileEngine::QTemporaryFileEngine(), and QTemporaryFileEngine::setFileName().

198 {
200  d->init();
201  d->fileEntry = QFileSystemEntry(file);
202 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ setPermissions()

bool QFSFileEngine::setPermissions ( uint  perms)
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 947 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

948 {
951  if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0)) {
953  return false;
954  }
955  return true;
956 }
void setError(QFile::FileError error, const QString &str)
Sets the error type to error, and the error string to errorString.
double d
Definition: qnumeric_p.h:62
static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data=0)
#define Q_D(Class)
Definition: qglobal.h:2482
QFile::FileError error() const
Returns the QFile::FileError that resulted from the last failed operation.
QString toString()
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ setSize()

bool QFSFileEngine::setSize ( qint64  size)
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 996 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName(), and setPermissions().

997 {
999  bool ret = false;
1000  if (d->fd != -1)
1001  ret = QT_FTRUNCATE(d->fd, size) == 0;
1002  else if (d->fh)
1003  ret = QT_FTRUNCATE(QT_FILENO(d->fh), size) == 0;
1004  else
1005  ret = QT_TRUNCATE(d->fileEntry.nativeFilePath().constData(), size) == 0;
1006  if (!ret)
1008  return ret;
1009 }
void setError(QFile::FileError error, const QString &str)
Sets the error type to error, and the error string to errorString.
double d
Definition: qnumeric_p.h:62
QString qt_error_string(int errorCode)
Definition: qglobal.cpp:2600
#define Q_D(Class)
Definition: qglobal.h:2482
qint64 size() const
Reimplemented Function
int errno
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ size()

qint64 QFSFileEngine::size ( ) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 493 of file qfsfileengine.cpp.

494 {
495  Q_D(const QFSFileEngine);
496  return d->nativeSize();
497 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ supportsExtension()

bool QFSFileEngine::supportsExtension ( Extension  extension) const
virtual

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 858 of file qfsfileengine.cpp.

859 {
860  Q_D(const QFSFileEngine);
861  if (extension == AtEndExtension && d->fh && isSequential())
862  return true;
863  if (extension == FastReadLineExtension && d->fh)
864  return true;
865  if (extension == FastReadLineExtension && d->fd != -1 && isSequential())
866  return true;
868  return true;
869  return false;
870 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool isSequential() const
Reimplemented Function
bool extension(Extension extension, const ExtensionOption *option=0, ExtensionReturn *output=0)
Reimplemented Function
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

◆ tempPath()

QString QFSFileEngine::tempPath ( )
static

Returns the temporary path (i.

e., a path in which it is safe to store temporary files).

Definition at line 754 of file qfsfileengine_unix.cpp.

Referenced by QFSFileEnginePrivate::longFileName().

755 {
757 }

◆ write()

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

Reimplemented Function

Reimplemented from QAbstractFileEngine.

Definition at line 723 of file qfsfileengine.cpp.

724 {
726 
727  // On Windows' stdlib implementation, the results of calling fread and
728  // fwrite are undefined if not called either in sequence, or if preceded
729  // with a call to fflush().
730  if (d->lastIOCommand != QFSFileEnginePrivate::IOWriteCommand) {
731  flush();
732  d->lastIOCommand = QFSFileEnginePrivate::IOWriteCommand;
733  }
734 
735  return d->nativeWrite(data, len);
736 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool flush()
Reimplemented Function
static const char * data(const QByteArray &arr)
The QFSFileEngine class implements Qt&#39;s default file engine.
Definition: qfsfileengine.h:60

The documentation for this class was generated from the following files: