*/
/*!
- \enum QAbstractFileEngine::FileFlag
-
- The permissions and types of a file, suitable for OR'ing together.
-
- \value ReadOwnerPerm The owner of the file has permission to read
- it.
- \value WriteOwnerPerm The owner of the file has permission to
- write to it.
- \value ExeOwnerPerm The owner of the file has permission to
- execute it.
- \value ReadUserPerm The current user has permission to read the
- file.
- \value WriteUserPerm The current user has permission to write to
- the file.
- \value ExeUserPerm The current user has permission to execute the
- file.
- \value ReadGroupPerm Members of the current user's group have
- permission to read the file.
- \value WriteGroupPerm Members of the current user's group have
- permission to write to the file.
- \value ExeGroupPerm Members of the current user's group have
- permission to execute the file.
- \value ReadOtherPerm All users have permission to read the file.
- \value WriteOtherPerm All users have permission to write to the
- file.
- \value ExeOtherPerm All users have permission to execute the file.
-
- \value LinkType The file is a link to another file (or link) in
- the file system (i.e. not a file or directory).
- \value FileType The file is a regular file to the file system
- (i.e. not a link or directory)
- \value DirectoryType The file is a directory in the file system
- (i.e. not a link or file).
-
- \value HiddenFlag The file is hidden.
- \value ExistsFlag The file actually exists in the file system.
- \value RootFlag The file or the file pointed to is the root of the filesystem.
- \value LocalDiskFlag The file resides on the local disk and can be passed to standard file functions.
- \value Refresh Passing this flag will force the file engine to refresh all flags.
-
- \omitvalue PermsMask
- \omitvalue TypesMask
- \omitvalue FlagsMask
- \omitvalue FileInfoAll
-
- \sa fileFlags(), setFileName()
-*/
-
-/*!
\enum QAbstractFileEngine::FileTime
These are used by the fileTime() function.
{
Q_D(const QAbstractFileEngine);
+ d->metaData.clear();
if (!d->doStat(QFileSystemMetaData::SizeAttribute))
return 0;
return d->metaData.size();
relative path; otherwise return false.
\sa setFileName()
- */
+*/
bool QAbstractFileEngine::isRelativePath() const
{
Q_D(const QAbstractFileEngine);
}
/*!
- Return the set of OR'd flags that are true for the file engine's
- file, and that are in the \a type's OR'd members.
-
- \sa setFileName()
+ Return true if the file referred to by this file engine exists;
+ otherwise return false.
*/
-QAbstractFileEngine::FileFlags QAbstractFileEngine::fileFlags(FileFlags type) const
+bool QAbstractFileEngine::exists() const
{
Q_D(const QAbstractFileEngine);
+ d->metaData.clear(); // always stat
+ if (!d->doStat(QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::FileType))
+ return false;
+ return d->metaData.exists() && d->metaData.isFile();
+}
- if (type & Refresh)
- d->metaData.clear();
-
- QAbstractFileEngine::FileFlags ret = 0;
-
- if (type & FlagsMask)
- ret |= LocalDiskFlag;
-
- QFileSystemMetaData::MetaDataFlags queryFlags =
- QFileSystemMetaData::MetaDataFlags(uint(type))
- & QFileSystemMetaData::Permissions;
- queryFlags |= QFileSystemMetaData::LinkType;
-
- if (type & TypesMask)
- queryFlags |= QFileSystemMetaData::LinkType
- | QFileSystemMetaData::FileType
- | QFileSystemMetaData::DirectoryType;
-
- if (type & FlagsMask)
- queryFlags |= QFileSystemMetaData::HiddenAttribute
- | QFileSystemMetaData::ExistsAttribute;
-
- bool exists = d->doStat(queryFlags);
+/*!
+ Return the set of permissions for the file engine's file.
+ \sa setFileName()
+*/
+QFile::Permissions QAbstractFileEngine::permissions() const
+{
+ Q_D(const QAbstractFileEngine);
+ bool exists = d->doStat(QFileSystemMetaData::Permissions | QFileSystemMetaData::LinkType);
if (!exists && !d->metaData.isLink())
- return ret;
-
- if (exists && (type & PermsMask))
- ret |= FileFlags(uint(d->metaData.permissions()));
-
- if (type & TypesMask) {
- if ((type & LinkType) && d->metaData.isLink())
- ret |= LinkType;
- if (exists) {
- if (d->metaData.isFile()) {
- ret |= FileType;
- } else if (d->metaData.isDirectory()) {
- ret |= DirectoryType;
- }
- }
- }
-
- if (type & FlagsMask) {
- if (exists)
- ret |= ExistsFlag;
- if (d->fileEntry.isRoot())
- ret |= RootFlag;
- else if (d->metaData.isHidden())
- ret |= HiddenFlag;
- }
-
- return ret;
+ return 0;
+ return d->metaData.permissions();
}
/*!
#ifndef QABSTRACTFILEENGINE_H
#define QABSTRACTFILEENGINE_H
-#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qdatetime.h>
#ifdef open
#error qabstractfileengine.h must be included before any header file that defines open
class Q_CORE_EXPORT QAbstractFileEngine
{
public:
- enum FileFlag {
- //perms (overlaps the QFile::Permission)
- ReadOwnerPerm = 0x4000, WriteOwnerPerm = 0x2000, ExeOwnerPerm = 0x1000,
- ReadUserPerm = 0x0400, WriteUserPerm = 0x0200, ExeUserPerm = 0x0100,
- ReadGroupPerm = 0x0040, WriteGroupPerm = 0x0020, ExeGroupPerm = 0x0010,
- ReadOtherPerm = 0x0004, WriteOtherPerm = 0x0002, ExeOtherPerm = 0x0001,
-
- //types
- LinkType = 0x10000,
- FileType = 0x20000,
- DirectoryType = 0x40000,
-
- //flags
- HiddenFlag = 0x0100000,
- LocalDiskFlag = 0x0200000,
- ExistsFlag = 0x0400000,
- RootFlag = 0x0800000,
- Refresh = 0x1000000,
-
- //masks
- PermsMask = 0x0000FFFF,
- TypesMask = 0x000F0000,
- FlagsMask = 0x0FF00000,
- FileInfoAll = FlagsMask | PermsMask | TypesMask
- };
- Q_DECLARE_FLAGS(FileFlags, FileFlag)
-
enum FileName {
DefaultName,
BaseName,
bool link(const QString &newName);
bool setSize(qint64 size);
bool isRelativePath() const;
- FileFlags fileFlags(FileFlags type) const;
+ bool exists() const;
+ QFile::Permissions permissions() const;
bool setPermissions(uint perms);
QString fileName(FileName file) const;
uint ownerId(FileOwner) const;
friend class QFilePrivate;
};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFileEngine::FileFlags)
QT_END_NAMESPACE
bool
QFile::exists() const
{
- // 0x1000000 = QAbstractFileEngine::Refresh, forcing an update
- const QAbstractFileEngine::FileFlags flags = fileEngine()->fileFlags(QAbstractFileEngine::Refresh
- | QAbstractFileEngine::FlagsMask);
- const QAbstractFileEngine::FileFlags type = fileEngine()->fileFlags(QAbstractFileEngine::Refresh
- | QAbstractFileEngine::TypesMask);
- return ((flags & QAbstractFileEngine::ExistsFlag) && (type & QAbstractFileEngine::FileType));
+ return fileEngine()->exists();
}
/*!
QFile::Permissions QFile::permissions() const
{
- QAbstractFileEngine::FileFlags perms = fileEngine()->fileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask;
- return QFile::Permissions((int)perms); //ewww
+ return fileEngine()->permissions();
}
/*!
qint64 QFile::size() const
{
- Q_D(const QFile);
- fileEngine()->fileFlags(QAbstractFileEngine::Refresh);
- return d->fileEngine->size();
+ return fileEngine()->size();
}
/*!