--- a/Win32OperatingSystem.st Wed Mar 14 16:49:24 2007 +0100
+++ b/Win32OperatingSystem.st Wed Mar 14 18:39:34 2007 +0100
@@ -130,6 +130,7 @@
# define NO_GETADAPTERSINFO
#endif
+
#define USE_H_ERRNO
# if defined(i386) || defined(__i386__)
@@ -239,16 +240,22 @@
# include <string.h>
# endif
+# define STAT stat
+
# if !defined(__BORLANDC__)
-# undef stat
-# define stat _stat
-
-# undef chmod
-# define chmod _chmod
-
-# undef access
-# define access _access
-
+# if 0
+# undef stat
+# define stat _stat
+
+# undef chmod
+# define chmod _chmod
+
+# undef access
+# define access _access
+# endif
+
+# undef STAT
+# define STAT _stat32
# define MAXFILELEN 256
# endif
@@ -2964,98 +2971,98 @@
"/ command.com command-line parsing here (sigh).
hasRedirection := false.
(aCommandString isNil or:[aCommandString includesAny:'<>|']) ifTrue:[
- hasRedirection := true
+ hasRedirection := true
].
self isMSWINDOWSNTlike ifTrue:[
- hasRedirection ifFalse:[
- "/ test whether the commandString is an executable;
- "/ then, no shell is required
- cmdName := aCommandString withoutSeparators.
- (cmdName notEmpty and:[(cmdName startsWith:$") not]) ifTrue:[
- |index file suffix|
-
- index := cmdName indexOfSeparatorStartingAt:1.
- index ~~ 0 ifTrue:[
- cmdName := cmdName copyFrom:1 to:(index -1).
- ].
-
- file := cmdName asFilename.
- suffix := file suffix.
-
- suffix isEmptyOrNil ifTrue:[
- suffix := 'exe'.
- file := file withSuffix:suffix.
- ].
-
- (file exists and:[suffix = 'exe']) ifTrue:[
- "/ is an executable, no shell required
- ^ Array with:nil with:aCommandString.
- ].
- (self pathOfCommand:cmdName) notNil ifTrue:[
- "/ is an executable, no shell required
- ^ Array with:nil with:aCommandString.
- ].
- ].
- ].
- shell := self getEnvironment:'COMSPEC'.
- shell isNil ifTrue:[
- wDir := self getWindowsSystemDirectory asFilename.
- shell := (wDir construct:'cmd.exe').
- shell exists ifFalse:[
- shell := (wDir construct:'command.com').
- shell exists ifFalse:[
- self error:'no command.com available'.
- ]
- ].
- shell := shell pathName.
- ].
- aCommandString isNil ifTrue:[
- ^ Array with:nil with:shell
- ].
-
- ^ Array with:nil with:(shell , ' /c ' , '"' , aCommandString , '"' )
+ hasRedirection ifFalse:[
+ "/ test whether the commandString is an executable;
+ "/ then, no shell is required
+ cmdName := aCommandString withoutSeparators.
+ (cmdName notEmpty and:[(cmdName startsWith:$") not]) ifTrue:[
+ |index file suffix|
+
+ index := cmdName indexOfSeparatorStartingAt:1.
+ index ~~ 0 ifTrue:[
+ cmdName := cmdName copyFrom:1 to:(index -1).
+ ].
+
+ file := cmdName asFilename.
+ suffix := file suffix.
+
+ suffix isEmptyOrNil ifTrue:[
+ suffix := 'exe'.
+ file := file withSuffix:suffix.
+ ].
+
+ (file exists and:[suffix = 'exe']) ifTrue:[
+ "/ is an executable, no shell required
+ ^ Array with:nil with:aCommandString.
+ ].
+ (self pathOfCommand:cmdName) notNil ifTrue:[
+ "/ is an executable, no shell required
+ ^ Array with:nil with:aCommandString.
+ ].
+ ].
+ ].
+ shell := self getEnvironment:'COMSPEC'.
+ shell isNil ifTrue:[
+ wDir := self getWindowsSystemDirectory asFilename.
+ shell := (wDir construct:'cmd.exe').
+ shell exists ifFalse:[
+ shell := (wDir construct:'command.com').
+ shell exists ifFalse:[
+ self error:'no command.com available'.
+ ]
+ ].
+ shell := shell pathName.
+ ].
+ aCommandString isNil ifTrue:[
+ ^ Array with:nil with:shell
+ ].
+
+ ^ Array with:nil with:(shell , ' /c ' , '"' , aCommandString , '"' )
].
"/ I/O redirection is not yet handled directly
"/ fallBack to command.com (below) to do it.
hasRedirection ifFalse:[
- words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
- args := ' '.
- words from:2 to:(words size) do:[:s |
- args := args , (s , ' ').
- ].
-
- path := self pathOfCommand:(words at:1).
- path notNil ifTrue:[
- "/ execute the command directly -
- "/ without going through command.com
-
- self isMSWINDOWSNTlike ifTrue:[
- args := path , args.
- ].
-
- ^ Array with:path with:args
- ].
+ words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space.
+ args := ' '.
+ words from:2 to:(words size) do:[:s |
+ args := args , (s , ' ').
+ ].
+
+ path := self pathOfCommand:(words at:1).
+ path notNil ifTrue:[
+ "/ execute the command directly -
+ "/ without going through command.com
+
+ self isMSWINDOWSNTlike ifTrue:[
+ args := path , args.
+ ].
+
+ ^ Array with:path with:args
+ ].
].
"/ I/O redirection or no executable was found
shell := self getEnvironment:'COMSPEC'.
shell isNil ifTrue:[
- wDir := self getWindowsSystemDirectory asFilename.
- shell := (wDir construct:'cmd.exe').
- shell exists ifFalse:[
- shell := (wDir construct:'command.com').
- shell exists ifFalse:[
- self error:'no command.com available'.
- ]
- ].
- shell := shell pathName.
+ wDir := self getWindowsSystemDirectory asFilename.
+ shell := (wDir construct:'cmd.exe').
+ shell exists ifFalse:[
+ shell := (wDir construct:'command.com').
+ shell exists ifFalse:[
+ self error:'no command.com available'.
+ ]
+ ].
+ shell := shell pathName.
].
aCommandString isNil ifTrue:[
- ^ Array with:shell with:shell
+ ^ Array with:shell with:shell
].
^ Array with:shell with:(shell , ' /c ' , aCommandString)
@@ -3457,36 +3464,36 @@
aCommandString isNil ifTrue:[^ nil].
(in := anExternalInStream) isNil ifTrue:[
- nullStream := Filename nullDevice readWriteStream.
- in := nullStream.
+ nullStream := Filename nullDevice readWriteStream.
+ in := nullStream.
].
(out := anExternalOutStream) isNil ifTrue:[
- nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
- out := nullStream.
+ nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
+ out := nullStream.
].
(err := anExternalErrStream) isNil ifTrue:[
- err := out
+ err := out
].
anAuxiliaryStream notNil ifTrue:[
- auxFd := anAuxiliaryStream fileDescriptor
+ auxFd := anAuxiliaryStream fileDescriptor
].
shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
rslt := self
- exec:(shellAndArgs at:1)
- withArguments:(shellAndArgs at:2)
- environment:anEvironmentDictionary
- fileDescriptors:(Array with:in fileDescriptor
- with:out fileDescriptor
- with:err fileDescriptor
- with:auxFd)
- fork:true
- newPgrp:true "/ false
- inDirectory:dir.
+ exec:(shellAndArgs at:1)
+ withArguments:(shellAndArgs at:2)
+ environment:anEvironmentDictionary
+ fileDescriptors:(Array with:in fileDescriptor
+ with:out fileDescriptor
+ with:err fileDescriptor
+ with:auxFd)
+ fork:true
+ newPgrp:true "/ false
+ inDirectory:dir.
nullStream notNil ifTrue:[
- nullStream close.
+ nullStream close.
].
^ rslt
@@ -3509,7 +3516,7 @@
The following will no longer work. monitorPid has disappeared
pid notNil ifTrue:[
- Processor monitorPid:pid action:[:OSstatus | sema signal ].
+ Processor monitorPid:pid action:[:OSstatus | sema signal ].
].
in close.
out close.
@@ -3612,65 +3619,65 @@
IPersistFile *ppf;
if (! __isString(aPathName)) {
- console_fprintf(stderr, "invalid argument\n");
- goto error;
+ console_fprintf(stderr, "invalid argument\n");
+ goto error;
}
hres = CoInitialize(NULL);
if (! SUCCEEDED(hres)) {
- console_fprintf(stderr, "Could not open the COM library\n");
- goto error;
+ console_fprintf(stderr, "Could not open the COM library\n");
+ goto error;
}
hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
- &IID_IShellLink, (LPVOID *)&psl);
+ &IID_IShellLink, (LPVOID *)&psl);
if (SUCCEEDED(hres)) {
- hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, &ppf);
-
- if (SUCCEEDED(hres)) {
- WORD wsz[MAX_PATH];
-
- MultiByteToWideChar(CP_ACP, 0, __stringVal(aPathName), -1, wsz, MAX_PATH);
-
- hres = ppf->lpVtbl->Load(ppf, wsz, STGM_READ);
- if (SUCCEEDED(hres)) {
+ hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile, &ppf);
+
+ if (SUCCEEDED(hres)) {
+ WORD wsz[MAX_PATH];
+
+ MultiByteToWideChar(CP_ACP, 0, __stringVal(aPathName), -1, wsz, MAX_PATH);
+
+ hres = ppf->lpVtbl->Load(ppf, wsz, STGM_READ);
+ if (SUCCEEDED(hres)) {
#if 0
- hres = psl->lpVtbl->Resolve(psl, 0, SLR_ANY_MATCH|SLR_NO_UI);
-#endif
- if (SUCCEEDED(hres)) {
- hres = psl->lpVtbl->GetPath(psl, szGotPath, MAX_PATH,
- (WIN32_FIND_DATA *)&wfd, 0 /* SLGP_SHORTPATH */ );
- if (!SUCCEEDED(hres)) {
- console_fprintf(stderr, "GetPath failed!\n");
- } else {
+ hres = psl->lpVtbl->Resolve(psl, 0, SLR_ANY_MATCH|SLR_NO_UI);
+#endif
+ if (SUCCEEDED(hres)) {
+ hres = psl->lpVtbl->GetPath(psl, szGotPath, MAX_PATH,
+ (WIN32_FIND_DATA *)&wfd, 0 /* SLGP_SHORTPATH */ );
+ if (!SUCCEEDED(hres)) {
+ console_fprintf(stderr, "GetPath failed!\n");
+ } else {
#if 0
- console_printf("This points to %s\n", wfd.cFileName); console_fflush(stdout);
- console_printf("Path is %s\n", szGotPath); console_fflush(stdout);
- if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- console_printf("This is a directory\n"); console_fflush(stdout);
- }
-#endif
- resolvedPath = __MKSTRING(szGotPath);
+ console_printf("This points to %s\n", wfd.cFileName); console_fflush(stdout);
+ console_printf("Path is %s\n", szGotPath); console_fflush(stdout);
+ if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ console_printf("This is a directory\n"); console_fflush(stdout);
+ }
+#endif
+ resolvedPath = __MKSTRING(szGotPath);
#if 0
- hres = psl->lpVtbl->GetWorkingDirectory(psl, szGotPath, MAX_PATH);
- if (!SUCCEEDED(hres)) {
- console_fprintf(stderr, "GetWorkingDirectory failed!\n");
- } else {
- console_printf("In Directory %s\n", szGotPath);
- }
-#endif
- }
- }
- } else {
- console_fprintf(stderr, "IPersistFile Load Error\n");
- }
- ppf->lpVtbl->Release(ppf);
- } else {
- console_fprintf(stderr, "QueryInterface Error\n");
- }
- psl->lpVtbl->Release(psl);
+ hres = psl->lpVtbl->GetWorkingDirectory(psl, szGotPath, MAX_PATH);
+ if (!SUCCEEDED(hres)) {
+ console_fprintf(stderr, "GetWorkingDirectory failed!\n");
+ } else {
+ console_printf("In Directory %s\n", szGotPath);
+ }
+#endif
+ }
+ }
+ } else {
+ console_fprintf(stderr, "IPersistFile Load Error\n");
+ }
+ ppf->lpVtbl->Release(ppf);
+ } else {
+ console_fprintf(stderr, "QueryInterface Error\n");
+ }
+ psl->lpVtbl->Release(psl);
} else {
- console_fprintf(stderr, "CoCreateInstance Error - hres = %08x\n", hres);
+ console_fprintf(stderr, "CoCreateInstance Error - hres = %08x\n", hres);
}
error: ;
%}.
@@ -4067,7 +4074,7 @@
"
%{
- struct stat buf;
+ struct STAT buf;
int ret;
if (__isString(aPathName)) {
@@ -4078,13 +4085,13 @@
do {
__threadErrno = 0;
- ret = STX_C_CALL2( "stat", stat, _aPathName, &buf);
+ ret = STX_C_CALL2( "stat", STAT, _aPathName, &buf);
} while ((ret < 0) && (__threadErrno == EINTR));
#else
__BEGIN_INTERRUPTABLE__
do {
__threadErrno = 0;
- ret = stat( (char *)__stringVal(aPathName), &buf);
+ ret = STAT( (char *)__stringVal(aPathName), &buf);
} while ((ret < 0) && (__threadErrno == EINTR));
__END_INTERRUPTABLE__
if (ret < 0) {
@@ -4407,16 +4414,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.
@@ -4430,10 +4437,10 @@
info := self linkInfoOf:aPathName.
(info notNil and:[info isSymbolicLink]) ifTrue:[
- target := info path.
- target notNil ifTrue:[
- ^ self linkInfoOf:target.
- ]
+ target := info path.
+ target notNil ifTrue:[
+ ^ self linkInfoOf:target.
+ ]
].
^ info
@@ -4615,7 +4622,6 @@
(i.e. the file or directory exists)"
%{
- struct stat buf;
int ret;
if (__isString(aPathName) || __isSymbol(aPathName)) {
@@ -4712,16 +4718,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.
@@ -4739,7 +4745,6 @@
fileName alternativeName path|
%{
- struct stat buf;
int ret;
char alternativeFileNameBuffer[15];
char fileNameBuffer[MAX_PATH+1];
@@ -4747,147 +4752,147 @@
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.
+ path := nil.
+ "/ 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
+ path:path
+ fullName:fileName
+ alternativeName:alternativeName.
+ ^ info
].
^ nil
@@ -5127,21 +5132,21 @@
|result|
Error
- handle:[:ex |
- self halt
- ] do:[
- |filename|
-
- filename := aFilenameOrString asFilename.
- result := self
- shellExecute:nil
- lpOperation:'open'
- lpFile:filename pathName
- lpParameters:nil
- lpDirectory:filename directory pathName
- nShowCmd:#SW_SHOWNORMAL.
- ^ self.
- ]
+ handle:[:ex |
+ self halt
+ ] do:[
+ |filename|
+
+ filename := aFilenameOrString asFilename.
+ result := self
+ shellExecute:nil
+ lpOperation:'open'
+ lpFile:filename pathName
+ lpParameters:nil
+ lpDirectory:filename directory pathName
+ nShowCmd:#SW_SHOWNORMAL.
+ ^ self.
+ ]
"
self openDocumentationFilename: 'C:\WINDOWS\Help\clipbrd.chm' asFilename
@@ -7970,12 +7975,12 @@
"
HINSTANCE ShellExecute(
- HWND hwnd, // handle to parent window
- LPCTSTR lpOperation, // pointer to string that specifies operation to perform
- LPCTSTR lpFile, // pointer to filename or folder name string
- LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
- LPCTSTR lpDirectory, // pointer to string that specifies default directory
- INT nShowCmd // whether file is shown when opened
+ HWND hwnd, // handle to parent window
+ LPCTSTR lpOperation, // pointer to string that specifies operation to perform
+ LPCTSTR lpFile, // pointer to filename or folder name string
+ LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
+ LPCTSTR lpDirectory, // pointer to string that specifies default directory
+ INT nShowCmd // whether file is shown when opened
);
"
"/ <apicall: long 'ShellExecuteA' (long char* char* char* char* ulong) module:'shell32.dll'>
@@ -7983,31 +7988,31 @@
unsigned long __nShowCmd = 0;
if (__isSmallInteger(nShowCmd)) {
- __nShowCmd = __intVal(nShowCmd);
+ __nShowCmd = __intVal(nShowCmd);
} else {
- if (nShowCmd == @symbol(SW_SHOW)) {
- __nShowCmd = SW_SHOW;
- } else if (nShowCmd == @symbol(SW_SHOWNORMAL)) {
- __nShowCmd = SW_SHOWNORMAL;
- } else if (nShowCmd == @symbol(SW_SHOWDEFAULT)) {
- __nShowCmd = SW_SHOWDEFAULT;
- } else if (nShowCmd == @symbol(SW_SHOWMAXIMIZED)) {
- __nShowCmd = SW_SHOWMAXIMIZED;
- } else if (nShowCmd == @symbol(SW_SHOWMINIMIZED)) {
- __nShowCmd = SW_SHOWMINIMIZED;
- } else if (nShowCmd == @symbol(SW_SHOWMINNOACTIVE)) {
- __nShowCmd = SW_SHOWMINNOACTIVE;
- } else if (nShowCmd == @symbol(SW_SHOWNA)) {
- __nShowCmd = SW_SHOWNA;
- } else if (nShowCmd == @symbol(SW_SHOWNOACTIVATE)) {
- __nShowCmd = SW_SHOWNOACTIVATE;
- } else if (nShowCmd == @symbol(SW_MAXIMIZE)) {
- __nShowCmd = SW_MAXIMIZE;
- } else if (nShowCmd == @symbol(SW_RESTORE)) {
- __nShowCmd = SW_RESTORE;
- } else {
- goto badArgument;
- }
+ if (nShowCmd == @symbol(SW_SHOW)) {
+ __nShowCmd = SW_SHOW;
+ } else if (nShowCmd == @symbol(SW_SHOWNORMAL)) {
+ __nShowCmd = SW_SHOWNORMAL;
+ } else if (nShowCmd == @symbol(SW_SHOWDEFAULT)) {
+ __nShowCmd = SW_SHOWDEFAULT;
+ } else if (nShowCmd == @symbol(SW_SHOWMAXIMIZED)) {
+ __nShowCmd = SW_SHOWMAXIMIZED;
+ } else if (nShowCmd == @symbol(SW_SHOWMINIMIZED)) {
+ __nShowCmd = SW_SHOWMINIMIZED;
+ } else if (nShowCmd == @symbol(SW_SHOWMINNOACTIVE)) {
+ __nShowCmd = SW_SHOWMINNOACTIVE;
+ } else if (nShowCmd == @symbol(SW_SHOWNA)) {
+ __nShowCmd = SW_SHOWNA;
+ } else if (nShowCmd == @symbol(SW_SHOWNOACTIVATE)) {
+ __nShowCmd = SW_SHOWNOACTIVATE;
+ } else if (nShowCmd == @symbol(SW_MAXIMIZE)) {
+ __nShowCmd = SW_MAXIMIZE;
+ } else if (nShowCmd == @symbol(SW_RESTORE)) {
+ __nShowCmd = SW_RESTORE;
+ } else {
+ goto badArgument;
+ }
}
if (((lpOperation == nil) || __isString(lpOperation))
@@ -8015,74 +8020,74 @@
&& ((lpParameters == nil) || __isString(lpParameters))
&& ((lpDirectory == nil) || __isString(lpDirectory))
) {
- HANDLE __hwnd = 0;
- char *__lpOperation = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
- char *__lpFile = (lpFile != nil) ? __stringVal(lpFile) : NULL;
- char *__lpParameters = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
- char *__lpDirectory = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
- long result;
-
- if (hwnd != nil) {
- if (__isExternalAddressLike(hwnd)) {
- __hwnd = (HANDLE)(__externalAddressVal(hwnd));
- } else
- goto badArgument;
- }
- result = ShellExecuteA(__hwnd, __lpOperation, __lpFile, __lpParameters, __lpDirectory, __nShowCmd);
-
- /* MS programmers are brain damaged - here's the proof... */
- if (result > 32) {
- RETURN ( self ); /* OK */
- }
-
- switch (result) {
- case 0:
- case SE_ERR_OOM:
- result = ERROR_NOT_ENOUGH_MEMORY;
- break;
-
- case SE_ERR_ACCESSDENIED:
- result = ERROR_ACCESS_DENIED;
- break;
-
- case SE_ERR_FNF:
- result = ERROR_FILE_NOT_FOUND;
- break;
-
- case SE_ERR_PNF:
- result = ERROR_PATH_NOT_FOUND;
- break;
-
- default:
- result = ERROR_INVALID_FUNCTION;
- break;
- }
- errorNumber = __MKUINT( result );
+ HANDLE __hwnd = 0;
+ char *__lpOperation = (lpOperation != nil) ? __stringVal(lpOperation) : NULL;
+ char *__lpFile = (lpFile != nil) ? __stringVal(lpFile) : NULL;
+ char *__lpParameters = (lpParameters != nil) ? __stringVal(lpParameters) : NULL;
+ char *__lpDirectory = (lpDirectory != nil) ? __stringVal(lpDirectory) : NULL;
+ long result;
+
+ if (hwnd != nil) {
+ if (__isExternalAddressLike(hwnd)) {
+ __hwnd = (HANDLE)(__externalAddressVal(hwnd));
+ } else
+ goto badArgument;
+ }
+ result = ShellExecuteA(__hwnd, __lpOperation, __lpFile, __lpParameters, __lpDirectory, __nShowCmd);
+
+ /* MS programmers are brain damaged - here's the proof... */
+ if (result > 32) {
+ RETURN ( self ); /* OK */
+ }
+
+ switch (result) {
+ case 0:
+ case SE_ERR_OOM:
+ result = ERROR_NOT_ENOUGH_MEMORY;
+ break;
+
+ case SE_ERR_ACCESSDENIED:
+ result = ERROR_ACCESS_DENIED;
+ break;
+
+ case SE_ERR_FNF:
+ result = ERROR_FILE_NOT_FOUND;
+ break;
+
+ case SE_ERR_PNF:
+ result = ERROR_PATH_NOT_FOUND;
+ break;
+
+ default:
+ result = ERROR_INVALID_FUNCTION;
+ break;
+ }
+ errorNumber = __MKUINT( result );
}
badArgument: ;
%}.
errorNumber isNil ifTrue:[
- self error:'invalid argument(s)'.
+ self error:'invalid argument(s)'.
] ifFalse:[
- (OperatingSystem errorHolderForNumber:errorNumber) reportError
- ].
-
- "
- self
- shellExecute:nil
- lpOperation:'open'
- lpFile:(Filename currentDirectory pathName)
- lpParameters:nil
- lpDirectory:(Filename currentDirectory pathName)
- nShowCmd:#SW_SHOWNORMAL
-
- self
- shellExecute:nil
- lpOperation:'explore'
- lpFile:(Filename currentDirectory pathName)
- lpParameters:nil
- lpDirectory:(Filename currentDirectory pathName)
- nShowCmd:#SW_SHOWNORMAL
+ (OperatingSystem errorHolderForNumber:errorNumber) reportError
+ ].
+
+ "
+ self
+ shellExecute:nil
+ lpOperation:'open'
+ lpFile:(Filename currentDirectory pathName)
+ lpParameters:nil
+ lpDirectory:(Filename currentDirectory pathName)
+ nShowCmd:#SW_SHOWNORMAL
+
+ self
+ shellExecute:nil
+ lpOperation:'explore'
+ lpFile:(Filename currentDirectory pathName)
+ lpParameters:nil
+ lpDirectory:(Filename currentDirectory pathName)
+ nShowCmd:#SW_SHOWNORMAL
"
"Modified: / 26-01-2007 / 14:29:21 / cg"
@@ -9672,9 +9677,9 @@
"/ access lazily...
path isNil ifTrue:[
- type == #symbolicLink ifTrue:[
- path := OperatingSystem getLinkTarget:fullName.
- ]
+ type == #symbolicLink ifTrue:[
+ path := OperatingSystem getLinkTarget:fullName.
+ ]
].
^ path
@@ -12748,7 +12753,7 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.268 2007-03-14 09:19:18 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.269 2007-03-14 17:39:34 cg Exp $'
! !
Win32OperatingSystem initialize!