--- a/WriteStream.st Tue Aug 01 17:45:36 2017 +0200
+++ b/WriteStream.st Wed Aug 02 09:27:56 2017 +0200
@@ -187,6 +187,48 @@
position := 0.
"Modified: 19.2.1997 / 08:57:00 / stefan"
+!
+
+truncateTo:givenMax
+ "if the streamed contents is larger than maxSize,
+ reset the write position back to this size.
+ Otherwise do nothing."
+
+ self size > givenMax ifTrue:[
+ self position:givenMax.
+ ].
+
+ "
+ |s|
+
+ s := '' writeStream.
+ s nextPutAll:'123456'.
+ s truncateTo:4.
+ s nextPutAll:'abc'.
+ s contents
+ "
+
+ "
+ |s|
+
+ s := '' writeStream.
+ s nextPutAll:'1234'.
+ s truncateTo:4.
+ s nextPutAll:'abc'.
+ s contents
+ "
+
+ "
+ |s|
+
+ s := '' writeStream.
+ s nextPutAll:'123'.
+ s truncateTo:4.
+ s nextPutAll:'abc'.
+ s contents
+ "
+
+ "Created: / 02-08-2017 / 09:24:58 / cg"
! !
!WriteStream methodsFor:'positioning'!