Win32OperatingSystem.st
changeset 8360 2b3d4d8ea027
parent 8349 b87b90e6d15a
child 8412 cb1f92123250
--- a/Win32OperatingSystem.st	Thu May 13 20:57:22 2004 +0200
+++ b/Win32OperatingSystem.st	Fri May 14 21:27:17 2004 +0200
@@ -3952,16 +3952,16 @@
     "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.
@@ -3987,136 +3987,140 @@
     unsigned INT ino;
 
     if (__isString(aPathName)) {
-	HANDLE hFile;
-	SYSTEMTIME creationTime;
-	SYSTEMTIME accessTime;
-	SYSTEMTIME modificationTime;
-	int modeBits = 0;
-	WIN32_FIND_DATA findStruct;
+        HANDLE hFile;
+        FILETIME tempFileTime;
+        SYSTEMTIME creationTime;
+        SYSTEMTIME accessTime;
+        SYSTEMTIME modificationTime;
+        int modeBits = 0;
+        WIN32_FIND_DATA findStruct;
 
 #ifdef DO_WRAP_CALLS
-	{
-	    char _aPathName[MAXPATHLEN];
-
-	    strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
-	    do {
-		__threadErrno = 0;
-		hFile = STX_API_CALL2( "FindFirstFile", FindFirstFile, _aPathName, &findStruct);
-	    } while ((hFile < 0) && (__threadErrno == EINTR));
-	}
+        {
+            char _aPathName[MAXPATHLEN];
+
+            strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0';
+            do {
+                __threadErrno = 0;
+                hFile = STX_API_CALL2( "FindFirstFile", FindFirstFile, _aPathName, &findStruct);
+            } while ((hFile < 0) && (__threadErrno == EINTR));
+        }
 #else
-	hFile = FindFirstFile(__stringVal(aPathName), &findStruct);
-	if (hFile < 0) {
-	    __threadErrno = __WIN32_ERR(GetLastError());
-	}
-#endif
-	if (! hFile || (hFile == (HANDLE)(-1)) || (hFile == INVALID_HANDLE_VALUE)) {
-	    @global(LastErrorNumber) = __MKSMALLINT(__threadErrno);
-	} else {
-	    FindClose(hFile);
-
-	    id = __MKSMALLINT(0);   /* could get it by opening ... */
-	    size = __MKLARGEINT64(1, findStruct.nFileSizeLow, findStruct.nFileSizeHigh);
-
-	    if (findStruct.cFileName[0] != '\0') {
-		bcopy(findStruct.cFileName, fileNameBuffer, MAX_PATH);
-		fileNameBuffer[MAX_PATH] = '\0';
-		fileName = __MKSTRING(fileNameBuffer);             /* FULL name */
-	    }
-
-	    if (findStruct.cAlternateFileName[0] != '\0') {
-		bcopy(findStruct.cAlternateFileName, alternativeFileNameBuffer, 14);
-		alternativeFileNameBuffer[14] = '\0';
-		alternativeName = __MKSTRING(alternativeFileNameBuffer); /* DOS name */
-	    }
-
-	    /*
-	     * simulate access bits
-	     */
-	    if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
-		modeBits = 0444;
-	    } else {
-		modeBits = 0666;
-	    }
-
-	    if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
-		type = @symbol(directory);
-		modeBits |= 0111;   /* executable */
-	    } else {
-		type = @symbol(regular);
-	    }
-
-	    mode = __MKSMALLINT(modeBits);
-
-	    /*
-	     * sigh - convert from stupid time to useful time
-	     */
-	    FileTimeToSystemTime(&(findStruct.ftCreationTime), &creationTime);
-	    FileTimeToSystemTime(&(findStruct.ftLastAccessTime), &accessTime);
-	    FileTimeToSystemTime(&(findStruct.ftLastWriteTime), &modificationTime);
-	    aYr  = __MKSMALLINT(accessTime.wYear);
-	    aMon = __MKSMALLINT(accessTime.wMonth);
-	    aDay = __MKSMALLINT(accessTime.wDay);
-	    aHr  = __MKSMALLINT(accessTime.wHour);
-	    aMin = __MKSMALLINT(accessTime.wMinute);
-	    aSec = __MKSMALLINT(accessTime.wSecond);
-	    aMS  = __MKSMALLINT(accessTime.wMilliseconds);
-
-	    mYr  = __MKSMALLINT(modificationTime.wYear);
-	    mMon = __MKSMALLINT(modificationTime.wMonth);
-	    mDay = __MKSMALLINT(modificationTime.wDay);
-	    mHr  = __MKSMALLINT(modificationTime.wHour);
-	    mMin = __MKSMALLINT(modificationTime.wMinute);
-	    mSec = __MKSMALLINT(modificationTime.wSecond);
-	    mMS  = __MKSMALLINT(modificationTime.wMilliseconds);
-
-	    cYr  = __MKSMALLINT(creationTime.wYear);
-	    cMon = __MKSMALLINT(creationTime.wMonth);
-	    cDay = __MKSMALLINT(creationTime.wDay);
-	    cHr  = __MKSMALLINT(creationTime.wHour);
-	    cMin = __MKSMALLINT(creationTime.wMinute);
-	    cSec = __MKSMALLINT(creationTime.wSecond);
-	    cMS  = __MKSMALLINT(creationTime.wMilliseconds);
-	}
+        hFile = FindFirstFile(__stringVal(aPathName), &findStruct);
+        if (hFile < 0) {
+            __threadErrno = __WIN32_ERR(GetLastError());
+        }
+#endif
+        if (! hFile || (hFile == (HANDLE)(-1)) || (hFile == INVALID_HANDLE_VALUE)) {
+            @global(LastErrorNumber) = __MKSMALLINT(__threadErrno);
+        } else {
+            FindClose(hFile);
+
+            id = __MKSMALLINT(0);   /* could get it by opening ... */
+            size = __MKLARGEINT64(1, findStruct.nFileSizeLow, findStruct.nFileSizeHigh);
+
+            if (findStruct.cFileName[0] != '\0') {
+                bcopy(findStruct.cFileName, fileNameBuffer, MAX_PATH);
+                fileNameBuffer[MAX_PATH] = '\0';
+                fileName = __MKSTRING(fileNameBuffer);             /* FULL name */
+            }
+
+            if (findStruct.cAlternateFileName[0] != '\0') {
+                bcopy(findStruct.cAlternateFileName, alternativeFileNameBuffer, 14);
+                alternativeFileNameBuffer[14] = '\0';
+                alternativeName = __MKSTRING(alternativeFileNameBuffer); /* DOS name */
+            }
+
+            /*
+             * simulate access bits
+             */
+            if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
+                modeBits = 0444;
+            } else {
+                modeBits = 0666;
+            }
+
+            if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+                type = @symbol(directory);
+                modeBits |= 0111;   /* executable */
+            } else {
+                type = @symbol(regular);
+            }
+
+            mode = __MKSMALLINT(modeBits);
+
+            /*
+             * sigh - convert from stupid time to useful time
+             */
+            FileTimeToLocalFileTime(&findStruct.ftCreationTime, &tempFileTime);
+            FileTimeToSystemTime(&tempFileTime, &creationTime);
+            FileTimeToLocalFileTime(&findStruct.ftLastAccessTime, &tempFileTime);
+            FileTimeToSystemTime(&tempFileTime, &accessTime);
+            FileTimeToLocalFileTime(&findStruct.ftLastWriteTime, &tempFileTime);
+            FileTimeToSystemTime(&tempFileTime, &modificationTime);
+            aYr  = __MKSMALLINT(accessTime.wYear);
+            aMon = __MKSMALLINT(accessTime.wMonth);
+            aDay = __MKSMALLINT(accessTime.wDay);
+            aHr  = __MKSMALLINT(accessTime.wHour);
+            aMin = __MKSMALLINT(accessTime.wMinute);
+            aSec = __MKSMALLINT(accessTime.wSecond);
+            aMS  = __MKSMALLINT(accessTime.wMilliseconds);
+
+            mYr  = __MKSMALLINT(modificationTime.wYear);
+            mMon = __MKSMALLINT(modificationTime.wMonth);
+            mDay = __MKSMALLINT(modificationTime.wDay);
+            mHr  = __MKSMALLINT(modificationTime.wHour);
+            mMin = __MKSMALLINT(modificationTime.wMinute);
+            mSec = __MKSMALLINT(modificationTime.wSecond);
+            mMS  = __MKSMALLINT(modificationTime.wMilliseconds);
+
+            cYr  = __MKSMALLINT(creationTime.wYear);
+            cMon = __MKSMALLINT(creationTime.wMonth);
+            cDay = __MKSMALLINT(creationTime.wDay);
+            cHr  = __MKSMALLINT(creationTime.wHour);
+            cMin = __MKSMALLINT(creationTime.wMinute);
+            cSec = __MKSMALLINT(creationTime.wSecond);
+            cMS  = __MKSMALLINT(creationTime.wMilliseconds);
+        }
     }
 %}.
     mode isNil ifTrue:[
-	(self isDirectory:aPathName) ifTrue:[
-	    "/ the code above fails for root directories (these do not exist).
-	    "/ simulate
-	    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
+            mode := 8r777.
+            type := #directory.
+            uid := gid := 0.
+            size := 0.
+            id := 0.
+            atime := mtime := ctime := Timestamp now.
+        ].
     ].
     mode notNil ifTrue:[
-	atime isNil ifTrue:[
-	    atime := Timestamp day:aDay month:aMon year:aYr hour:aHr minutes:aMin seconds:aSec milliseconds:aMS.
-	].
-	mtime isNil ifTrue:[
-	    mtime := Timestamp day:mDay month:mMon year:mYr hour:mHr minutes:mMin seconds:mSec milliseconds:mMS.
-	].
-	ctime isNil ifTrue:[
-	    ctime := Timestamp day:cDay month:cMon year:cYr hour:cHr minutes:cMin seconds:cSec milliseconds:cMS.
-	].
-
-	info := FileStatusInfo
-		    type:type
-		    mode:mode
-		    uid:uid
-		    gid:gid
-		    size:size
-		    id:id
-		    accessed:atime
-		    modified:mtime
-		    created:ctime
-		    path:nil
-		    fullName:fileName
-		    alternativeName:alternativeName.
-	^ info
+        atime isNil ifTrue:[
+            atime := Timestamp day:aDay month:aMon year:aYr hour:aHr minutes:aMin seconds:aSec milliseconds:aMS.
+        ].
+        mtime isNil ifTrue:[
+            mtime := Timestamp day:mDay month:mMon year:mYr hour:mHr minutes:mMin seconds:mSec milliseconds:mMS.
+        ].
+        ctime isNil ifTrue:[
+            ctime := Timestamp day:cDay month:cMon year:cYr hour:cHr minutes:cMin seconds:cSec milliseconds:cMS.
+        ].
+
+        info := FileStatusInfo
+                    type:type
+                    mode:mode
+                    uid:uid
+                    gid:gid
+                    size:size
+                    id:id
+                    accessed:atime
+                    modified:mtime
+                    created:ctime
+                    path:nil
+                    fullName:fileName
+                    alternativeName:alternativeName.
+        ^ info
    ].
    ^ nil
 
@@ -9036,7 +9040,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.156 2004-05-12 10:19:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.157 2004-05-14 19:27:17 stefan Exp $'
 ! !
 
 !Win32OperatingSystem::Win32FILEHandle methodsFor:'release'!
@@ -9063,7 +9067,7 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.156 2004-05-12 10:19:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.157 2004-05-14 19:27:17 stefan Exp $'
 ! !
 
 !Win32OperatingSystem::Win32Handle methodsFor:'io'!
@@ -9442,7 +9446,7 @@
 !Win32OperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.156 2004-05-12 10:19:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.157 2004-05-14 19:27:17 stefan Exp $'
 ! !
 
 Win32OperatingSystem initialize!