use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
authorClaus Gittinger <cg@exept.de>
Thu, 10 Sep 1998 13:08:03 +0200
changeset 3816 af3f917c7759
parent 3815 57aff51fbbfb
child 3817 5d1719e862c7
use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
DirStr.st
DirectoryStream.st
--- a/DirStr.st	Wed Sep 09 21:54:08 1998 +0200
+++ b/DirStr.st	Thu Sep 10 13:08:03 1998 +0200
@@ -117,7 +117,7 @@
 #ifndef HAS_OPENDIR
 # if defined(__VMS__)
 
-#  define lib$find_file	LIB$FIND_FILE
+#  define lib$find_file LIB$FIND_FILE
 
 /*
 **  VMS readdir() routines.
@@ -469,13 +469,13 @@
 	__BEGIN_INTERRUPTABLE__
 	do {
 	    do {
-	        errno = 0;
-	        dp = readdir(d);
-	        /*
-	         * for compatibility with ST-80,
-	         * skip entries for '.' and '..'.
-	         * If wanted, these must be added synthetically.
-	         */
+		errno = 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) && (errno == EINTR));
 	__END_INTERRUPTABLE__
@@ -495,12 +495,18 @@
     HANDLE d;
     WIN32_FIND_DATA data;
     OBJ dirP;
+    int rslt;
 
     if (__INST(hitEOF) != true && (dirP = __INST(dirPointer)) != nil) {
 	__INST(lastErrorNumber) = nil;
 	d = __HANDLEVal(dirP);
 
-	if (FindNextFile(d, &data)) {
+#  ifdef DO_WRAP_CALLS
+	rslt = __doWrapCall2(1,(void*)FindNextFile,(void *)d, (void *)&data);
+#  else
+	rslt = FindNextFile(d, &data);
+#  endif
+	if (rslt) {
 	    nextEntry = __MKSTRING( data.cFileName );
 	} else {
 	   __INST(hitEOF) = true;
@@ -599,12 +605,16 @@
 	    int l = __stringSize(path);
 
 	    if (l < (sizeof(pattern)-4)) {
-	        strncpy(pattern, __stringVal(path), l);
-	        strcpy(pattern+l, "\\*");
-	        d = FindFirstFile(pattern, &data);
-	        if (d == INVALID_HANDLE_VALUE) {
+		strncpy(pattern, __stringVal(path), l);
+		strcpy(pattern+l, "\\*");
+#  ifdef DO_WRAP_CALLS
+		d = __doWrapCall2(1,(void*)FindFirstFile,(void *)pattern, (void *)&data);
+#  else
+		d = FindFirstFile(pattern, &data);
+#  endif
+		if (d == INVALID_HANDLE_VALUE) {
 		    __INST(lastErrorNumber) = __MKSMALLINT(GetLastError());
-	        } else {
+		} else {
 		    __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
 		    entry = __MKSTRING( data.cFileName );
 		    ok = true;
@@ -658,17 +668,17 @@
     |entry|
 
     [self atEnd] whileFalse:[
-        entry := self nextLine.
-        entry asFilename isImplicit ifFalse:[
-            ^ false.
-        ]
+	entry := self nextLine.
+	entry asFilename isImplicit ifFalse:[
+	    ^ false.
+	]
     ].
     ^ true
 
 
     "
-        (DirectoryStream directoryNamed:'/') isEmpty
-        (DirectoryStream directoryNamed:'/var/tmp') isEmpty
+	(DirectoryStream directoryNamed:'/') isEmpty
+	(DirectoryStream directoryNamed:'/var/tmp') isEmpty
     "
 
     "Modified: 18.9.1997 / 18:05:31 / stefan"
@@ -677,5 +687,5 @@
 !DirectoryStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Attic/DirStr.st,v 1.42 1998-01-12 13:21:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Attic/DirStr.st,v 1.43 1998-09-10 11:08:03 cg Exp $'
 ! !
--- a/DirectoryStream.st	Wed Sep 09 21:54:08 1998 +0200
+++ b/DirectoryStream.st	Thu Sep 10 13:08:03 1998 +0200
@@ -117,7 +117,7 @@
 #ifndef HAS_OPENDIR
 # if defined(__VMS__)
 
-#  define lib$find_file	LIB$FIND_FILE
+#  define lib$find_file LIB$FIND_FILE
 
 /*
 **  VMS readdir() routines.
@@ -469,13 +469,13 @@
 	__BEGIN_INTERRUPTABLE__
 	do {
 	    do {
-	        errno = 0;
-	        dp = readdir(d);
-	        /*
-	         * for compatibility with ST-80,
-	         * skip entries for '.' and '..'.
-	         * If wanted, these must be added synthetically.
-	         */
+		errno = 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) && (errno == EINTR));
 	__END_INTERRUPTABLE__
@@ -495,12 +495,18 @@
     HANDLE d;
     WIN32_FIND_DATA data;
     OBJ dirP;
+    int rslt;
 
     if (__INST(hitEOF) != true && (dirP = __INST(dirPointer)) != nil) {
 	__INST(lastErrorNumber) = nil;
 	d = __HANDLEVal(dirP);
 
-	if (FindNextFile(d, &data)) {
+#  ifdef DO_WRAP_CALLS
+	rslt = __doWrapCall2(1,(void*)FindNextFile,(void *)d, (void *)&data);
+#  else
+	rslt = FindNextFile(d, &data);
+#  endif
+	if (rslt) {
 	    nextEntry = __MKSTRING( data.cFileName );
 	} else {
 	   __INST(hitEOF) = true;
@@ -599,12 +605,16 @@
 	    int l = __stringSize(path);
 
 	    if (l < (sizeof(pattern)-4)) {
-	        strncpy(pattern, __stringVal(path), l);
-	        strcpy(pattern+l, "\\*");
-	        d = FindFirstFile(pattern, &data);
-	        if (d == INVALID_HANDLE_VALUE) {
+		strncpy(pattern, __stringVal(path), l);
+		strcpy(pattern+l, "\\*");
+#  ifdef DO_WRAP_CALLS
+		d = __doWrapCall2(1,(void*)FindFirstFile,(void *)pattern, (void *)&data);
+#  else
+		d = FindFirstFile(pattern, &data);
+#  endif
+		if (d == INVALID_HANDLE_VALUE) {
 		    __INST(lastErrorNumber) = __MKSMALLINT(GetLastError());
-	        } else {
+		} else {
 		    __INST(dirPointer) = dp = __MKEXTERNALADDRESS(d); __STORE(self, dp);
 		    entry = __MKSTRING( data.cFileName );
 		    ok = true;
@@ -658,17 +668,17 @@
     |entry|
 
     [self atEnd] whileFalse:[
-        entry := self nextLine.
-        entry asFilename isImplicit ifFalse:[
-            ^ false.
-        ]
+	entry := self nextLine.
+	entry asFilename isImplicit ifFalse:[
+	    ^ false.
+	]
     ].
     ^ true
 
 
     "
-        (DirectoryStream directoryNamed:'/') isEmpty
-        (DirectoryStream directoryNamed:'/var/tmp') isEmpty
+	(DirectoryStream directoryNamed:'/') isEmpty
+	(DirectoryStream directoryNamed:'/var/tmp') isEmpty
     "
 
     "Modified: 18.9.1997 / 18:05:31 / stefan"
@@ -677,5 +687,5 @@
 !DirectoryStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.42 1998-01-12 13:21:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.43 1998-09-10 11:08:03 cg Exp $'
 ! !