Skip to content

putContents doesn't truncate the file like file_put_contents #63

Closed
@choval

Description

@choval

React\Filesystem\Node\File::putContents @ line 158 opens without truncating option t. Hence, it writes the length of the content and leaves previous existing bytes.

It kinda goes against the regular behaviour of file_put_contents, is this intended?

$file = 'tmp.txt';
file_put_contents( $file, '000');
$promise = $fs->file( $file )->putContents( '11' );
$res = Block\await($promise, $loop);
var_dump( file_get_contents( $file ));
// returns 110 instead of 11

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