Article View: alt.msdos.programmer
Article #340Re: Truncate a file in MS-DOS with Borland C or C++
From: Al Degenaar
Date: Fri, 28 Aug 1992 14:05
Date: Fri, 28 Aug 1992 14:05
36 lines
2001 bytes
2001 bytes
In <JPL.92Aug25105414@antares.fct.unl.pt> jpl@fct.unl.pt (Joao Prospero Luis [ps]) writes: >In article <172@chorus.chorus.fr> mir@opera.chorus.fr (Adam Mirowski) writes: >> Trying to make a file restoration utility, I recently noti- >> ced that there is no library call in Borland C and C++ to >> truncate a file. No truncate() and no ftruncate(). >> Did you try looking at chsize()? It performs the equivalent function and has been in borland at least since 2.0, probably longer. >> Is there a clever trick to do to obtain that? I only need >> to change the size within the last cluster range: basically >> I want to bring a FILExxxx.CHK to its previous (and separately >> saved) name/size/date/time/attributes, etc. > Do a seek to the location where you want the file truncated >and write zero bytes. > This only works if the call (write, fwrite whatever) really >does an INT 21h to write zero bytes. This would also work, but why give up portability... > JPL >-- >Joao Prospero Luis | BITNET/Internet: jpl@fct.unl.pt >Universidade Nova de Lisboa | UUCP: jpl@unl.uucp >FCT - Dpto. de Informatica | Fax: (+351) (1) 295-5641 >2825 Monte Caparica, PORTUGAL | Phone: (+351) (1) 295-4464 Al -- Albert W. Degenaar II work : awd@scscom.com SCS/Compute, Incorporated. other : awd@bold1.gatech.edu #include "standard.disclaimer" Phone : (404)368-1040
Technical Details
Message-ID:
<1992Aug28.140509.1634@atl.scscom.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!stanford.edu!hubcap!ncrcae!ncratl!scscom!awdReferences:
<172@chorus.chorus.fr> <JPL.92Aug25105414@antares.fct.unl.pt>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!stanford.edu!hubcap!ncrcae!ncratl!scscom!awd From: awd@atl.scscom.com (Al Degenaar) Newsgroups: alt.msdos.programmer Subject: Re: Truncate a file in MS-DOS with Borland C or C++ Message-ID: <1992Aug28.140509.1634@atl.scscom.com> Date: 28 Aug 92 14:05:09 GMT References: <172@chorus.chorus.fr> <JPL.92Aug25105414@antares.fct.unl.pt> Organization: SCS/Compute, Inc. Lines: 36