#copyToEndInto
authorStefan Vogel <sv@exept.de>
Sun, 09 May 2004 22:51:37 +0200
changeset 8339 b6c3643af40f
parent 8338 a399729a3c69
child 8340 c00e71830ee3
#copyToEndInto Handle partial writes when doinf sendfile()
ExternalStream.st
--- a/ExternalStream.st	Sun May 09 22:45:54 2004 +0200
+++ b/ExternalStream.st	Sun May 09 22:51:37 2004 +0200
@@ -2920,26 +2920,32 @@
 
     |bufferSize pos n nWritten|
 
+    "the sendfile() system call currently (2004-05-07) handles only descriptors that
+     that support mmap-like operations as from-fd"
+
     self isFileStream ifTrue:[
-	outStream isExternalStream ifTrue:[
-	    pos := self position.
-	    n := self size - pos.
-	    nWritten := OperatingSystem 
-		copyFromFd:(self fileDescriptor)
-		toFd:(outStream fileDescriptor)
-		startIndex:pos 
-		count:n.
-	    nWritten = n ifTrue:[
-		^ self
-	    ]
-	]
+        outStream isExternalStream ifTrue:[
+            pos := self position0Based.
+            n := self size - pos.
+            nWritten := OperatingSystem 
+                copyFromFd:(self fileDescriptor)
+                toFd:(outStream fileDescriptor)
+                startIndex:pos 
+                count:n.
+            nWritten = n ifTrue:[
+                ^ self
+            ].
+            nWritten > 0 ifTrue:[
+                self position0Based:pos+nWritten.
+            ].
+        ]
     ].
 
     OperatingSystem isMSDOSlike ifTrue:[
-	"/ mhmh - NT hangs, when copying bigger blocks to a network drive - why ?
-	bufferSize := 1 * 1024.
+        "/ mhmh - NT hangs, when copying bigger blocks to a network drive - why ?
+        bufferSize := 1 * 1024.
     ] ifFalse:[
-	bufferSize := 8 * 1024.
+        bufferSize := 8 * 1024.
     ].
 
     ^ self copyToEndInto:outStream bufferSize:bufferSize
@@ -5896,7 +5902,7 @@
 !ExternalStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.279 2004-04-01 13:33:51 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalStream.st,v 1.280 2004-05-09 20:51:37 stefan Exp $'
 ! !
 
 ExternalStream initialize!