[comp.sys.ibm.pc] Chopping an existing file

erdman@ncextb.ncsu.edu (erdman) (08/04/88)

   I am looking for a way to shorting the length of an existing file
without re-writing the whole file.  I know it can be done, dBase III's
"pack" appears to do this.  Are there any reliable ways to do this?
Any help would be appreciated.

Please send responses to:
   erdman%ncextb@ncsuvx.ncsu.edu

Thanks,
   Tom
 

las@apr.UUCP (Larry Shurr) (08/06/88)

In article <290@ncextb.ncsu.edu> erdman@ncextb.ncsu.edu (erdman) writes:

>   I am looking for a way to shorting the length of an existing file
>without re-writing the whole file.  I know it can be done, dBase III's
>"pack" appears to do this.  Are there any reliable ways to do this?
>Any help would be appreciated.

Seek to the position in the file where you wish to truncate it and
then request a zero-length write.

regards, Larry
-- 
Who: Larry A. Shurr (...!osu-cis!apr!las or try {cbosgd,ihnp4}!cbema!las)
What: "The only thing worse than being talked about is not being talked about."
Where: _The Portrait of Dorian Grey_ - Oscar Wilde
Disclaimer: The above is not necessarily the opinion of APR or any APR client.

hollen@tsunami.megatek.uucp (Dion Hollenbeck) (08/08/88)

> In article <290@ncextb.ncsu.edu> erdman@ncextb.ncsu.edu (erdman) writes:
> 
>   I am looking for a way to shorting the length of an existing file
>without re-writing the whole file.  I know it can be done, dBase III's
>"pack" appears to do this.  Are there any reliable ways to do this?
>Any help would be appreciated.

Look in the back of the DOS Programmer's Reference Manual for the
File Control Block format.  Use the old style file open which uses
the FCB.  Just poke the length field with the new length you want
and tell DOS to close the file.  The new FCB with new length will be
written back to disk.

	Dion Hollenbeck             (619) 455-5590 x2814
	Megatek Corporation, 9645 Scranton Road, San Diego, CA  92121

                                seismo!s3sun!megatek!hollen
                                ames!scubed/