diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2009-08-11 16:11:23 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@trolltech.com> | 2009-08-11 16:20:44 (GMT) |
commit | 0e193b51c995395c92f8b1d0b67a782314772c6c (patch) | |
tree | cf93150762d2a3ac486d8ca246a7caa57bff61d8 | |
parent | bcbaeff0332e30f020f031b99efcc69d9707f962 (diff) | |
download | Qt-0e193b51c995395c92f8b1d0b67a782314772c6c.zip Qt-0e193b51c995395c92f8b1d0b67a782314772c6c.tar.gz Qt-0e193b51c995395c92f8b1d0b67a782314772c6c.tar.bz2 |
avoid needless const_cast-s
tried_stat, could_stat, need_lstat, and is_link are members marked as mutable;
prefer mutable over const_cast
Merge-request: 1176
Reviewed-by: Joerg Bornemann <joerg.bornemann@trolltech.com>
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index cde5272..029d422 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -524,18 +524,19 @@ QFileInfoList QFSFileEngine::drives() bool QFSFileEnginePrivate::doStat() const { - if (tried_stat == 0) { - QFSFileEnginePrivate *that = const_cast<QFSFileEnginePrivate*>(this); + if (!tried_stat) { + tried_stat = true; + could_stat = false; + if (fh && nativeFilePath.isEmpty()) { // ### actually covers two cases: d->fh and when the file is not open - that->could_stat = (QT_FSTAT(fileno(fh), &st) == 0); + could_stat = (QT_FSTAT(QT_FILENO(fh), &st) == 0); } else if (fd == -1) { // ### actually covers two cases: d->fh and when the file is not open - that->could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0); + could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0); } else { - that->could_stat = (QT_FSTAT(fd, &st) == 0); + could_stat = (QT_FSTAT(fd, &st) == 0); } - that->tried_stat = 1; } return could_stat; } @@ -543,10 +544,10 @@ bool QFSFileEnginePrivate::doStat() const bool QFSFileEnginePrivate::isSymlink() const { if (need_lstat) { - QFSFileEnginePrivate *that = const_cast<QFSFileEnginePrivate *>(this); - that->need_lstat = false; + need_lstat = false; + QT_STATBUF st; // don't clobber our main one - that->is_link = (QT_LSTAT(nativeFilePath.constData(), &st) == 0) ? S_ISLNK(st.st_mode) : false; + is_link = (QT_LSTAT(nativeFilePath.constData(), &st) == 0) ? S_ISLNK(st.st_mode) : false; } return is_link; } |