PDA

View Full Version : QDir::mkPath and Permissions



sky
25th October 2012, 10:03
Hi,

I am working on Ubuntu 12.04 LTS and 10.04 LTS platforms and I am having a problem with QDir::mkPath.
I am trying to create a path using mkPath, lets say /john/play/games and then copy a file game.htm to the /home/john/play. After I copy the file I set the permissions on the file to rwxr - - r - -. So that 3rd party applications can read the file game.htm. But the directories /john, /john/play and /john/play/games are created with permissions drwxr - x - - - due to which other applications and other users are not able to read the file game.htm.

I have also observed in a different application that the same QDir::mkpath creates the dir with drwxr - xr - x . I want to understand with what permissions does QDir::mkpath creates the directories and how to control or set the permissions.


Sky.

sky
2nd July 2013, 17:35
You could, however, use the umask() OS function to set the umask to something else before calling QDir::mkpath. You might have to #ifdef it out on windows though, though I suspect the umask() function may have been implemented in the mingw environment being used by qtcreator on wnidows. So it may work anyway.

Answer by Wes Hardaker on stackoverflow.