Merge files without copying their contents

(In C / C ++ / Linux)

Is there a way to combine file A and file B (or actually add one content A to B) only by changing the file system without the overhead of copying data? Then file A can be dropped.

thanks

+7
c ++ linux file file-io
source share
2 answers

If the files were block-structured, and if the OS supports block-structured files (as some do), then (in principle) yes. But, as you ask about Linux, I assume that you are talking about a file system with a byte stream, where the disk block may not be fully used. In this case, some copying is inevitable, and in practice you need to copy the entire file.

+7
source share

You can write your own file system (for example, using FUSE) that provides pseudo files for cheap concatenation. But I think that would be redundant (for any use case), since you need to take care of the links, etc.

+2
source share

All Articles