summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfsfileengine.cpp
diff options
context:
space:
mode:
authorJoão Abecasis <joao.abecasis@nokia.com>2010-09-03 18:17:35 (GMT)
committerJoão Abecasis <joao.abecasis@nokia.com>2010-09-03 18:39:50 (GMT)
commit4fd2aced96d9095254d89f9da9c911bd88f15245 (patch)
tree6a98f03fd019b401bf244fa053c6fca1f586303c /src/corelib/io/qfsfileengine.cpp
parent81b302d06c93b77127a2bd6ee527aeefadffbf64 (diff)
downloadQt-4fd2aced96d9095254d89f9da9c911bd88f15245.zip
Qt-4fd2aced96d9095254d89f9da9c911bd88f15245.tar.gz
Qt-4fd2aced96d9095254d89f9da9c911bd88f15245.tar.bz2
QFileSystemEngine::fillMetaData for Unix platforms
This shuffles a lot of code out of QFSFileEngine. fillMetaData, however is almost a reimplementation of the logic. Goals for this function are to maximize data gathered and minimize file system queries. Symbian had an optimization to lstat first and only stat again on links, having noticed a lot of lstat were being done that weren't really necessary. That optimization was also made in the new fillMetaData function and extended to all platforms, whenever the LinkType attribute is requested (QFSFileEngine will now typically request this in reply to a fileFlags request). We now try to cache all meta data we get from the file system, while still requesting "refreshes" as often as we did before. Client code going straight to QFileSystemEngine API can choose it's behaviour by clearing and querying specific flags in the QFileSystemMetaData instance. Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'src/corelib/io/qfsfileengine.cpp')
-rw-r--r--src/corelib/io/qfsfileengine.cpp33
1 files changed, 9 insertions, 24 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 5d7b354..1b0a28c 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -447,24 +447,13 @@ qint64 QFSFileEngine::size() const
qint64 QFSFileEnginePrivate::sizeFdFh() const
{
Q_Q(const QFSFileEngine);
- // ### Fix this function, it should not stat unless the file is closed.
- QT_STATBUF st;
- int ret = 0;
const_cast<QFSFileEngine *>(q)->flush();
- if (fh && fileEntry.isEmpty()) {
- // Buffered stdlib mode.
- // ### This should really be an ftell
- ret = QT_FSTAT(QT_FILENO(fh), &st);
- } else if (fd == -1) {
- // Stateless stat.
- ret = QT_STAT(fileEntry.nativeFilePath().constData(), &st);
- } else {
- // Unbuffered stdio mode.
- ret = QT_FSTAT(fd, &st);
- }
- if (ret == -1)
+
+ tried_stat = 0;
+ metaData.clearFlags(QFileSystemMetaData::SizeAttribute);
+ if (!doStat(QFileSystemMetaData::SizeAttribute))
return 0;
- return st.st_size;
+ return metaData.size();
}
#endif
@@ -773,18 +762,14 @@ bool QFSFileEngine::isSequential() const
/*!
\internal
*/
+#ifdef Q_OS_UNIX
bool QFSFileEnginePrivate::isSequentialFdFh() const
{
- if (!tried_stat)
- doStat();
- if (could_stat) {
-#ifdef Q_OS_UNIX
- return (st.st_mode & S_IFMT) != S_IFREG;
- // ### WINDOWS!
-#endif
- }
+ if (doStat(QFileSystemMetaData::SequentialType))
+ return metaData.isSequential();
return true;
}
+#endif
/*!
\reimp