*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Fri, 31 Oct 2008 15:03:42 +0100
changeset 11302 c8e8b9cde3d7
parent 11301 f65ffb560925
child 11303 48759a62953b
*** empty log message ***
DirectoryStream.st
--- a/DirectoryStream.st	Fri Oct 31 14:32:37 2008 +0100
+++ b/DirectoryStream.st	Fri Oct 31 15:03:42 2008 +0100
@@ -517,55 +517,54 @@
     OBJ dirP;
 
     if (__INST(hitEOF) != true && (dirP = __INST(dirPointer)) != nil) {
-        __INST(lastErrorNumber) = nil;
-        d = (DIR *)__FILEVal(dirP);
+	__INST(lastErrorNumber) = nil;
+	d = (DIR *)__FILEVal(dirP);
 
-        __BEGIN_INTERRUPTABLE__
-        do {
-            do {
-                __threadErrno = 0;
-                dp = readdir(d);
-                /*
-                 * for compatibility with ST-80,
-                 * skip entries for '.' and '..'.
-                 * If wanted, these must be added synthetically.
-                 */
-            } while (dp && ((strcmp(dp->d_name, ".")==0) || (strcmp(dp->d_name, "..")==0)));
-        } while ((dp == NULL) && (__threadErrno == EINTR));
-        __END_INTERRUPTABLE__
+	__BEGIN_INTERRUPTABLE__
+	do {
+	    do {
+		__threadErrno = 0;
+		dp = readdir(d);
+		/*
+		 * for compatibility with ST-80,
+		 * skip entries for '.' and '..'.
+		 * If wanted, these must be added synthetically.
+		 */
+	    } while (dp && ((strcmp(dp->d_name, ".")==0) || (strcmp(dp->d_name, "..")==0)));
+	} while ((dp == NULL) && (__threadErrno == EINTR));
+	__END_INTERRUPTABLE__
 
-        if (dp != NULL) {
-            nextEntry = __MKSTRING((char *)(dp->d_name));
-        } else {
-            if (__threadErrno) {
-                __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
-            } else {
-                __INST(hitEOF) = true;
-            }
+	if (dp != NULL) {
+	    nextEntry = __MKSTRING((char *)(dp->d_name));
+	} else {
+	    if (__threadErrno) {
+		__INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
+	    } else {
+		__INST(hitEOF) = true;
+	    }
        }
     }
 #else /* no HAS_OPENDIR */
 # ifdef WIN32
     HANDLE d;
     WIN32_FIND_DATAW data;
-    OBJ __MKU16STRING();
     OBJ dirP;
     int rslt;
 
     if (__INST(hitEOF) != true && (dirP = __INST(dirPointer)) != nil) {
-        __INST(lastErrorNumber) = nil;
-        d = __HANDLEVal(dirP);
+	__INST(lastErrorNumber) = nil;
+	d = __HANDLEVal(dirP);
 
-        do {
-            __threadErrno = 0;
-            rslt = STX_API_CALL2( "FindNextFileW", FindNextFileW, d, &data );
-        } while ((rslt < 0) && (__threadErrno == EINTR));
+	do {
+	    __threadErrno = 0;
+	    rslt = STX_API_CALL2( "FindNextFileW", FindNextFileW, d, &data );
+	} while ((rslt < 0) && (__threadErrno == EINTR));
 
-        if (rslt > 0) {
-            nextEntry = __MKU16STRING( data.cFileName );
-        } else {
-           __INST(hitEOF) = true;
-        }
+	if (rslt > 0) {
+	    nextEntry = __MKU16STRING( data.cFileName );
+	} else {
+	   __INST(hitEOF) = true;
+	}
     }
 # endif /* WIN32 */
 #endif /* HAS_OPENDIR */
@@ -574,7 +573,7 @@
     prevEntry := readAheadEntry.
     readAheadEntry := nextEntry.
     readAheadEntry notNil ifTrue:[
-        readAheadEntry := readAheadEntry asSingleByteStringIfPossible.
+	readAheadEntry := readAheadEntry asSingleByteStringIfPossible.
     ].
     prevEntry isNil ifTrue:[^ self pastEndRead].
     ^ prevEntry
@@ -632,109 +631,109 @@
 
     ok = false;
     if (__INST(dirPointer) == nil) {
-        path = __INST(pathName);
-        if (__isString(path)) {
-            __BEGIN_INTERRUPTABLE__
-            __threadErrno = 0;
-            do {
-                path = __INST(pathName);
-                d = opendir((char *) __stringVal(path));
-            } while ((d == NULL) && (__threadErrno == EINTR));
-            __END_INTERRUPTABLE__
+	path = __INST(pathName);
+	if (__isString(path)) {
+	    __BEGIN_INTERRUPTABLE__
+	    __threadErrno = 0;
+	    do {
+		path = __INST(pathName);
+		d = opendir((char *) __stringVal(path));
+	    } while ((d == NULL) && (__threadErrno == EINTR));
+	    __END_INTERRUPTABLE__
 
-            if (d == NULL) {
-                __INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
-            } else {
-                dp = __MKEXTERNALADDRESS(d); __INST(dirPointer) = dp; __STORE(self, dp);
-                ok = true;
-            }
-        }
+	    if (d == NULL) {
+		__INST(lastErrorNumber) = __mkSmallInteger(__threadErrno);
+	    } else {
+		dp = __MKEXTERNALADDRESS(d); __INST(dirPointer) = dp; __STORE(self, dp);
+		ok = true;
+	    }
+	}
     }
 #else
 # ifdef WIN32
-#  ifndef MAXPATHLEN 
+#  ifndef MAXPATHLEN
 #   define MAXPATHLEN 1024
 #  endif
     HANDLE d;
     OBJ path, dp;
     union {
-        char pattern[MAXPATHLEN];
-        wchar_t wpattern[MAXPATHLEN];
+	char pattern[MAXPATHLEN];
+	wchar_t wpattern[MAXPATHLEN];
     } uP;
     union {
-        WIN32_FIND_DATAA data;
-        WIN32_FIND_DATAW wdata;
+	WIN32_FIND_DATAA data;
+	WIN32_FIND_DATAW wdata;
     } uD;
 
     ok = false;
     if (__INST(dirPointer) == nil) {
-        path = __INST(pathName);
-        if (__isString(path)) {
-            int l = __stringSize(path);
+	path = __INST(pathName);
+	if (__isString(path)) {
+	    int l = __stringSize(path);
 
-            if (l < (MAXPATHLEN-4)) {
-                strncpy(uP.pattern, __stringVal(path), l);
-                strcpy(uP.pattern+l, "\\*");
+	    if (l < (MAXPATHLEN-4)) {
+		strncpy(uP.pattern, __stringVal(path), l);
+		strcpy(uP.pattern+l, "\\*");
 
-                do {
-                    __threadErrno = 0;
-                    d = STX_API_CALL2( "FindFirstFile", FindFirstFile, uP.pattern, &uD.data );
-                } while ((d < 0) && (__threadErrno == EINTR));
+		do {
+		    __threadErrno = 0;
+		    d = STX_API_CALL2( "FindFirstFile", FindFirstFile, uP.pattern, &uD.data );
+		} while ((d < 0) && (__threadErrno == EINTR));
 
-                if (d == INVALID_HANDLE_VALUE) {
-                    __INST(lastErrorNumber) = __mkSmallInteger(GetLastError());
-                } else {
-                    dp = __MKEXTERNALADDRESS(d); __INST(dirPointer) = dp; __STORE(self, dp);
-                    entry = __MKSTRING( uD.data.cFileName );
-                    ok = true;
-                }
-            }
-        }
-        else if (__isUnicode16String(path)) {
-            int l = __unicode16StringSize(path);
-            int i;
+		if (d == INVALID_HANDLE_VALUE) {
+		    __INST(lastErrorNumber) = __mkSmallInteger(GetLastError());
+		} else {
+		    dp = __MKEXTERNALADDRESS(d); __INST(dirPointer) = dp; __STORE(self, dp);
+		    entry = __MKSTRING( uD.data.cFileName );
+		    ok = true;
+		}
+	    }
+	}
+	else if (__isUnicode16String(path)) {
+	    int l = __unicode16StringSize(path);
+	    int i;
 
-            if (l < (MAXPATHLEN-4)) {
-                for (i=0; i<l; i++) {
-                    uP.wpattern[i] = __unicode16StringVal(path)[i];
-                }
-                uP.wpattern[i++] = '\\';
-                uP.wpattern[i++] = '*';
-                uP.wpattern[i] = 0;
+	    if (l < (MAXPATHLEN-4)) {
+		for (i=0; i<l; i++) {
+		    uP.wpattern[i] = __unicode16StringVal(path)[i];
+		}
+		uP.wpattern[i++] = '\\';
+		uP.wpattern[i++] = '*';
+		uP.wpattern[i] = 0;
 
-                do {
-                    __threadErrno = 0;
-                    d = STX_API_CALL2( "FindFirstFileW", FindFirstFileW, uP.wpattern, &uD.wdata );
-                } while ((d < 0) && (__threadErrno == EINTR));
+		do {
+		    __threadErrno = 0;
+		    d = STX_API_CALL2( "FindFirstFileW", FindFirstFileW, uP.wpattern, &uD.wdata );
+		} while ((d < 0) && (__threadErrno == EINTR));
 
-                if (d == INVALID_HANDLE_VALUE) {
-                    __INST(lastErrorNumber) = __mkSmallInteger(GetLastError());
-                } else {
-                    dp = __MKEXTERNALADDRESS(d); __INST(dirPointer) = dp; __STORE(self, dp);
-                    entry = __MKU16STRING( uD.wdata.cFileName );
-                    ok = true;
-                }
-            }
-        }
+		if (d == INVALID_HANDLE_VALUE) {
+		    __INST(lastErrorNumber) = __mkSmallInteger(GetLastError());
+		} else {
+		    dp = __MKEXTERNALADDRESS(d); __INST(dirPointer) = dp; __STORE(self, dp);
+		    entry = __MKU16STRING( uD.wdata.cFileName );
+		    ok = true;
+		}
+	    }
+	}
     }
 # endif
 #endif
 %}.
     ok isNil ifTrue:[
-        "
-         opendir not avalable - use slower pipe
-        "
-        ^ PipeStream readingFrom:('cd ' , pathName , '; ls -a')
+	"
+	 opendir not avalable - use slower pipe
+	"
+	^ PipeStream readingFrom:('cd ' , pathName , '; ls -a')
     ].
 
     (ok == true) ifTrue:[
-        Lobby register:self.
-        entry isNil ifTrue:[
-            self nextLine. "read 1st entry into readAheadEntry buffer"
-        ] ifFalse:[
-            readAheadEntry := entry.
-        ].
-        ^ self
+	Lobby register:self.
+	entry isNil ifTrue:[
+	    self nextLine. "read 1st entry into readAheadEntry buffer"
+	] ifFalse:[
+	    readAheadEntry := entry.
+	].
+	^ self
     ].
     dirPointer notNil ifTrue:[^ self errorAlreadyOpen].
     lastErrorNumber notNil ifTrue:[^ self openError].
@@ -783,5 +782,5 @@
 !DirectoryStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.65 2008-10-30 16:25:55 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.66 2008-10-31 14:03:42 cg Exp $'
 ! !