I am trying to copy a game from a disk or USB flash drive to hard drive in my computer using Qt and I wanted to use QFile::copy
and it is important for me to keep the permissions like being executable and writable.
Do I have to use QFile::setPermissions
or the permissions are not changed by default in the copy function call?
QFile::copy
preserves the file permissions, as evidenced by the source code:
if(!error) {
QFile::setPermissions(newName, permissions());
close();
unsetError();
return true;
}
QFile::setPermissions(newName, permissions());
actually copies the permissions from the current file to the file named newName
. Hence, there is no need to do that manually.