How to merge two files on NTFS by chaining the file's B-tree nodes to avoid reading any file

Viewed 117

I have the following challenge:

  • File1 is a huge file, let's say the the filesystem assigns it disk blocks [1, 2, 5]
  • File2 is another huge file, let's say the filesystem assigns it disk blocks [10, 15, 16, 18]

Traditional append opens File2 and copies it to the end of File1, so it ends up like

  • File1: [1, 2, 5], [30, 20, 40, 182] (it assigns and copies File2 blocks in new ones)
  • File2: [10, 15, 16, 18] (Will still be in use and assigned to File2)

I want to merge the two files without ever reading the files, let's say, getting File1 chain and consume File2, so it ends like up

  • File1: [1, 2, 5], [10, 15, 16, 18] (and File2 gets consumed in the process)

Do you know any API call to do that magic?

0 Answers
Related