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. Check if file can be renamed without copying
Forum Updated to NodeBB v4.3 + New Features

Check if file can be renamed without copying

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.0k Views 2 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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by Violet Giraffe
    #1

    QFile::rename description says:

    If the rename operation fails, Qt will attempt to copy this file's contents to newName, and then remove this file, keeping only newName.

    That is undesirable. I need to call QFile::rename only if the file can be renamed without copying (e. g. remains on the same disk drive on Windows). Is there a function in Qt that can perform this check (without me having to code it manually for every platform)?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on last edited by
      #2

      Look at QFSFileEngine. I think its rename should do what you want.

      V 1 Reply Last reply
      0
      • A alex_malyu

        Look at QFSFileEngine. I think its rename should do what you want.

        V Offline
        V Offline
        Violet Giraffe
        wrote on last edited by
        #3

        @alex_malyu, it seems that QFSFileEngine has been removed from Qt 5.

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

          Hi,

          No, it's there but it's a private class

          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
          0
          • V Offline
            V Offline
            Violet Giraffe
            wrote on last edited by Violet Giraffe
            #5

            I'm not making that distinction. Not in the public API => not available.
            I guess I'll use PathGetDriveNumber on Windows and stat on Unix to get the storage device number/id and compare IDs to determine if 2 paths belong to the same device.

            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