Skip to content

How to overwrite a file with less content #2203

Open
@sphaero

Description

@sphaero

It seems it updates the file in place leaving the old content in the tail.

zfile_output calls fopen (self->fullname, "r+b"); which according to docs:

r+ or rb+ or r+b: Open file for update (reading and writing).

To write the new file without a tail of old data we'd need:

w+ or wb+ or w+b
Truncate to zero length or create file for update.

However the old behaviour is probably also needed? Perhaps we need to add another method like zfile_output_truncate ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions