How do I SHORTEN a file without rewriting it?

Laird Broadfield lairdb at crash.cts.com
Sat Oct 27 10:12:09 AEST 1990


In article <2830 at lectroid.sw.stratus.com> bad at atrain.sw.stratus.com (Bruce Dumes) writes:
>In article <1162 at bilver.UUCP> 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.
>
>Have you thought about using ftruncate()?

Okay, tell us where in K&R you find ftruncate.  I don't see it in
the TurboC manual, or K&R2.  Perhaps YOUR funky.lib has it, but not
everyone's does.  

As long as we're on the subject, does anyone have a neat-o method for
getting rid of records from the _beginning_ of a file?  (Standard preferred,
but if there's an MSDOS way, I'll accept it....)


-- 
--  Laird P. Broadfield                        | Year after year, site after
    UUCP: {akgua, sdcsvax, nosc}!crash!lairdb  | site, and I still can't think
    INET: lairdb at crash.cts.com                 | of a funny enough .sig.



More information about the Comp.lang.c mailing list