#BUGFIX by stefan
class: FileStream
changed:
#accessRights
#accessRights:
#copy:into:bufferSize:
check for nil fd
--- a/FileStream.st Wed Mar 04 17:00:04 2020 +0100
+++ b/FileStream.st Wed Mar 04 17:01:08 2020 +0100
@@ -759,13 +759,24 @@
"return the access rights of the file as opaque data
(SmallInteger in unix/linux)"
- ^ OperatingSystem accessModeOfFd:self fileDescriptor.
+ |fd|
+
+ "self fileDescriptor sets handle to nil and
+ answers nil, if the handle is no longer valid!!"
+ fd := self fileDescriptor.
+ fd isNil ifTrue:[
+ self errorNotOpen.
+ ^ nil.
+ ].
+ ^ OperatingSystem accessModeOfFd:fd.
"
'Make.proto' asFilename readingFileDo:[:s|
- s accessRights
+ s accessRights
]
"
+
+ "Modified (comment): / 04-03-2020 / 13:11:30 / Stefan Vogel"
!
accessRights:opaqueData
@@ -773,23 +784,33 @@
which is normally retrieved by Filename>>#accessRights
or FileStreamm>>#accessRights."
- (OperatingSystem changeAccessModeOfFd:self fileHandle to:opaqueData) ifFalse:[
- OperatingSystem accessDeniedErrorSignal
- raiseRequestWith:self
- errorString:(' - cannot change access rights: ' , self pathName).
+ |fd|
+
+ fd := self fileHandle.
+ fd isNil ifTrue:[
+ self errorNotOpen.
+ ^ self.
+ ].
+
+ (OperatingSystem changeAccessModeOfFd:fd to:opaqueData) ifFalse:[
+ OperatingSystem accessDeniedErrorSignal
+ raiseRequestWith:self
+ errorString:(' - cannot change access rights: ' , self pathName).
].
"
'Make.proto' asFilename readingFileDo:[:s|
- s accessRights:s accessRights
+ s accessRights:s accessRights
]
"
"
'/' asFilename readingFileDo:[:s|
- s accessRights:s accessRights
+ s accessRights:s accessRights
]
"
+
+ "Modified: / 04-03-2020 / 15:00:22 / Stefan Vogel"
! !
!FileStream methodsFor:'accessing'!
@@ -919,11 +940,19 @@
If nuberOfBytesOrNil is nil, copy until the end of myself.
Redefined to use operating system features to do a fast copy."
- |pos n nWritten|
+ |pos n nWritten fromFd toFd|
outStream isExternalStream ifTrue:[
- "sendfile() in Linux does not support any combination of file/pipe/socket fds.
- #copyFromFd:toFd:startIndex:count: is currently not available in windows."
+ fromFd := self fileHandle.
+ fromFd isNil ifTrue:[
+ self errorNotOpen.
+ ^ self.
+ ].
+ toFd := outStream fileHandle.
+ toFd isNil ifTrue:[
+ outStream errorNotOpen.
+ ^ self.
+ ].
pos := self position.
numberOfBytesOrNil isNil ifTrue:[
@@ -931,9 +960,14 @@
] ifFalse:[
n := numberOfBytesOrNil.
].
+
+ "sendfile() in Linux does not support any combination of file/pipe/socket fds.
+ #copyFromFd:toFd:startIndex:count: is currently not available in windows.
+ Both will return 0 and fall through to super."
+
nWritten := OperatingSystem
- copyFromFd:self fileHandle
- toFd:outStream fileHandle
+ copyFromFd:fromFd
+ toFd:toFd
startIndex:pos
count:n.
nWritten > 0 ifTrue:[
@@ -963,6 +997,7 @@
"Created: / 13-03-2019 / 16:27:04 / Stefan Vogel"
"Modified (format): / 25-05-2019 / 16:47:53 / Claus Gittinger"
+ "Modified (comment): / 04-03-2020 / 15:09:52 / Stefan Vogel"
!
syncFileSystem