--- a/Win32OperatingSystem.st Tue Nov 29 16:05:46 2016 +0100
+++ b/Win32OperatingSystem.st Tue Nov 29 21:48:26 2016 +0100
@@ -5163,76 +5163,82 @@
"
this could have been implemented as:
- (self infoOf:aPathName) at:#mode
+ (self infoOf:aPathName) at:#mode
but for huge directory searches the code below is faster
"
+ |error|
+
%{
struct stat buf;
int ret;
if (__isStringLike(aPathName)) {
#ifdef DO_WRAP_CALLS
- char _aPathName[MAXPATHLEN];
-
- strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
-
- do {
- __threadErrno = 0;
- // do not cast to INT - will loose sign bit then!
- ret = STX_C_NOINT_CALL2( "_stat", _stat, _aPathName, &buf);
- } while ((ret < 0) && (__threadErrno == EINTR));
-#else
- __BEGIN_INTERRUPTABLE__
- do {
- __threadErrno = 0;
- ret = _stat( (char *)__stringVal(aPathName), &buf);
- } while ((ret < 0) && (__threadErrno == EINTR));
- __END_INTERRUPTABLE__
- if (ret < 0) {
- __threadErrno = __WIN32_ERR(GetLastError());
- }
-#endif
- if (ret < 0) {
- @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
- RETURN ( nil );
- }
- RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
+ char _aPathName[MAXPATHLEN];
+
+ strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
+
+ do {
+ __threadErrno = 0;
+ // do not cast to INT - will loose sign bit then!
+ ret = STX_C_NOINT_CALL2( "_stat", _stat, _aPathName, &buf);
+ } while ((ret < 0) && (__threadErrno == EINTR));
+#else
+ __BEGIN_INTERRUPTABLE__
+ do {
+ __threadErrno = 0;
+ ret = _stat( (char *)__stringVal(aPathName), &buf);
+ } while ((ret < 0) && (__threadErrno == EINTR));
+ __END_INTERRUPTABLE__
+ if (ret < 0) {
+ __threadErrno = __WIN32_ERR(GetLastError());
+ }
+#endif
} else if (__isUnicode16String(aPathName)) {
#ifdef DO_WRAP_CALLS
- char _wPathName[MAXPATHLEN];
-
- _makeWchar(aPathName, _wPathName, sizeof(_wPathName));
-
- do {
- __threadErrno = 0;
- // do not cast to INT - will loose sign bit then!
- ret = STX_C_NOINT_CALL2( "_wstat", _wstat, _wPathName, &buf);
- } while ((ret < 0) && (__threadErrno == EINTR));
-#else
- __BEGIN_INTERRUPTABLE__
- do {
- __threadErrno = 0;
- ret = _wstat((char *)__unicode16StringVal(aPathName), &buf);
- } while ((ret < 0) && (__threadErrno == EINTR));
- __END_INTERRUPTABLE__
- if (ret < 0) {
- __threadErrno = __WIN32_ERR(GetLastError());
- }
-#endif
- if (ret < 0) {
- @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
- RETURN ( nil );
- }
- RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
- }
-%}.
- ^ self primitiveFailed
+ char _wPathName[MAXPATHLEN];
+
+ _makeWchar(aPathName, _wPathName, sizeof(_wPathName));
+
+ do {
+ __threadErrno = 0;
+ // do not cast to INT - will loose sign bit then!
+ ret = STX_C_NOINT_CALL2( "_wstat", _wstat, _wPathName, &buf);
+ } while ((ret < 0) && (__threadErrno == EINTR));
+#else
+ __BEGIN_INTERRUPTABLE__
+ do {
+ __threadErrno = 0;
+ ret = _wstat((char *)__unicode16StringVal(aPathName), &buf);
+ } while ((ret < 0) && (__threadErrno == EINTR));
+ __END_INTERRUPTABLE__
+ if (ret < 0) {
+ __threadErrno = __WIN32_ERR(GetLastError());
+ }
+#endif
+ } else
+ goto out;
+
+ if (ret >= 0) {
+ RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
+ }
+ error = __mkSmallInteger(__threadErrno);
+out:;
+%}.
+
+ error notNil ifTrue:[
+ LastErrorNumber := error.
+ ^ self errorHolderForNumber:error.
+ ].
+
+ ^ self primitiveFailed
"
(OperatingSystem accessModeOf:'/') printStringRadix:8
+ (OperatingSystem accessModeOf:'foo') printStringRadix:8
(OperatingSystem accessModeOf:'Make.proto') printStringRadix:8
- (OperatingSystem changeAccessModeOf:'Make.proto' to:8r644)
+ (OperatingSystem changeAccessModeOf:'foo' to:8r644)
'Make.proto' asUnicode16String asFilename accessRights printStringRadix:8
"
!
@@ -5245,49 +5251,57 @@
"
this could have been implemented as:
- (self infoOf:aPathName) at:#mode
+ (self infoOf:aPathName) at:#mode
but for huge directory searches the code below is faster
"
+ |error|
+
%{
struct stat buf;
int ret;
if (__isSmallInteger(aFileDescriptor)) {
#ifdef DO_WRAP_CALLS
- do {
- __threadErrno = 0;
- // do not cast to INT - will loose sign bit then!
- ret = STX_C_NOINT_CALL2( "fstat", fstat, __smallIntegerVal(aFileDescriptor), &buf);
- } while ((ret < 0) && (__threadErrno == EINTR));
-#else
- __BEGIN_INTERRUPTABLE__
- do {
- __threadErrno = 0;
- // do not cast to INT - will loose sign bit then!
- ret = fstat( __smallIntegerVal(aFileDescriptor), &buf);
- } while ((ret < 0) && (__threadErrno == EINTR));
- __END_INTERRUPTABLE__
- if (ret < 0) {
- __threadErrno = __WIN32_ERR(GetLastError());
- }
-#endif
-
- if (ret < 0) {
- @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
- RETURN ( nil );
- }
- RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
- }
-%}.
- ^ self primitiveFailed
+ do {
+ __threadErrno = 0;
+ // do not cast to INT - will loose sign bit then!
+ ret = STX_C_NOINT_CALL2( "fstat", fstat, __smallIntegerVal(aFileDescriptor), &buf);
+ } while ((ret < 0) && (__threadErrno == EINTR));
+#else
+ __BEGIN_INTERRUPTABLE__
+ do {
+ __threadErrno = 0;
+ // do not cast to INT - will loose sign bit then!
+ ret = fstat( __smallIntegerVal(aFileDescriptor), &buf);
+ } while ((ret < 0) && (__threadErrno == EINTR));
+ __END_INTERRUPTABLE__
+ if (ret < 0) {
+ __threadErrno = __WIN32_ERR(GetLastError());
+ }
+#endif
+ } else
+ goto out;
+
+ if (ret >= 0) {
+ RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
+ }
+ error = __mkSmallInteger(__threadErrno);
+out:;
+%}.
+
+ error notNil ifTrue:[
+ LastErrorNumber := error.
+ ^ self errorHolderForNumber:error.
+ ].
+ ^ self primitiveFailed
"
'c:\windows' asFilename readingFileDo:[:s|
- (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8.
+ (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8.
].
'Make.proto' asFilename readingFileDo:[:s|
- (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8.
+ (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8.
].
(OperatingSystem changeAccessModeOf:'Make.proto' to:8r644)
"
@@ -5339,7 +5353,8 @@
} while ((ret < 0) && (__threadErrno == EINTR));
__END_INTERRUPTABLE__
#endif
- }
+ } else
+ goto out;
if (ret >= 0) {
RETURN (nil);
@@ -5347,6 +5362,7 @@
error = __mkSmallInteger(__threadErrno);
}
+out:;
%}.
error notNil ifTrue:[