views:

115

answers:

2

Hi,

(In C/C++/Linux)

Is there a way to concatenate file A and file B (or actually append one A's content to that of B) only by altering the file system without the overhead of data copying? File A then can be discarded.

Thanks

+7  A: 

If the files were block-structured, and if the OS supported block-structured files (as some do) then (in principle) yes. But as you are asking about Linux, I assume you are talking about a byte-stream oriented file system, where a disk block may not be completely used. In this case, some copying is inevitable and in practice you have to copy the whole file.

anon
+2  A: 

You could write your own file system (e.g. with FUSE) that provides pseudo files for cheap concatenation. But I guess that would be overkill (for any use case), as you have to care about references and stuff.

AndiDog