Re: how do I shorten a file?

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Friday 08 February 2002 07:13 am, Derek Parnell wrote:

> daryl_vdb at HOTMAIL.COM wrote:
> > How can I delete bytes from the end of a file opened for update (or
> > write)?
>
> Unfortunately you can't do that in DOS/Windows/Linux systems. Instead,
> you have to copy the parts of the file you want to a new file, then
> delete the old file and then rename the new file with the original name.
>
> The seek() and where() statements help you navigate around a file but
> they don't influence shortening it, though seek() can be used to extend
> a file, I think.

Some languages (Pascal is one, I think) reserve a byte to indicate EOF.
You could do the same thing with Euphoria, but it's probably better to 
do as Derek suggested. 

You can append to a file by 
seek(fn, -1) -- goes to end of file,
puts(fn, "Stuff") -- writes more to the file.

Note that the file should be opened in "ub" mode, otherwise, you may get 
unexpected line feeds in the text.

Regards,
Irv

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu