How do I SHORTEN a file without rewriting it?
Michael Henning
michi at ptcburp.ptcbu.oz.au
Thu Oct 25 15:59:06 AEST 1990
alex at bilver.UUCP (Alex Matulich) writes:
>Is there a way to shorten a file, that is, chop some data off the end of
>it, so that it doesn't consume as much physical space on the disk? The
>file I have is too big to read into memory and write back out again, and
>there is not enough room on the disk to write out a temporary file.
Ftruncate() (BSD call) will do the job. Under AIX (maybe others), there
is an fclear() call that allows you to punch holes into a file at arbitrary
places. The blocks corresponding the hole(s) are returned to the file system.
In SysV.4, you can use fntl() to do the same.
Michi.
--
-m------- Michael Henning +61 75 950255
---mmm----- Pyramid Technology +61 75 522475 FAX
-----mmmmm--- Research Park, Bond University michi at ptcburp.ptcbu.oz.au
-------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA uunet!munnari!ptcburp.oz!michi
More information about the Comp.lang.c
mailing list