sockets and files
authormkobetic
Sun, 15 Jan 2012 02:16:21 +0000
changeset 38 2f05f2f63e04
parent 37 04265dae86ee
child 39 80fdc4602b14
sockets and files
support/Xtreams__Encoder.st
support/Xtreams__RecyclingCenter.st
support/Xtreams__XtreamsPool.st
support/extensions.sav
support/extensions.st
support/stx_goodies_xtreams_support.st
--- a/support/Xtreams__Encoder.st	Sun Jan 15 02:15:50 2012 +0000
+++ b/support/Xtreams__Encoder.st	Sun Jan 15 02:16:21 2012 +0000
@@ -1,3 +1,5 @@
+'From Smalltalk/X, Version:6.2.1 on 14-01-2012 at 09:10:15 PM'                  !
+
 "{ Package: 'stx:goodies/xtreams/support' }"
 
 "{ NameSpace: Xtreams }"
--- a/support/Xtreams__RecyclingCenter.st	Sun Jan 15 02:15:50 2012 +0000
+++ b/support/Xtreams__RecyclingCenter.st	Sun Jan 15 02:16:21 2012 +0000
@@ -1,3 +1,5 @@
+'From Smalltalk/X, Version:6.2.1 on 14-01-2012 at 09:10:15 PM'                  !
+
 "{ Package: 'stx:goodies/xtreams/support' }"
 
 "{ NameSpace: Xtreams }"
@@ -5,7 +7,7 @@
 Object subclass:#RecyclingCenter
 	instanceVariableNames:'recycled mutex'
 	classVariableNames:''
-	poolDictionaries:'Xtreams::XtreamsPool'
+	poolDictionaries:'XtreamsPool'
 	category:'Xtreams-Support'
 !
 
--- a/support/Xtreams__XtreamsPool.st	Sun Jan 15 02:15:50 2012 +0000
+++ b/support/Xtreams__XtreamsPool.st	Sun Jan 15 02:16:21 2012 +0000
@@ -1,10 +1,12 @@
+'From Smalltalk/X, Version:6.2.1 on 14-01-2012 at 09:10:15 PM'                  !
+
 "{ Package: 'stx:goodies/xtreams/support' }"
 
 "{ NameSpace: Xtreams }"
 
 SharedPool subclass:#XtreamsPool
 	instanceVariableNames:''
-	classVariableNames:'DefaultBufferSize'
+	classVariableNames:'DefaultBufferSize LF CR'
 	poolDictionaries:''
 	category:'Xtreams-Support'
 !
@@ -14,7 +16,9 @@
 
 initialize
 
-    DefaultBufferSize := 32768
+    DefaultBufferSize := 32768.
+    LF := Character value: 10.
+    CR := Character value: 13.
 ! !
 
 !XtreamsPool class methodsFor:'documentation'!
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/support/extensions.sav	Sun Jan 15 02:16:21 2012 +0000
@@ -0,0 +1,43 @@
+"{ Package: 'stx:goodies/xtreams/support' }"
+
+!
+
+!Block methodsFor:'converting'!
+
+cull: value
+
+    ^self numArgs = 1 ifTrue: [ self value: value ] ifFalse: [ self value ]
+! !
+!Object methodsFor:'private'!
+
+isFixedArgument
+
+    ^false
+! !
+!SequenceableCollection methodsFor:'xtreams'!
+
+copyGrownToAtLeast: newSize
+
+    |newCollection|
+
+    newCollection := self class new: newSize.
+    newCollection replaceFrom: 1 to: self size with: self startingAt: 1.
+    ^newCollection
+! !
+!SequenceableCollection methodsFor:'xtreams'!
+
+recycle
+
+    Xtreams::RecyclingCenter recycle: self
+! !
+!SequenceableCollection class methodsFor:'xtreams'!
+
+newRecycled: size
+
+    ^Xtreams::RecyclingCenter new: size class: self
+! !
+!stx_goodies_xtreams_support class methodsFor:'documentation'!
+
+extensionsVersion_SVN
+    ^ '$Id: extensions.st 16 2011-11-21 06:02:29Z mkobetic $'
+! !
--- a/support/extensions.st	Sun Jan 15 02:15:50 2012 +0000
+++ b/support/extensions.st	Sun Jan 15 02:16:21 2012 +0000
@@ -1,19 +1,27 @@
-"{ Package: 'stx:goodies/xtreams/support' }"
+"{ Encoding: utf8 }" !
+"{ Package: 'stx:goodies/xtreams/support' }" !
+
+!Symbol methodsFor:'xtreams'!
 
-!
+cull: anObject
 
-!Block methodsFor:'converting'!
+    ^anObject perform: self
+! !
+
+!Block methodsFor:'xtreams'!
 
 cull: value
 
     ^self numArgs = 1 ifTrue: [ self value: value ] ifFalse: [ self value ]
 ! !
-!Object methodsFor:'private'!
+
+!Block methodsFor:'xtreams'!
 
-isFixedArgument
+cull: value1 cull: value2
 
-    ^false
+    ^self numArgs < 2 ifTrue: [ self cull: value1 ] ifFalse: [ self value: value1 value: value2 ]
 ! !
+
 !SequenceableCollection methodsFor:'xtreams'!
 
 copyGrownToAtLeast: newSize
@@ -24,20 +32,56 @@
     newCollection replaceFrom: 1 to: self size with: self startingAt: 1.
     ^newCollection
 ! !
+
 !SequenceableCollection methodsFor:'xtreams'!
 
 recycle
 
     Xtreams::RecyclingCenter recycle: self
 ! !
+
 !SequenceableCollection class methodsFor:'xtreams'!
 
 newRecycled: size
 
     ^Xtreams::RecyclingCenter new: size class: self
 ! !
-!stx_goodies_xtreams_support class methodsFor:'documentation'!
+
+!Object methodsFor:'private'!
+
+isFixedArgument
+
+    ^false
+! !
+
+!UnixOperatingSystem::FileDescriptorHandle methodsFor:'xtreams'!
+
+fileSize
+
+    | error size |
+%{
+    struct stat buf;
 
-extensionsVersion_SVN
-    ^ '$Id$'
+    if (__isSmallInteger(__INST(fd))) {
+        if (fstat(__smallIntegerVal(__INST(fd)), &buf) >= 0) {
+           if (sizeof(buf.st_size) == 8) {
+              size = __MKINT64(&buf.st_size);
+           } else {
+               size = __MKINT(buf.st_size);
+           };
+        } else {
+           error = __mkSmallInteger(errno);
+        };
+    }
+%}.
+    ^size notNil
+        ifTrue: [ size ]
+        ifFalse: [ self error: error ]
+
+"
+    | h |
+    h := OperatingSystem openFileForRead: '/etc/hosts'.
+    [ h fileSize ] ensure: [ h close ]
+"
 ! !
+
--- a/support/stx_goodies_xtreams_support.st	Sun Jan 15 02:15:50 2012 +0000
+++ b/support/stx_goodies_xtreams_support.st	Sun Jan 15 02:16:21 2012 +0000
@@ -1,5 +1,9 @@
+'From Smalltalk/X, Version:6.2.1 on 14-01-2012 at 09:10:15 PM'                  !
+
 "{ Package: 'stx:goodies/xtreams/support' }"
 
+"{ NameSpace: Xtreams }"
+
 LibraryDefinition subclass:#stx_goodies_xtreams_support
 	instanceVariableNames:''
 	classVariableNames:''
@@ -49,7 +53,7 @@
         #'Xtreams::Encoder'
         #'Xtreams::RecyclingCenter'
         #'stx_goodies_xtreams_support'
-        #'Xtreams::XtreamsPool'
+        XtreamsPool
     )
 !