Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileInfo::isExecutable() returns true for dirs
Forum Updated to NodeBB v4.3 + New Features

QFileInfo::isExecutable() returns true for dirs

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dimsedane
    wrote on last edited by
    #1

    I am using the following code to search all subdirs for executables.

    @QDir dir(path);
    QDirIterator iterator(dir.absolutePath(), QDirIterator::Subdirectories);
    while (iterator.hasNext()) {
    iterator.next();
    if(!iterator.fileInfo().isDir() && iterator.fileInfo().isExecutable()) {
    tests.append(new QFile(iterator.filePath()));
    qDebug() << iterator.filePath();
    emit locatedTest(iterator.fileName());
    }
    }@

    That works fine, however if i remove the isDir() check, all directories, including . and .., are printed aswell. Is this a bug, or is there some reason I don't understand?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mario
      wrote on last edited by
      #2

      Well, on Unix most directories are marked as executable which means that you have permission to 'change directory' in to the dir.

      For example 'ls -l' give following output:
      drwxr-xr-x+ ... Documents
      drwx------+ ... Downloads

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dimsedane
        wrote on last edited by
        #3

        Then there was in fact a reason I did not understand, many thanks!

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mario
          wrote on last edited by
          #4

          You could try changing the permission on a directory to see if I'm right but I'm quite sure that this is the expected behavior.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved