3

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?

scopchanov
  • 7,966
  • 10
  • 40
  • 68
Amy jonas
  • 91
  • 6

1 Answers1

5

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.

scopchanov
  • 7,966
  • 10
  • 40
  • 68