how to change the read only files and subdirectories to writable in QT
-
I have a directory which has a sub directory
ls Dir
A -- directory
B -- directory
C -- directory
file -I have to make all the sub directories and file as writable in the directory
-
Is it really so hard to take a quick look at the documentation esp. since you were already hinted to the needed functions in the former thread?
http://doc.qt.io/qt-5/qfile.html#setPermissions -
Is it really so hard to take a quick look at the documentation esp. since you were already hinted to the needed functions in the former thread?
http://doc.qt.io/qt-5/qfile.html#setPermissionsI have modified the question
Please let me know the answer -
I have modified the question
Please let me know the answerI don't see what I should add to my answer... permissions for a directory can be modified with QFile::setPermissions() too.
-
I have modified the question
Please let me know the answer@Qt-Enthusiast
You will use http://doc.qt.io/qt-5/qdir.html#entryList-1 to get a list of the files & sub-directories in the top-level directory.You will create
QFile
s on each of the returned paths, and use http://doc.qt.io/qt-5/qfile.html#setPermissions to set each file/directory's permissions.You will need to decide whether your intention is to recurse down each sub-directory and repeat the procedure on each of their children, or whether you only wish to set the top-level permissions in the hierarchy.
You do not say which OS you are on, which is relevant to this question. If it's Linux this is OK. If it's Windows, AFAIK you cannot set directories read-only, or it has no effect. If you want to do this for Windows you will need to address ACLs, which is outside of Qt's scope.
-
I will using linux and windows both versions
-
I will using linux and windows both versions
@Qt-Enthusiast
Then for Windows, what is it you expect to achieve on directories?OIC, you want to make them writeable, not read-only. Then that's maybe fine, I don't think you will find under Windows that your directories start read-only anyway? But if your intention is to make it so under Windows the user can now write into sub-directories where they cannot at present, then no amount of
setPermissions()
will achieve that, so you need to clarify what the starting situation is exactly?