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 |