Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!wuarchive!zaphod.mps.ohio-state.edu!think.com!spool.mu.edu!uunet!overload!dillon From: dillon@overload.Berkeley.CA.US (Matthew Dillon) Newsgroups: comp.sys.amiga.programmer Subject: Re: How do you truncate a file? Message-ID: Date: 5 May 91 21:55:23 GMT References: <1991May5.063352.6627@csusac.csus.edu> Distribution: usa Organization: Not an Organization Lines: 21 In article <1991May5.063352.6627@csusac.csus.edu> cilibrar@athena.ecs.csus.edu (Rudi Cilibrasi) writes: >Suppose that I have a 100-byte file, and I want to get rid of the last >ten bytes. Is there any way to do this other than freading in the >entire file and then fwriting out only 90 bytes of it? I'd like to find >a way to avoid having to read the whole file into memory. I've heard >that there is a function called ftruncate that does this, but my >compiler (Aztec C 5.0) doesn't have this one. (It also doesn't have >chsize, which was another suggestion) Thanks for any help. Under 2.0 there is a filesystem call, SetFileSize(), that will truncate or extend a file as requested. Under 1.3 you have to rewrite the file. -Matt -- Matthew Dillon dillon@Overload.Berkeley.CA.US 891 Regal Rd. uunet.uu.net!overload!dillon Berkeley, Ca. 94708 USA