--- a/Win32OperatingSystem.st Tue Oct 21 15:36:37 2008 +0200
+++ b/Win32OperatingSystem.st Tue Oct 21 16:08:10 2008 +0200
@@ -35,7 +35,7 @@
Object subclass:#FileStatusInfo
instanceVariableNames:'type mode uid gid size id accessed modified created statusChanged
- path fullName alternativeName'
+ fullName alternativeName sourcePath linkTargetPath'
classVariableNames:''
poolDictionaries:''
privateIn:Win32OperatingSystem
@@ -436,6 +436,12 @@
%}
! !
+!Win32OperatingSystem primitiveVariables!
+%{
+static int coInitialized = 0;
+%}
+! !
+
!Win32OperatingSystem primitiveFunctions!
%{
@@ -568,12 +574,6 @@
%}
! !
-!Win32OperatingSystem primitiveVariables!
-%{
-static int coInitialized = 0;
-%}
-! !
-
!Win32OperatingSystem class methodsFor:'documentation'!
copyright
@@ -5091,16 +5091,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.
@@ -5115,7 +5115,7 @@
aYr aMon aDay aHr aMin aSec aMS
mYr mMon mDay mHr mMin mSec mMS
cYr cMon cDay cHr cMin cSec cMS
- fileName alternativeName path|
+ fileName alternativeName|
%{
int ret;
@@ -5125,147 +5125,146 @@
unsigned INT ino;
if (__isString(aPathName)) {
- HANDLE hFile;
- FILETIME tempFileTime;
- 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));
- }
-#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) = __mkSmallInteger(__threadErrno);
- } else {
- FindClose(hFile);
-
- id = __mkSmallInteger(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 = __mkSmallInteger(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 = __mkSmallInteger(accessTime.wYear);
- aMon = __mkSmallInteger(accessTime.wMonth);
- aDay = __mkSmallInteger(accessTime.wDay);
- aHr = __mkSmallInteger(accessTime.wHour);
- aMin = __mkSmallInteger(accessTime.wMinute);
- aSec = __mkSmallInteger(accessTime.wSecond);
- aMS = __mkSmallInteger(accessTime.wMilliseconds);
-
- mYr = __mkSmallInteger(modificationTime.wYear);
- mMon = __mkSmallInteger(modificationTime.wMonth);
- mDay = __mkSmallInteger(modificationTime.wDay);
- mHr = __mkSmallInteger(modificationTime.wHour);
- mMin = __mkSmallInteger(modificationTime.wMinute);
- mSec = __mkSmallInteger(modificationTime.wSecond);
- mMS = __mkSmallInteger(modificationTime.wMilliseconds);
-
- cYr = __mkSmallInteger(creationTime.wYear);
- cMon = __mkSmallInteger(creationTime.wMonth);
- cDay = __mkSmallInteger(creationTime.wDay);
- cHr = __mkSmallInteger(creationTime.wHour);
- cMin = __mkSmallInteger(creationTime.wMinute);
- cSec = __mkSmallInteger(creationTime.wSecond);
- cMS = __mkSmallInteger(creationTime.wMilliseconds);
- }
+ {
+ 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) = __mkSmallInteger(__threadErrno);
+ } else {
+ FindClose(hFile);
+
+ id = __mkSmallInteger(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 = __mkSmallInteger(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 = __mkSmallInteger(accessTime.wYear);
+ aMon = __mkSmallInteger(accessTime.wMonth);
+ aDay = __mkSmallInteger(accessTime.wDay);
+ aHr = __mkSmallInteger(accessTime.wHour);
+ aMin = __mkSmallInteger(accessTime.wMinute);
+ aSec = __mkSmallInteger(accessTime.wSecond);
+ aMS = __mkSmallInteger(accessTime.wMilliseconds);
+
+ mYr = __mkSmallInteger(modificationTime.wYear);
+ mMon = __mkSmallInteger(modificationTime.wMonth);
+ mDay = __mkSmallInteger(modificationTime.wDay);
+ mHr = __mkSmallInteger(modificationTime.wHour);
+ mMin = __mkSmallInteger(modificationTime.wMinute);
+ mSec = __mkSmallInteger(modificationTime.wSecond);
+ mMS = __mkSmallInteger(modificationTime.wMilliseconds);
+
+ cYr = __mkSmallInteger(creationTime.wYear);
+ cMon = __mkSmallInteger(creationTime.wMonth);
+ cDay = __mkSmallInteger(creationTime.wDay);
+ cHr = __mkSmallInteger(creationTime.wHour);
+ cMin = __mkSmallInteger(creationTime.wMinute);
+ cSec = __mkSmallInteger(creationTime.wSecond);
+ cMS = __mkSmallInteger(creationTime.wMilliseconds);
+ }
}
%}.
(aPathName endsWith:'.lnk') ifTrue:[
- type := #symbolicLink.
- path := nil.
- "/ 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
- 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:path
- 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
+ sourcePath:aPathName
+ fullName:fileName
+ alternativeName:alternativeName.
+ ^ info
].
^ nil
@@ -10634,20 +10633,13 @@
!Win32OperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
-type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP alternativeName:name2
+type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT sourcePath:lP fullName:fullName alternativeName:name2
^ self basicNew
- type:t mode:m uid:u gid:g size:s
- id:i accessed:aT modified:mT created:cT
- path:lP alternativeName:name2
-!
-
-type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP fullName:fullName alternativeName:name2
- ^ self basicNew
- type:t mode:m uid:u gid:g size:s
- id:i accessed:aT modified:mT created:cT
- path:lP
- fullName:fullName
- alternativeName:name2
+ type:t mode:m uid:u gid:g size:s
+ id:i accessed:aT modified:mT created:cT
+ sourcePath:lP
+ fullName:fullName
+ alternativeName:name2
! !
!Win32OperatingSystem::FileStatusInfo methodsFor:'accessing'!
@@ -10698,6 +10690,21 @@
^ id
!
+linkTargetPath
+ "for symbolic links only: return the path where the symbolic link points to"
+
+ "/ access lazily...
+ linkTargetPath isNil ifTrue:[
+ type == #symbolicLink ifTrue:[
+ linkTargetPath := OperatingSystem getLinkTarget:sourcePath.
+ ]
+ ].
+
+ ^ linkTargetPath
+
+ "Modified: / 07-02-2007 / 10:31:56 / cg"
+!
+
mode
"return mode"
@@ -10721,18 +10728,10 @@
!
path
- "for symbolic links only: return the path where the symbolic link points to"
-
- "/ access lazily...
- path isNil ifTrue:[
- type == #symbolicLink ifTrue:[
- path := OperatingSystem getLinkTarget:fullName.
- ]
- ].
-
- ^ path
-
- "Modified: / 07-02-2007 / 10:31:56 / cg"
+ "for symbolic links only: return the path where the symbolic link points to.
+ bad named method - left here for backward compatibility"
+
+ ^ self linkTargetPath.
!
size
@@ -10828,7 +10827,7 @@
!Win32OperatingSystem::FileStatusInfo methodsFor:'private accessing'!
-type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP alternativeName:name2
+type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT sourcePath:lP fullName:name1 alternativeName:name2
type := t.
mode := m.
uid := u.
@@ -10838,21 +10837,7 @@
accessed := aT.
modified := mT.
created := cT.
- path := lP.
- alternativeName := name2.
-!
-
-type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP fullName:name1 alternativeName:name2
- type := t.
- mode := m.
- uid := u.
- gid := g.
- size := s.
- id := i.
- accessed := aT.
- modified := mT.
- created := cT.
- path := lP.
+ sourcePath := lP.
fullName := name1.
alternativeName := name2.
! !
@@ -15661,7 +15646,7 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.350 2008-10-21 11:47:41 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.351 2008-10-21 14:08:10 ca Exp $'
! !
Win32OperatingSystem initialize!