Frage

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.

War es hilfreich?

Lösung

The environment is messed up for letting the mkdir routine create readable directories, as sky pointed out in the comments perfectly.

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top