FileStream.st
changeset 24149 e5e20aba8e1f
parent 24102 e14d73f12120
child 24380 9951a2af279e
equal deleted inserted replaced
24148:0a40f4bca78d 24149:e5e20aba8e1f
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
   918      Redefined to use operating system features to do a fast copy."
   920      Redefined to use operating system features to do a fast copy."
   919 
   921 
   920     |pos n nWritten|
   922     |pos n nWritten|
   921 
   923 
   922     outStream isExternalStream ifTrue:[
   924     outStream isExternalStream ifTrue:[
   923 	"sendfile() in Linux does not support any combination of file/pipe/socket fds.
   925         "sendfile() in Linux does not support any combination of file/pipe/socket fds.
   924 	 #copyFromFd:toFd:startIndex:count is curently not available in windows."
   926          #copyFromFd:toFd:startIndex:count: is curently not available in windows."
   925 
   927 
   926 	pos := self position.
   928         pos := self position.
   927 	numberOfBytesOrNil isNil ifTrue:[
   929         numberOfBytesOrNil isNil ifTrue:[
   928 	    n := self size - pos.
   930             n := self size - pos.
   929 	] ifFalse:[
   931         ] ifFalse:[
   930 	    n := numberOfBytesOrNil.
   932             n := numberOfBytesOrNil.
   931 	].
   933         ].
   932 	nWritten := OperatingSystem
   934         nWritten := OperatingSystem
   933 			copyFromFd:self fileHandle
   935                         copyFromFd:self fileHandle
   934 			toFd:outStream fileHandle
   936                         toFd:outStream fileHandle
   935 			startIndex:pos
   937                         startIndex:pos
   936 			count:n.
   938                         count:n.
   937 	nWritten > 0 ifTrue:[
   939         nWritten > 0 ifTrue:[
   938 	    self position:pos+nWritten.
   940             self position:pos+nWritten.
   939 	].
   941         ].
   940 	nWritten = n ifTrue:[
   942         nWritten = n ifTrue:[
   941 	    ^ self
   943             ^ self
   942 	].
   944         ].
   943     ].
   945     ].
   944 
   946 
   945     "fall back..."
   947     "fall back..."
   946     ^ super copy:numberOfBytesOrNil into:outStream bufferSize:bufferSize.
   948     ^ super copy:numberOfBytesOrNil into:outStream bufferSize:bufferSize.
   947 
   949 
   960      in close. out close.
   962      in close. out close.
   961      '/tmp/test' asFilename contents.
   963      '/tmp/test' asFilename contents.
   962     "
   964     "
   963 
   965 
   964     "Created: / 13-03-2019 / 16:27:04 / Stefan Vogel"
   966     "Created: / 13-03-2019 / 16:27:04 / Stefan Vogel"
       
   967     "Modified (format): / 25-05-2019 / 16:47:53 / Claus Gittinger"
   965 !
   968 !
   966 
   969 
   967 syncFileSystem
   970 syncFileSystem
   968     "sync the filesystem containing this FileStream"
   971     "sync the filesystem containing this FileStream"
   969 
   972