Truncating Files 
Author Message
 Truncating Files

Hello,

Is there any way of truncating data from the *beginnning* of a file?  You see, I have large files of
around 80Mb+ and I want to trim off a few meg from the ends.  CFiles' SetLength() will truncate the
file so that data at the end is lost, which is only half of what I want,  but I my also need to trim
off data from the start.

I could always save it to another file and then delete the original, but this is obviously a lot
slower, and I might not have enough of temporary disk space in the first place.

Any suggestions???

Thanks.

Paul...



Mon, 20 Aug 2001 03:00:00 GMT  
 Truncating Files
Hi Paul!

Unfortunately, there is absolutely no way to do such a truncate.
I do not know about Unix and other OS-es, but all DOS, Windows and (I think)
OS files are STREAMS in general, so truncating from the beggining is
impossible (the architecture of file storage can't allow this)

Regards!
DonAngel

PP. I'll be really glad if someone can propose a logical solution of this
problem, because I also was trying to solve such a problem some years ago,
and I failed (it was DOS environment yet, with much less longer files, but
also much slower machines and environment :) )

Quote:

>Hello,

>Is there any way of truncating data from the *beginnning* of a file?  You

see, I have large files of
Quote:
>around 80Mb+ and I want to trim off a few meg from the ends.  CFiles'

SetLength() will truncate the
Quote:
>file so that data at the end is lost, which is only half of what I want,

but I my also need to trim
Quote:
>off data from the start.

>I could always save it to another file and then delete the original, but

this is obviously a lot
Quote:
>slower, and I might not have enough of temporary disk space in the first
place.

>Any suggestions???

>Thanks.

>Paul...



Mon, 20 Aug 2001 03:00:00 GMT  
 Truncating Files

Easy !!! All you need to do is read the file from
the position you want to truncate, read in blocks
of n bytes each.  n = the number of bytes from the real start
of the file to the required start offset, this will avoid overlap..
and write each block starting at (currentposition - n)

This wont require any more disk space..

Cameron.

Quote:

>Hello,

>Is there any way of truncating data from the *beginnning* of a file?  You

see, I have large files of
Quote:
>around 80Mb+ and I want to trim off a few meg from the ends.  CFiles'

SetLength() will truncate the
Quote:
>file so that data at the end is lost, which is only half of what I want,

but I my also need to trim
Quote:
>off data from the start.

>I could always save it to another file and then delete the original, but

this is obviously a lot
Quote:
>slower, and I might not have enough of temporary disk space in the first
place.

>Any suggestions???

>Thanks.

>Paul...



Tue, 21 Aug 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. TRUNCATE FILE: EOF?

2. truncating files in dos?

3. Truncate files

4. Truncate files

5. Truncating files

6. How to truncate file

7. How to truncate file opened r+?

8. Truncating files

9. Truncating Files

10. How to truncate files with fstream/iostream stl classes?

11. Truncating a file.

12. How can I truncate the file ?

 

 
Powered by phpBB® Forum Software