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. How to check if a folder is writable using Qt?
Forum Updated to NodeBB v4.3 + New Features

How to check if a folder is writable using Qt?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.7k 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.
  • S Offline
    S Offline
    Samananda
    wrote on last edited by
    #1

    I have tried the code, it is not working. it always satisfy the below conditional for all path whether it has write permission or not. what is the the other way to check whether the folder had write permission or not?

    QFileInfo my_dir(folderName);

    if(my_dir.isDir() && my_dir.isWritable()){
    // Do something
    }

    JonBJ 2 Replies Last reply
    0
    • S Samananda

      I have tried the code, it is not working. it always satisfy the below conditional for all path whether it has write permission or not. what is the the other way to check whether the folder had write permission or not?

      QFileInfo my_dir(folderName);

      if(my_dir.isDir() && my_dir.isWritable()){
      // Do something
      }

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Samananda
      All sorts of questions, since you don't say what OS/filing system, whether NTFS etc etc. https://doc.qt.io/qt-5/qfileinfo.html#permission may help you. Then if you are Windows there is also http://doc.qt.io/qt-4.8/qfile.html#platform-specific-issues to bear in mind.

      It is even possible that you won't really know whether a directory is "writeable" till you try to create (e.g. a temporary) file/folder there and see what happens. NTFS, if that's what you're on, has a shed-load of possible sub-permissions, Windows has "restricted" folders...

      S 1 Reply Last reply
      4
      • S Samananda

        I have tried the code, it is not working. it always satisfy the below conditional for all path whether it has write permission or not. what is the the other way to check whether the folder had write permission or not?

        QFileInfo my_dir(folderName);

        if(my_dir.isDir() && my_dir.isWritable()){
        // Do something
        }

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • JonBJ JonB

          @Samananda
          All sorts of questions, since you don't say what OS/filing system, whether NTFS etc etc. https://doc.qt.io/qt-5/qfileinfo.html#permission may help you. Then if you are Windows there is also http://doc.qt.io/qt-4.8/qfile.html#platform-specific-issues to bear in mind.

          It is even possible that you won't really know whether a directory is "writeable" till you try to create (e.g. a temporary) file/folder there and see what happens. NTFS, if that's what you're on, has a shed-load of possible sub-permissions, Windows has "restricted" folders...

          S Offline
          S Offline
          Samananda
          wrote on last edited by Samananda
          #4

          @JonB Thanks for the information.

          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