Skip to content

#writeStream does not clear old file contents, should it? #12

Open
@LinqLover

Description

@LinqLover
ref := FileSystem disk workingDirectory / 'fstest.txt'.
ref writeStreamDo: [:stream |
	stream nextPutAll: 'abcde'].
ref contents. "'abcde'"
ref writeStreamDo: [:stream |
	stream nextPutAll: 'XYZ'].
ref contents "'XYZde'"

I would have expected just 'XYZ', analogously to FileStream class>>#forceNewFileNamed:.

But, is this a bug or intended behavior?

This issue can be avoided by sending assureDeleted to the reference prior to opening it for the second write. But this sounds less convenient than Squeak's built-in protocols ... And (to me) this was quite surprising and cost me a lot of time to debug. 😅

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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