Update Hard-Link Stream, Preserve Links

Consider that A.txt and B.txt are hard-links that point to the same data stream. If I want to update that data stream without losing the links, I may use the batch command type New.txt > A.txt or type New.txt > B.txt.

On my tests, this worked fine, but the speed is very slow (in comparison to a simple copy operation). I guess there is some huge overhead in that operation.

I tried to write something similar on PowerShell, in case it were faster, but I could not, because PowerShell garbled the binary data by forcing its default encoding on the redirected output.

From reading Opus' documentation, it seems there is native support only for creating hard-links, not for something like I described above.

Considering scripting, do you think it would be possible to do that operation (update hard-link stream, preserve link) using the blob object? Even for huge movie files? (If the blob is read all to memory, I think it won't be suitable.)

If not, do you have any suggestion of alternative?

You should be able to use the scripting File and Blob objects for that.

You don't have to read the entire file into memory (as long as you are careful that you are not trying to replace a file with itself, which can be complicated if hardlinks are involved). You can read a chunk of the input file, write that out, then read another chunk. As long as the chunks aren't too small, the overhead of controlling it from a scripting language shouldn't be too bad.

Note that File.Truncate exists to let you open an existing file and then wipe its data before writing new data into it.