On 09/23/2017 12:34 PM, Brandon Allbery wrote:
On Sat, Sep 23, 2017 at 2:34 AM, ToddAndMargo <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> wrote:

    I see ":truncate".  This seems liek it will do the trick.
    Problem: I would like to read from the file first before
    truncating (ro).

    Is there a way to do this, or should I
        1) open the handle with :ro
        2) read what I want from it
        3) close the handle
        4) reopen the handle with :w and overwrite what I want?

You have to do it the long way. I don't think we expose a binding to ftruncate() that would let you open it r/.w, red from it, truncate, and write.

That said, there's actually a good reason for that: is it okay to trash the file if something goes wrong? You might prefer to *rename* the old file instead of overwriting, so you can recover if necessary.

That is what I did.  Thank you for the confirmation!

Reply via email to