How do I SHORTEN a file without rewriting it?

Robert Thurlow thurlow at convex.com
Mon Oct 29 04:27:16 AEST 1990


In <5289 at crash.cts.com> lairdb at crash.cts.com (Laird Broadfield) writes:

>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.  

Take it easy, Laird.  ftruncate() is a Berkeley Unix system call, and
would probably have nothing to do with K&R or Turbo C in any case.
While it isn't all that useful to point to it without saying where it
comes from, there very well might have been a lookalike function in
someone's C library.  And there was no clue to readers of comp.lang.c
that Alex wanted an MS-DOS solution.

Some people don't think enough about the fact that C is everywhere,
and that <insert your OS of choice here> is not reflective of the way
the whole world works.  It annoys me wherever I see it.  Bruce didn't
qualify where he found ftruncate(), but Alex committed an equal crime
by not saying he needed a very operating-system-dependent call on
MS-DOS, not BSD 4.3.  Some people get really confused between language
features and standard library routines and system calls, as well.  All
we can do is try to add to the information, rather than bitch because
people are talking about something Turbo C doesn't happen to support.

Rob T
--
Rob Thurlow, thurlow at convex.com or thurlow%convex.com at uxc.cso.uiuc.edu
----------------------------------------------------------------------
"This opinion was the only one available; I got here kind of late."



More information about the Comp.lang.c mailing list