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. QFile::copy() doesn't keep "last modified time"?

QFile::copy() doesn't keep "last modified time"?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 2.2k Views
  • 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.
  • ChunKai-WangC Offline
    ChunKai-WangC Offline
    ChunKai-Wang
    wrote on last edited by ChunKai-Wang
    #1

    Hi,

    Just consulting that does anyone knows
    how to keep a file's "last modified time"
    after QFile::copy copy it to somewhere?

    On windows, that seems no problem,
    copied files can keep it's original "last modified time",

    But on Linux(ubuntu 14.04),
    the "last modified time" would be updated to the time when it was copied.

    I thought the "copy" should keep all info of file including "last modified time", but seems it doesn't on Linux(ubuntu14.04)?

    So I would like to consult that does anyone knows the problem of copy and "last modified time" on Linux(ubuntu 14.04)?

    Thanks~

    • list item
    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      It is not a problem. You have created a new file with the same content as the original. It was last accessed and modified shortly after it was created, and the time stamps reflect that.

      You can use the POSIX standard utime() function to set the modification and access times on a file. You can get these time stamps for the original file from a QFileInfo object or using the POSIX utimes() function (may be easier).

      ChunKai-WangC 1 Reply Last reply
      0
      • C ChrisW67

        It is not a problem. You have created a new file with the same content as the original. It was last accessed and modified shortly after it was created, and the time stamps reflect that.

        You can use the POSIX standard utime() function to set the modification and access times on a file. You can get these time stamps for the original file from a QFileInfo object or using the POSIX utimes() function (may be easier).

        ChunKai-WangC Offline
        ChunKai-WangC Offline
        ChunKai-Wang
        wrote on last edited by
        #3

        Hi @ChrisW67 ,

        ...You can use the POSIX standard utime() function to set the modification and access times on a file...

        Thank you, that works~

        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