Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Copy a file with Read and Write Permissions
Forum Updated to NodeBB v4.3 + New Features

Copy a file with Read and Write Permissions

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 2.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • carles.sole.grauC Offline
    carles.sole.grauC Offline
    carles.sole.grau
    wrote on last edited by carles.sole.grau
    #1

    Hi everybody,
    when I'm copying a file in c++ on Qt:

    QFile::copy( ":/myFolder/old.txt","./myFolder/new.txt");
    

    The new file has only Read Permissions,

    How can I convert this file to write too?

    Thank you very much

    1 Reply Last reply
    0
    • Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by
      #2

      Hi @carles.sole.grau,

      How can I convert this file to write too?

      I haven't tested this, but it looks like you would use QFile::setPermissions:

      QFile::copy( ":/myFolder/old.txt","./myFolder/new.txt");
      QFile::setPermissions("./myFolder/new.txt", QFileDevice::ReadOwner|QFileDevice::WriteOwner);
      

      Cheers.

      1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        QFile::setPermission is what you are looking for.

        Be aware of the warning about ACL.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • carles.sole.grauC Offline
          carles.sole.grauC Offline
          carles.sole.grau
          wrote on last edited by
          #4

          Yes, it works fine, thank you.

          ? 1 Reply Last reply
          0
          • carles.sole.grauC carles.sole.grau

            Yes, it works fine, thank you.

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @carles.sole.grau Hi! Please use the button "Topic Tools" to mark the topic as "solved".

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved