🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #332

Re: Truncate a file in MS-DOS with Borland C or C++

#332
From: Joao Prospero Luis [ps]
Date: Tue, 25 Aug 1992 10:54
24 lines
1561 bytes
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().
>
>   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.

	Hope this helps,

	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
Technical Details
Message-ID: <JPL.92Aug25105414@antares.fct.unl.pt>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!inesc.inesc.pt!dec4pt.puug.pt!unl!unl!jpl
References: <172@chorus.chorus.fr>

Show Full Headers
Complete Article Headers
Newsgroups: alt.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!inesc.inesc.pt!dec4pt.puug.pt!unl!unl!jpl
From: jpl@fct.unl.pt (Joao Prospero Luis [ps])
Subject: Re: Truncate a file in MS-DOS with Borland C or C++
In-Reply-To: mir@opera.chorus.fr's message of 24 Aug 92 11:57:47 GMT
Message-ID: <JPL.92Aug25105414@antares.fct.unl.pt>
Followup-To: alt.msdos.programmer
Sender: news@fct.unl.pt (USENET News System)
Organization: Universidade Nova de Lisboa -- Lisbon, Portugal
References: <172@chorus.chorus.fr>
Date: Tue, 25 Aug 1992 10:54:14 GMT
Lines: 25