-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
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:
FSWriteStream>>basicNextPut:callsat:put:on theFSMemoryHandleat:put:is overridden onFSMemoryHandle, to (among other things) dosize := size max: index(keeping at least the original size)- normally (in
FSHandle>>at:put:and withbasicNextPutAll:),at:write:startingAt:count:is called, which, onFSMemoryHandle, setssizeto the index of the byte that was written last (correctly truncating the file)
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
Labels
No labels