Win32OperatingSystem.st
branchjv
changeset 18060 3708e12e9aa8
parent 18057 8da7c39a6322
parent 15252 621c034e94a0
child 18062 014678b4657a
--- a/Win32OperatingSystem.st	Tue May 21 21:58:09 2013 +0100
+++ b/Win32OperatingSystem.st	Fri May 24 18:52:05 2013 +0100
@@ -747,13 +747,16 @@
     HRESULT hres;
 
     if( ! coInitialized ) {
+
 	hres = CoInitializeEx(NULL, COINIT_MULTITHREADED);
 	if (! SUCCEEDED(hres)) {
 	    console_fprintf(stderr, "OperatingSystem [info]: Could not open the COM library hres = %08x\n", hres );
 	    goto error;
 	}
 	coInitialized = 1;
+
 #ifdef COM_DEBUG
+
 	console_fprintf(stderr, "OperatingSystem [info]: COM initialized\n" );
 #endif
     }
@@ -821,7 +824,6 @@
     "Modified: 7.1.1997 / 19:36:11 / stefan"
 ! !
 
-
 !Win32OperatingSystem class methodsFor:'OS signal constants'!
 
 sigABRT
@@ -5526,23 +5528,24 @@
     "return some object filled with info for the file 'aPathName';
      the info (for which corresponding access methods are understood by
      the returned object) is:
-	 type            - a symbol giving the files type
-	 mode            - numeric access mode
-	 uid             - owners user id
-	 gid             - owners group id
-	 size            - files size
-	 id              - files number (i.e. inode number)
-	 accessed        - last access time (as Timestamp)
-	 modified        - last modification time (as Timestamp)
-	 statusChanged   - last status change time (as Timestamp)
-	 alternativeName - (windows only:) the MSDOS name of the file
+         type            - a symbol giving the files type
+         mode            - numeric access mode
+         uid             - owners user id
+         gid             - owners group id
+         size            - files size
+         id              - files number (i.e. inode number)
+         accessed        - last access time (as Timestamp)
+         modified        - last modification time (as Timestamp)
+         statusChanged   - last status change time (as Timestamp)
+         alternativeName - (windows only:) the MSDOS name of the file
 
      Some of the fields may be returned as nil on systems which do not provide
      all of the information.
      Return nil if such a file does not exist.
-     For symbolic links (if supported by the OS),
-     the info of the pointed-to-file (i.e. the target) is returned;
-     use #linkInfoOf: to get info about the link itself.
+
+     Return the info about the link itself,
+     on contrast to #infoOf:, which returns the info of the pointed to file
+     in case of a symbolic link.
     "
 
     |info type mode uid gid size id
@@ -5561,45 +5564,45 @@
     wchar_t _aPathName[MAXPATHLEN+1];
 
     if (__isStringLike(aPathName)) {
-	int i;
-	int l = __stringSize(aPathName);
-	if (l > MAXPATHLEN) l = MAXPATHLEN;
-
-	for (i=0; i<l; i++) {
-	    _aPathName[i] = __stringVal(aPathName)[i];
-	}
-	_aPathName[i] = 0;
+        int i;
+        int l = __stringSize(aPathName);
+        if (l > MAXPATHLEN) l = MAXPATHLEN;
+
+        for (i=0; i<l; i++) {
+            _aPathName[i] = __stringVal(aPathName)[i];
+        }
+        _aPathName[i] = 0;
     } else if (__isUnicode16String(aPathName)) {
-	int i;
-	int l = __unicode16StringSize(aPathName);
-	if (l > MAXPATHLEN) l = MAXPATHLEN;
-
-	for (i=0; i<l; i++) {
-	    _aPathName[i] = __unicode16StringVal(aPathName)[i];
-	}
-	_aPathName[i] = 0;
+        int i;
+        int l = __unicode16StringSize(aPathName);
+        if (l > MAXPATHLEN) l = MAXPATHLEN;
+
+        for (i=0; i<l; i++) {
+            _aPathName[i] = __unicode16StringVal(aPathName)[i];
+        }
+        _aPathName[i] = 0;
     } else
-	goto badArgument;
+        goto badArgument;
 
 #ifdef DO_WRAP_CALLS
     {
-	do {
-	    __threadErrno = 0;
-	    result = STX_API_NOINT_CALL3( "GetFileAttributesExW", GetFileAttributesExW, _aPathName, GetFileExInfoStandard, &fileAttributeData);
-	} while (!result && (__threadErrno == EINTR));
+        do {
+            __threadErrno = 0;
+            result = STX_API_NOINT_CALL3( "GetFileAttributesExW", GetFileAttributesExW, _aPathName, GetFileExInfoStandard, &fileAttributeData);
+        } while (!result && (__threadErrno == EINTR));
     }
 #else
     result = GetFileAttributesExW(_aPathName, GetFileExInfoStandard, &fileAttributeData);
     if (!result) {
-	__threadErrno = __WIN32_ERR(GetLastError());
+        __threadErrno = __WIN32_ERR(GetLastError());
     }
 #endif
 
     if (!result) {
-	@global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
+        @global(LastErrorNumber) = __mkSmallInteger(__threadErrno);
     } else {
-	id = __mkSmallInteger(0);   /* could get it by opening ... */
-	size = __MKLARGEINT64(1, fileAttributeData.nFileSizeLow, fileAttributeData.nFileSizeHigh);
+        id = __mkSmallInteger(0);   /* could get it by opening ... */
+        size = __MKLARGEINT64(1, fileAttributeData.nFileSizeLow, fileAttributeData.nFileSizeHigh);
 
 //        if (fileAttributeData.cFileName[0] != '\0') {
 //            bcopy(fileAttributeData.cFileName, fileNameBuffer, MAXPATHLEN*sizeof(wchar_t));
@@ -5613,83 +5616,83 @@
 //            alternativeName = __MKU16STRING(alternativeFileNameBuffer); /* DOS name */
 //        }
 
-	/*
-	 * simulate access bits
-	 */
-	if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
-	    modeBits = 0444;
-	} else {
-	    modeBits = 0666;
-	}
-
-	if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
-	    type = @symbol(directory);
-	    modeBits = 0777;   /* executable and WRITABLE - refer to comment in #isWritable: */
-	} else if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
-	    type = @symbol(symbolicLink);
-	    modeBits = 0777;   /* even in UNIX symlinks have 0777 */
-	} else {
-	    type = @symbol(regular);
-	}
-
-	mode = __mkSmallInteger(modeBits);
-
-	cOsTime = FileTimeToOsTime(&fileAttributeData.ftCreationTime);
-	aOsTime = FileTimeToOsTime(&fileAttributeData.ftLastAccessTime);
-	mOsTime = FileTimeToOsTime(&fileAttributeData.ftLastWriteTime);
+        /*
+         * simulate access bits
+         */
+        if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
+            modeBits = 0444;
+        } else {
+            modeBits = 0666;
+        }
+
+        if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+            type = @symbol(directory);
+            modeBits = 0777;   /* executable and WRITABLE - refer to comment in #isWritable: */
+        } else if (fileAttributeData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+            type = @symbol(symbolicLink);
+            modeBits = 0777;   /* even in UNIX symlinks have 0777 */
+        } else {
+            type = @symbol(regular);
+        }
+
+        mode = __mkSmallInteger(modeBits);
+
+        cOsTime = FileTimeToOsTime(&fileAttributeData.ftCreationTime);
+        aOsTime = FileTimeToOsTime(&fileAttributeData.ftLastAccessTime);
+        mOsTime = FileTimeToOsTime(&fileAttributeData.ftLastWriteTime);
     }
 
   badArgument: ;
 %}.
 
     (aPathName endsWith:'.lnk') ifTrue:[
-	type := #symbolicLink.
-	"/ now done lazyly in FileStatusInfo, when the path is accessed
-	"/ path := self getLinkTarget:aPathName.
+        type := #symbolicLink.
+        "/ now done lazyly in FileStatusInfo, when the path is accessed
+        "/ path := self getLinkTarget:aPathName.
     ].
 
     mode isNil ifTrue:[
-	(self isDirectory:aPathName) ifTrue:[
-	    "/ the code above fails for root directories (these do not exist).
-	    "/ simulate here
-	    mode := 8r777.
-	    type := #directory.
-	    uid := gid := 0.
-	    size := 0.
-	    id := 0.
-	    atime := mtime := ctime := Timestamp now.
-	].
+        (self isDirectory:aPathName) ifTrue:[
+            "/ the code above fails for root directories (these do not exist).
+            "/ simulate here
+            mode := 8r777.
+            type := #directory.
+            uid := gid := 0.
+            size := 0.
+            id := 0.
+            atime := mtime := ctime := Timestamp now.
+        ].
     ].
     mode notNil ifTrue:[
-	atime isNil ifTrue:[
-	    atime := Timestamp new fromOSTime:aOsTime.
-	].
-	mtime isNil ifTrue:[
-	    mtime := Timestamp new fromOSTime:mOsTime.
-	].
-	ctime isNil ifTrue:[
-	    ctime := Timestamp new fromOSTime:cOsTime.
-	].
-	fileName notNil ifTrue:[
-	    fileName := fileName asSingleByteStringIfPossible
-	].
-	alternativeName notNil ifTrue:[
-	    alternativeName := alternativeName asSingleByteStringIfPossible
-	].
-	info := FileStatusInfo
-		    type:type
-		    mode:mode
-		    uid:uid
-		    gid:gid
-		    size:size
-		    id:id
-		    accessed:atime
-		    modified:mtime
-		    created:ctime
-		    sourcePath:aPathName
-		    fullName:fileName
-		    alternativeName:alternativeName.
-	^ info
+        atime isNil ifTrue:[
+            atime := Timestamp new fromOSTime:aOsTime.
+        ].
+        mtime isNil ifTrue:[
+            mtime := Timestamp new fromOSTime:mOsTime.
+        ].
+        ctime isNil ifTrue:[
+            ctime := Timestamp new fromOSTime:cOsTime.
+        ].
+        fileName notNil ifTrue:[
+            fileName := fileName asSingleByteStringIfPossible
+        ].
+        alternativeName notNil ifTrue:[
+            alternativeName := alternativeName asSingleByteStringIfPossible
+        ].
+        info := FileStatusInfo
+                    type:type
+                    mode:mode
+                    uid:uid
+                    gid:gid
+                    size:size
+                    id:id
+                    accessed:atime
+                    modified:mtime
+                    created:ctime
+                    sourcePath:aPathName
+                    fullName:fileName
+                    alternativeName:alternativeName.
+        ^ info
    ].
    ^ nil
 
@@ -5862,21 +5865,21 @@
 
 %{
     if (__isStringLike(aPathName)) {
-	char nameBuffer[MAXPATHLEN + 1];
-	char nameBuffer2[MAXPATHLEN + 1];
-	char *returnedName = NULL;
-	int rslt;
+        char nameBuffer[MAXPATHLEN + 1];
+        char nameBuffer2[MAXPATHLEN + 1];
+        char *returnedName = NULL;
+        int rslt;
 
 #ifdef DO_WRAP_CALLS
-	char _aPathName[MAXPATHLEN+1];
-
-	strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
-	do {
-	    __threadErrno = 0;
-	    rslt = STX_API_NOINT_CALL4( "GetFullPathNameA", GetFullPathNameA, _aPathName, MAXPATHLEN, nameBuffer, NULL);
-	} while ((rslt < 0) && (__threadErrno == EINTR));
-#else
-	rslt = GetFullPathNameA(__stringVal(aPathName), MAXPATHLEN, nameBuffer, NULL);
+        char _aPathName[MAXPATHLEN+1];
+
+        strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
+        do {
+            __threadErrno = 0;
+            rslt = STX_API_NOINT_CALL4( "GetFullPathNameA", GetFullPathNameA, _aPathName, MAXPATHLEN, nameBuffer, NULL);
+        } while ((rslt < 0) && (__threadErrno == EINTR));
+#else
+        rslt = GetFullPathNameA(__stringVal(aPathName), MAXPATHLEN, nameBuffer, NULL);
 #endif
 	returnedName = nameBuffer;
 
@@ -5898,31 +5901,33 @@
 	RETURN (nil);
     }
     if (__isUnicode16String(aPathName)) {
-	wchar_t nameBuffer[MAXPATHLEN + 1];
-	wchar_t nameBuffer2[MAXPATHLEN + 1];
-	wchar_t *returnedName = NULL;
-	int rslt;
-	wchar_t _aPathName[MAXPATHLEN+1];
-	int i, l;
-
-	l = __unicode16StringSize(aPathName);
-	if (l > MAXPATHLEN) l = MAXPATHLEN;
-	for (i=0; i<l; i++) {
-	    _aPathName[i] = __unicode16StringVal(aPathName)[i];
-	}
-	_aPathName[i] = 0;
+        wchar_t nameBuffer[MAXPATHLEN + 1];
+        wchar_t nameBuffer2[MAXPATHLEN + 1];
+        wchar_t *returnedName = NULL;
+        int rslt;
+        wchar_t _aPathName[MAXPATHLEN+1];
+        int i, l;
+
+        l = __unicode16StringSize(aPathName);
+        if (l > MAXPATHLEN) l = MAXPATHLEN;
+        for (i=0; i<l; i++) {
+            _aPathName[i] = __unicode16StringVal(aPathName)[i];
+        }
+        _aPathName[i] = 0;
 
 #ifdef DO_WRAP_CALLS
-	do {
-	    __threadErrno = 0;
-	    rslt = STX_API_NOINT_CALL4( "GetFullPathNameW", GetFullPathNameW, _aPathName, MAXPATHLEN, nameBuffer, NULL);
-	} while ((rslt < 0) && (__threadErrno == EINTR));
-#else
-	rslt = GetFullPathNameW(_aPathName, MAXPATHLEN, nameBuffer, NULL);
-#endif
+        do {
+            __threadErrno = 0;
+            rslt = STX_API_NOINT_CALL4( "GetFullPathNameW", GetFullPathNameW, _aPathName, MAXPATHLEN, nameBuffer, NULL);
+        } while ((rslt < 0) && (__threadErrno == EINTR));
+#else
+        rslt = GetFullPathNameW(_aPathName, MAXPATHLEN, nameBuffer, NULL);
+#endif
+
 	returnedName = nameBuffer;
 
 	if (rslt > 0) {
+
 #ifdef DO_WRAP_CALLS
 	    do {
 		__threadErrno = 0;
@@ -5940,6 +5945,7 @@
     }
     error = @symbol(argument);     // argument is not a string or unicode16string
 %}.
+
     error notNil ifTrue:[
 	self primitiveFailed:error.
     ].
@@ -7776,8 +7782,8 @@
 
 getNetworkMACAddresses
     "return a dictionary filled with
-	key -> name of interface
-	value -> the MAC adress (as ByteArray)
+        key -> name of interface
+        value -> the MAC adress (as ByteArray)
      for each interface
     "
 
@@ -7813,6 +7819,7 @@
 	    ipAddress = __MKSTRING(pAdapterInfo->IpAddressList.IpAddress.String);
 	    ipAddressMask = __MKSTRING(pAdapterInfo->IpAddressList.IpMask.String);
 	    entry = __ARRAY_NEW_INT(5);
+
 /*
  * back to ST/X's String definition
  */
@@ -7838,16 +7845,16 @@
     "Keep the order as reurned by the OS"
     info := OrderedDictionary new:nAdapters.
     nAdapters notNil ifTrue:[
-	1 to:nAdapters do:[:i |
-	    |entry name description macAddr ipAddr|
-
-	    entry := rawData at:i.
-	    name := entry at:1.
-	    "/ description := entry at:2.
-	    macAddr := entry at:3.
-	    "/ ipAddr := entry at:4.
-	    info at:name put:macAddr.
-	].
+        1 to:nAdapters do:[:i |
+            |entry name description macAddr ipAddr|
+
+            entry := rawData at:i.
+            name := entry at:1.
+            "/ description := entry at:2.
+            macAddr := entry at:3.
+            "/ ipAddr := entry at:4.
+            info at:name put:macAddr.
+        ].
     ].
     ^ info
 
@@ -11629,6 +11636,14 @@
     ^ type == #socket
 !
 
+isSpecialFile
+    ^ (type ~~ #directory
+        and:[type ~~ #remoteDirectory
+        and:[type ~~ #regular
+        and:[type ~~ #symbolicLink
+    ]]])
+!
+
 isSymbolicLink
     ^ type == #symbolicLink
 !
@@ -17105,15 +17120,15 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.461 2013-04-26 12:42:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.462 2013-05-15 17:06:14 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.461 2013-04-26 12:42:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.462 2013-05-15 17:06:14 stefan Exp $'
 !
 
 version_SVN
-    ^ '§Id§'
+    ^ '$Id: Win32OperatingSystem.st,v 1.462 2013-05-15 17:06:14 stefan Exp $'
 
 ! !