Skip to content

Commit 1c9c31d

Browse files
committed
Conform memory stream truncate to StandardFileStream
...and Pharo's BinaryFileStream. Also add truncate: in FSWriteStream. truncate on FSWriteStream still does not truncate to 0, although this should probably also be changed at some point. Need to evaluate compatiblity concerns first (with Pharo, with existing code).
1 parent e66afa3 commit 1c9c31d

File tree

15 files changed

+44
-7
lines changed

15 files changed

+44
-7
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
SquotTrackedObjectMetadata {
22
#objectClassName : #PackageInfo,
3+
#objectsReplacedByNames : true,
34
#serializer : #SquotCypressCodeSerializer
45
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
file
2+
truncate: anInteger
3+
self truncateTo: anInteger.

src/FS-AnsiStreams.package/FSWriteStream.class/methodProperties.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@
3030
"store:" : "CamilloBruni 1/24/2012 13:42",
3131
"tab:" : "CamilloBruni 8/12/2011 14:24",
3232
"truncate" : "jr 4/13/2017 15:45",
33+
"truncate:" : "jr 12/13/2020 23:49",
3334
"truncateTo:" : "cwp 10/15/2009 21:49" } }
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{
1+
SquotTrackedObjectMetadata {
22
#objectClassName : #PackageInfo,
3+
#objectsReplacedByNames : true,
34
#serializer : #SquotCypressCodeSerializer
45
}

src/FS-Memory.package/FSMemoryFileStream.class/instance/close.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ close
33

44
store
55
replaceFile: path
6-
in: [ :bytes | collection first: position ]
6+
in: [ :bytes | self binary; contents ]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
writing
22
truncate: aPosition
3-
position := position min: aPosition.
4-
"bytes in the MemoryStore are replaced with my collection up to position anyway"
3+
position := readLimit := aPosition.
4+
position > collection size ifTrue: [self growTo: aPosition].
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
writing
2+
truncate
3+
self truncate: 0.

src/FS-Memory.package/FSMemoryFileStream.class/methodProperties.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"class" : {
33
},
44
"instance" : {
5-
"close" : "jr 6/5/2017 22:27",
5+
"close" : "jr 12/14/2020 00:11",
66
"growTo:" : "cwp 2/19/2011 01:20",
77
"pastEndPut:" : "cwp 2/19/2011 01:20",
8-
"truncate:" : "jr 6/5/2017 22:55" } }
8+
"truncate" : "jr 12/13/2020 23:49",
9+
"truncate:" : "jr 12/14/2020 00:23" } }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
SquotTrackedObjectMetadata {
22
#objectClassName : #PackageInfo,
3+
#objectsReplacedByNames : true,
34
#serializer : #SquotCypressCodeSerializer
45
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tests
2+
testTruncateToCurrentPosition
3+
stream
4+
nextPutAll: #(42 43 44 45 46);
5+
flush;
6+
position: 3;
7+
truncate: stream position.
8+
self assert: self contents = #(42 43 44) asByteArray

0 commit comments

Comments
 (0)