home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / alt / msdos / programm / 2276 < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.5 KB  |  39 lines

  1. Newsgroups: alt.msdos.programmer
  2. Path: sparky!uunet!mcsun!inesc.inesc.pt!dec4pt.puug.pt!unl!unl!jpl
  3. From: jpl@fct.unl.pt (Joao Prospero Luis [ps])
  4. Subject: Re: Truncate a file in MS-DOS with Borland C or C++
  5. In-Reply-To: mir@opera.chorus.fr's message of 24 Aug 92 11:57:47 GMT
  6. Message-ID: <JPL.92Aug25105414@antares.fct.unl.pt>
  7. Followup-To: alt.msdos.programmer
  8. Sender: news@fct.unl.pt (USENET News System)
  9. Organization: Universidade Nova de Lisboa -- Lisbon, Portugal
  10. References: <172@chorus.chorus.fr>
  11. Date: Tue, 25 Aug 1992 10:54:14 GMT
  12. Lines: 25
  13.  
  14. In article <172@chorus.chorus.fr> mir@opera.chorus.fr (Adam Mirowski) writes:
  15.  
  16. >   Trying to make a file restoration utility, I recently noti-
  17. >   ced that there is no library call in Borland C and C++ to
  18. >   truncate a file. No truncate() and no ftruncate().
  19. >
  20. >   Is there a clever trick to do to obtain that? I only need
  21. >   to change the size within the last cluster range: basically
  22. >   I want to bring a FILExxxx.CHK to its previous (and separately
  23. >   saved) name/size/date/time/attributes, etc.
  24.  
  25.     Do a seek to the location where you want the file truncated
  26. and write zero bytes.
  27.     This only works if the call (write, fwrite whatever) really
  28. does an INT 21h to write zero bytes.
  29.  
  30.     Hope this helps,
  31.  
  32.     JPL
  33. --
  34. Joao Prospero Luis                | BITNET/Internet: jpl@fct.unl.pt
  35. Universidade Nova de Lisboa       |            UUCP: jpl@unl.uucp
  36. FCT - Dpto. de Informatica        | Fax:   (+351) (1) 295-5641
  37. 2825 Monte Caparica, PORTUGAL     | Phone: (+351) (1) 295-4464
  38.  
  39.