Skip to content

FSWriteStream>>nextPut: does not truncate a file in memory #14

@MariusDoe

Description

@MariusDoe

When using an FSMemoryStore, after closing a write stream that only called nextPut:, the file is not properly truncated. nextPutAll: does not have this behavior.

| fs ref |
fs := FileSystem memory.
ref := fs / 'test'.
ref writeStreamDo: [:s | s nextPutAll: 'abc'].
ref contents. "'abc'"
ref writeStreamDo: [:s | s nextPutAll: 'xy'].
ref contents. "'xy'"
ref writeStreamDo: [:s | s nextPut: $!].
ref contents. "'!y'"

Some investigation:

I'm not sure whether basicNextPut: is at fault for calling at:put: instead of at:write:startingAt:count: or whether at:put: should instead set the size to the index - maybe at:put: is sometimes used to set bytes in the middle of a file, without wanting a truncation?

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