Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/3/84; site maynard.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!talcott!wjh12!maynard!campbell From: campbell@maynard.UUCP (Larry Campbell) Newsgroups: net.unix-wizards Subject: Re: Re: truncating a file opened via open() Message-ID: <126@maynard.UUCP> Date: Wed, 19-Jun-85 08:03:49 EDT Article-I.D.: maynard.126 Posted: Wed Jun 19 08:03:49 1985 Date-Received: Sun, 23-Jun-85 08:38:41 EDT References: <340@cmu-cs-edu1.ARPA> <786@turtlevax.UUCP> <217@luke.UUCP> <2315@sun.uucp> Organization: The Boston Software Works Inc., Maynard, MA Lines: 24 > > >In article <340@cmu-cs-edu1.ARPA> hua@cmu-cs-edu1.ARPA (Ernest Hua) writes: > > >>Does anyone have any idea how to truncate a file at the current point in > > >>writing if it is opened by open()? > > There are precisely two solutions for non-4.2BSD systems: > 1) implement (f)truncate on your system... Kind of tough for people without source licenses (I know, I'm whining). > 2) Copy the entire file, up to the point of truncation, to a temporary file, > then copy it back to the original file. > > Guy Harris I don't see how this works unless you unlink the file and then re-creat it before writing it back. But the original question implied you only had a descriptor for the file, not a name... so you can't unlink or re-creat it. And even if you knew the name, other links wouldn't get truncated. Sounds like it's pretty tough to fake this one ... sigh ... - Larry Campbell The Boston Software Works, Inc., 120 Fulton St., Boston MA 02109 UUCP: {decvax, security, linus, mit-eddie}!genrad!enmasse!maynard!campbell ARPA: decvax!genrad!enmasse!maynard!campbell@DECWRL.ARPA