Article 134795 of comp.os.vms: Path: nntpd.lkg.dec.com!crl.dec.com!crl.dec.com!caen!reeve.research.aa.wl.com!decwrl!lll-winken.llnl.gov!uwm.edu!homer.alpha.net!mvb.saic.com!info-vax From: "GWDGV1::MOELLER" Newsgroups: comp.os.vms Subject: RE: How to truncate files in C? Message-ID: <66127964@MVB.SAIC.COM> Date: Fri, 24 Nov 1995 19:17:46 +0100 Organization: Info-Vax<==>Comp.Os.Vms Gateway X-Gateway-Source-Info: Mailing List Lines: 31 P A Keller writes: > This may sound a stupid question, but how do you truncate an existing file > in C? >[...] > (Also, this is not the first time that I have found myself > wishing that there was a way to get at the FAB of a file which has been > opened with open/fopen). 2nd point first: VAXCRTL seems to have an undocumented entry int _fstat(int /*fd*/, FAB **, NAM **) or int _fstat(int /*fd*/, FAB **, NAM **, RAB**) which returns pointers to FAB, NAM, and (optionally) RAB associated with a file descriptor (= fileno(FILE *)). The DECC RTL doesn't have _fstat(), instead it supports an "access callback" among the optional parameters to open() etc., which ought to be useful for picking up FAB and RAB pointers (didn't explore this feature yet). Neither library seems to support truncation of stream files (accessed via RMS block I/O, as opposed to files opened in record mode, where "normal" RMS behaviour ought to apply); I understand that RMS can't truncate them (at an arbitrary byte position) either. VAXCRTL contains _unreachable_ code for truncation of disk files that makes use of the ACP/QIO interface - sad but true. Wolfgang J. Moeller, Tel. +49 551 2011516 or -510, moeller@gwdgv1.dnet.gwdg.de GWDG, D-37077 Goettingen, F.R.Germany PSI%(0262)45050859008::MOELLER Disclaimer: No claim intended! | moeller@decus.decus.de w.moeller@ieee.org