Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to copy ONLY the updated data from a large file?

How to copy ONLY the updated data from a large file?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 3 Posters 0 Views 1 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.
  • J Offline
    J Offline
    jahfer
    wrote on last edited by
    #1

    Hello, I copied a large file from one disk(source) to another disk(destination). After this I made (manually or programmatically) some changes in the file on the source disk. Now, these changes should reflect in the file on the destination disk also. In order to achieve this, I copied the file again from source to destination. Since the file is a large one this method is not efficient. Because, for any minute change, I have to copy the entire thing. Is there any way to copy only the updated portion from the file on the source disk to the file on the destination disk? Hoping to get a reply soon. Thanks in advance. regards, Jahfer V P.

    K J 2 Replies Last reply
    0
    • J jahfer

      Hello, I copied a large file from one disk(source) to another disk(destination). After this I made (manually or programmatically) some changes in the file on the source disk. Now, these changes should reflect in the file on the destination disk also. In order to achieve this, I copied the file again from source to destination. Since the file is a large one this method is not efficient. Because, for any minute change, I have to copy the entire thing. Is there any way to copy only the updated portion from the file on the source disk to the file on the destination disk? Hoping to get a reply soon. Thanks in advance. regards, Jahfer V P.

      K Offline
      K Offline
      khan
      wrote on last edited by
      #2

      When you are making changes to the file, make another file (changes-file) also, with your own file format: Repeat (1) below for every change: 1- The size of data in four bytes (long int) then four bytes (long int) for offset into the file for the data, then the data. Write this into your "changes-file". Then when you need to update the destination file, repeat (2) below until the end of the file. 2- Read the "changes-file", and correctly read the length of data, offset of data, and the data. Then open the destination file in update mode, move into it at the correct offset, and write out the data you read from the "changes-file". Does that solve the problem? this is this.

      J 1 Reply Last reply
      0
      • K khan

        When you are making changes to the file, make another file (changes-file) also, with your own file format: Repeat (1) below for every change: 1- The size of data in four bytes (long int) then four bytes (long int) for offset into the file for the data, then the data. Write this into your "changes-file". Then when you need to update the destination file, repeat (2) below until the end of the file. 2- Read the "changes-file", and correctly read the length of data, offset of data, and the data. Then open the destination file in update mode, move into it at the correct offset, and write out the data you read from the "changes-file". Does that solve the problem? this is this.

        J Offline
        J Offline
        jahfer
        wrote on last edited by
        #3

        Dear khan++, That doesn't solve my problem, because I am not the person going to update the file. More over, the file may get updated not only at its end but anywhere in it. Any other idea? regards, Jahfer V P.

        K 1 Reply Last reply
        0
        • J jahfer

          Dear khan++, That doesn't solve my problem, because I am not the person going to update the file. More over, the file may get updated not only at its end but anywhere in it. Any other idea? regards, Jahfer V P.

          K Offline
          K Offline
          khan
          wrote on last edited by
          #4

          jahfer wrote: because I am not the person going to update the file I don't get it. The technique I gave can update the file anywhere in it, not just the end, that is why I asked for an offset field. I hope someone else can help as I am about to logout for the day. this is this.

          1 Reply Last reply
          0
          • J jahfer

            Hello, I copied a large file from one disk(source) to another disk(destination). After this I made (manually or programmatically) some changes in the file on the source disk. Now, these changes should reflect in the file on the destination disk also. In order to achieve this, I copied the file again from source to destination. Since the file is a large one this method is not efficient. Because, for any minute change, I have to copy the entire thing. Is there any way to copy only the updated portion from the file on the source disk to the file on the destination disk? Hoping to get a reply soon. Thanks in advance. regards, Jahfer V P.

            J Offline
            J Offline
            John M Drescher
            wrote on last edited by
            #5

            Here are a few links to tools that do this by sending only the differences between the two files. They both use the same rsync algorithm to determine what to send: http://samba.anu.edu.au/rsync/features.html[^] http://www.cis.upenn.edu/~bcpierce/unison/[^] John

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups