--- a/Win32OperatingSystem.st Mon Feb 04 15:31:14 2002 +0100
+++ b/Win32OperatingSystem.st Mon Feb 04 17:55:40 2002 +0100
@@ -3789,16 +3789,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.
@@ -3822,120 +3822,140 @@
unsigned INT ino;
if (__isString(aPathName)) {
- HANDLE hFile;
- SYSTEMTIME creationTime;
- SYSTEMTIME accessTime;
- SYSTEMTIME modificationTime;
- int modeBits = 0;
- WIN32_FIND_DATA findStruct;
+ HANDLE hFile;
+ 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);
- RETURN (nil);
- }
- FindClose(hFile);
-
- id = __MKSMALLINT(0); /* could get it by opening ... */
- size = __MKLARGEINT64(1, findStruct.nFileSizeLow, findStruct.nFileSizeHigh);
-
- if (findStruct.cAlternateFileName[0] != '\0') {
- bcopy(findStruct.cAlternateFileName, nameBuffer, 14);
- nameBuffer[14] = '\0';
- name2 = __MKSTRING(nameBuffer); /* 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.cAlternateFileName[0] != '\0') {
+ bcopy(findStruct.cAlternateFileName, nameBuffer, 14);
+ nameBuffer[14] = '\0';
+ name2 = __MKSTRING(nameBuffer); /* 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);
+ }
}
%}.
+ 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 := AbsoluteTime now.
+ ].
+ ].
mode notNil ifTrue:[
- atime := AbsoluteTime day:aDay month:aMon year:aYr hour:aHr minutes:aMin seconds:aSec milliseconds:aMS.
- mtime := AbsoluteTime day:mDay month:mMon year:mYr hour:mHr minutes:mMin seconds:mSec milliseconds:mMS.
- ctime := AbsoluteTime 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
- statusChanged:ctime
- path:nil
- alternativeName:name2.
- ^ info
+ atime isNil ifTrue:[
+ atime := AbsoluteTime day:aDay month:aMon year:aYr hour:aHr minutes:aMin seconds:aSec milliseconds:aMS.
+ ].
+ mtime isNil ifTrue:[
+ mtime := AbsoluteTime day:mDay month:mMon year:mYr hour:mHr minutes:mMin seconds:mSec milliseconds:mMS.
+ ].
+ ctime isNil ifTrue:[
+ ctime := AbsoluteTime 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
+ statusChanged:ctime
+ path:nil
+ alternativeName:name2.
+ ^ info
].
^ self primitiveFailed
"
- OperatingSystem infoOf:'/'
+ OperatingSystem infoOf:'c:\windows'
OperatingSystem infoOf:'stx.exe'
(OperatingSystem infoOf:'/') uid
(OperatingSystem infoOf:'/') accessed
"
+
+ "Modified: / 4.2.2002 / 17:15:08 / cg"
!
isDirectory:aPathName
@@ -8572,7 +8592,7 @@
!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.108 2002-02-01 10:13:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.109 2002-02-04 16:55:40 cg Exp $'
! !
!Win32OperatingSystem::Win32FILEHandle methodsFor:'release'!
@@ -8599,7 +8619,7 @@
!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.108 2002-02-01 10:13:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.109 2002-02-04 16:55:40 cg Exp $'
! !
!Win32OperatingSystem::Win32Handle methodsFor:'io'!
@@ -8986,6 +9006,6 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.108 2002-02-01 10:13:46 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.109 2002-02-04 16:55:40 cg Exp $'
! !
Win32OperatingSystem initialize!