3 ms·
You can do it without a temporary file if your filesystem supports sparse files. Figure out the output size, and create a sparse file with that size. You'll be
by crote 6y ago
You can do it without a temporary file if your filesystem supports sparse files.
Figure out the output size, and create a sparse file with that size. You'll be able to use it like a regular file, but blocks will only take up space once you write to them.
Now simply copy from the input to the output file, starting at the end. Truncate the input file whenever the disk fills up.