class: DirectoryStream
authorClaus Gittinger <cg@exept.de>
Mon, 12 Jan 2015 16:36:51 +0100
changeset 17290 47f6863bcbce
parent 17289 9df64c66192f
child 17291 3177810ab9ae
class: DirectoryStream changed: #atEnd #nextLinkInfo
DirectoryStream.st
--- a/DirectoryStream.st	Mon Jan 12 15:23:39 2015 +0100
+++ b/DirectoryStream.st	Mon Jan 12 16:36:51 2015 +0100
@@ -522,16 +522,23 @@
 
     |nextResult resultInfo|
 
-    hitEOF ifFalse:[
-	nextResult := OperatingSystem nextLinkInfoFrom:self dirPointer:dirPointer.
-	nextResult isNil ifTrue:[
-	    hitEOF := true.
-	].
+    hitEOF ifTrue:[
+        ^ self pastEndRead
+    ].
+
+    nextResult := OperatingSystem nextLinkInfoFrom:self dirPointer:dirPointer.
+    nextResult isNil ifTrue:[
+        hitEOF := true.
     ].
-    resultInfo := readAheadEntry.
-    resultInfo isNil ifTrue:[^ self pastEndRead].
-    readAheadEntry := nextResult.
-    ^ resultInfo
+    readAheadEntry notNil ifTrue:[
+        resultInfo := readAheadEntry.
+        readAheadEntry := nextResult.
+        ^ resultInfo
+    ].
+    nextResult isNil ifTrue:[
+        ^ self pastEndRead
+    ].
+    ^ nextResult
 ! !
 
 !DirectoryStream protectedMethodsFor:'instance release'!
@@ -566,6 +573,7 @@
 
     encodedPathName := OperatingSystem encodePath:pathName.
     mode := #readonly.
+    hitEOF := false.
 
 %{
 #ifdef HAS_OPENDIR
@@ -716,7 +724,7 @@
 atEnd
     "return true, if position is at end"
 
-    ^ readAheadEntry == nil
+    ^ hitEOF "/ readAheadEntry == nil
 !
 
 isEmpty
@@ -749,10 +757,10 @@
 !DirectoryStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.83 2015-01-12 13:55:30 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.84 2015-01-12 15:36:51 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.83 2015-01-12 13:55:30 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.84 2015-01-12 15:36:51 cg Exp $'
 ! !