Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: Re: truncating a file opened via open() Message-ID: <2330@sun.uucp> Date: Thu, 20-Jun-85 06:03:02 EDT Article-I.D.: sun.2330 Posted: Thu Jun 20 06:03:02 1985 Date-Received: Sun, 23-Jun-85 00:59:37 EDT References: <340@cmu-cs-edu1.ARPA> <786@turtlevax.UUCP> <217@luke.UUCP> <2315@sun.uucp> <126@maynard.UUCP> Organization: Sun Microsystems, Inc. Lines: 20 > > 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). Actually, it was meant as a hint to various vendors, some of whom may be long-distance carriers... > > 2) Copy the entire file, up to the point of truncation, to a temporary > > file, then copy it back to the original file. > I don't see how this works unless you unlink the file and then re-creat > it before writing it back. Why unlink it? Re-"creat"ing will do the job - it truncates the file to zero length (unless you don't have write permission, which is unlikely unless the file is newly created and you created it without giving yourself write permission). Guy Harris