help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to truncate a file after partly overwriting it


From: Philip Nienhuis
Subject: Re: How to truncate a file after partly overwriting it
Date: Sat, 8 Feb 2014 13:32:15 -0800 (PST)

Macy wrote
> clumsy, but might work for you.
> 
> take the first part you want and write it to file temp.txt
> then open temp.txt as an append and write the new stuff
> then overwrite your original file with the temp.txt file and erase
> temp.txt.
> 
> 
> --- 

> address@hidden

>  wrote:
> 
> From: Philip Nienhuis <

> address@hidden

> >
> To: 

> help-octave@

> Subject: How to truncate a file after partly overwriting it
> Date: Sat, 8 Feb 2014 09:45:59 -0800 (PST)
> 
> Hi,
> 
> I'd like to partly overwrite a text file starting from position X.
> However,
> the new part to be written is shorter than the rest of the original file
> contents from X to EOF. Consequently, after the newly written part, the
> remainder of the old contents show up.
> So, how can I close & truncate the file after the end of the new part?

Thanks, I found similar solutions with google.
Some mor goolging shows that my request perhaps looks obvious but isn't so
easy. Matlab has the same limitations it seems.
On *nix systems (incl. Mac OSX) there seems to be a "truncate"/"ftruncate"
command, but I need it for Windows as well. AFAICS for MinGW these commands
either don't work, or are buggy, or are still in development.

My point is that I want to replace part(s) of potentially very large XML
files. These can get really big, so it is handy to keep as much file
contents as possible on disk and not in memory.

Philip




--
View this message in context: 
http://octave.1599824.n4.nabble.com/How-to-truncate-a-file-after-partly-overwriting-it-tp4661758p4661761.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]