At 2004-08-08T12:10:15+1200, Volker Kuhlmann wrote:
> > If you're dead set against copying the file, use a pipe.
> How does a pipe not mean copying the file? In this case I can't copy
> the file, as it contains a disk I/O error 2GB into a 4GB file. To keep
> the error contained in a small file I chopped the end, but wouldn't
> mind getting another 2GB of usable disk space back from the front. Of
> course I could just stop playing and write over it.
A pipe won't work in the case you've outlined above. It will work in
the case that you need to provide the middle part of the file to another
program. If you'd provided those details in your original post, I
would've said:
If the only reason you're trying to do this is to minimize the size of
the file affected by a media error and you plan to leave the file on
disk to stop the bad block(s) being reallocated, you're going about this
the wrong way.
Calculate the filesystem block number(s) that are affected by the media
error and add them to the filesystem's bad block list. If you need to
recovery the good data from the file, you might be able to get away with
leaving the file on disk once the block(s) have been added to the bad
blocks list--if you don't care about the rest of the data, remove the
file.
But going back to the generic 'can I truncate the beginning of a file'
question, the answer is (as has been said): not easily. Some systems
will provide an alternative to the {,f}truncate library calls that allow
you to do this, but it's not portable, and requires filesystem-specific
support to do it.
Cheers,
-mjg
--
Matthew Gregan |/
/| [EMAIL PROTECTED]