Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2803

QFileInfo::isReadable() and QDir::isReadable() inconsistent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.0
    • 4.3.2
    • Core: I/O
    • None

    Description

      The example program included inline demonstrates a problem I see with the implementations of the isReadable() methods on Linux. Assume a directory and a file with permissions 070, 060 resp. For both I am not the owner, but since I am a member of the same group "develop"
      as the owner, I am allowed to read the file and list the directory and
      change into the directory (which can be tested by using "cat" on the file and "ls" and "cd" on the directory).

      bernd@corot:~/incoming> ls -ld file dir
      d--rwx-- 2 andre develop 4096 2008-09-15 13:31 dir
      ---rw--- 1 andre develop 5 2008-09-15 13:29 file

      The output of the program is:

      fi1.isReadable 1
      fi2.isReadable 1
      dir.isReadable 0

      That means, QFileInfo correctly recognizes that I have read permissions on the file and the directory. From the implementation it becomes clear that this is due to Qt's usage of the POSIX access() function in QFileInfoPrivate::hasAccess().

      However, QDir works differently: it only evaluates the ReadUserPerm flag
      from the method QAbstractFileEngine::fileFlags() and doesn't take the group permissions into consideration.

      This difference is not evident from the documentation of the two methods. I would expect either that the implementation is changed accordingly or that the difference is explained more clearly.

      This all applies to both Qt 4.3.2, Qt 4.4.0 and Qt 4.4.1 on Linux.

      program code:

      #include <QtCore/QFileInfo>
      #include <QtCore/QDir>
      
      
      int main (int /*argc*/, char ** /*argv*/)
      {
        QFileInfo fi1 ("file");
      
        QFileInfo fi2 ("dir");
        QDir dir ("dir");
      
        qDebug ("fi1.isReadable %d", fi1.isReadable ());
        qDebug ("fi2.isReadable %d", fi2.isReadable ());
        qDebug ("dir.isReadable %d", dir.isReadable ());
      
        return 0;
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            biochimia João Abecasis
            dakovaci Daniel Kovacic
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes