Xref: utzoo comp.lang.c:33142 comp.os.msdos.programmer:1650 Path: utzoo!attcan!uunet!munnari.oz.au!brolga!bunyip.cc.uq.oz.au!lance!ptcburp!michi From: michi@ptcburp.ptcbu.oz.au (Michael Henning) Newsgroups: comp.lang.c,comp.os.msdos.programmer Subject: Re: How do I SHORTEN a file without rewriting it? Keywords: truncation Message-ID: <179@ptcburp.ptcbu.oz.au> Date: 25 Oct 90 05:59:06 GMT References: <1162@bilver.UUCP> Followup-To: comp.lang.c Organization: Pyramid Technology Corporation Lines: 19 alex@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@ptcburp.ptcbu.oz.au -------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA uunet!munnari!ptcburp.oz!michi