--- a/Win32OperatingSystem.st Wed Feb 26 01:53:38 2003 +0100
+++ b/Win32OperatingSystem.st Wed Feb 26 02:05:44 2003 +0100
@@ -2610,49 +2610,49 @@
hasRedirection := false.
(aCommandString isNil or:[aCommandString includesAny:'<>|']) ifTrue:[
- hasRedirection := true
+ hasRedirection := true
].
self isMSWINDOWSNTlike ifTrue:[
- 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)
+ 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
+ ].
].
"/ windows-NT (where command.com works)
@@ -2660,18 +2660,18 @@
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)
@@ -2683,60 +2683,60 @@
"Internal lowLevel entry for combined fork & exec for WIN32
If fork is false (chain a command):
- execute the OS command specified by the argument, aCommandPath, with
- arguments in argArray (no arguments, if nil).
- If successful, this method does not return and smalltalk is gone.
- If not successful, it does return.
- Normal use is with forkForCommand.
+ execute the OS command specified by the argument, aCommandPath, with
+ arguments in argArray (no arguments, if nil).
+ If successful, this method does not return and smalltalk is gone.
+ If not successful, it does return.
+ Normal use is with forkForCommand.
If fork is true (subprocess command execution):
- fork a child to do the above.
- The process id of the child process is returned; nil if the fork failed.
+ fork a child to do the above.
+ The process id of the child process is returned; nil if the fork failed.
fdArray contains the filedescriptors, to be used for the child (if fork is true).
- fdArray[1] = 15 -> use fd 15 as stdin.
- If an element of the array is set to nil, the corresponding filedescriptor
- will be closed for the child.
- fdArray[0] == StdIn for child
- fdArray[1] == StdOut for child
- fdArray[2] == StdErr for child
- on VMS, these must be channels as returned by createMailBox.
+ fdArray[1] = 15 -> use fd 15 as stdin.
+ If an element of the array is set to nil, the corresponding filedescriptor
+ will be closed for the child.
+ fdArray[0] == StdIn for child
+ fdArray[1] == StdOut for child
+ fdArray[2] == StdErr for child
+ on VMS, these must be channels as returned by createMailBox.
closeFdArray contains descriptors that will be closed in the subprocess.
- closeDescriptors are ignored in the WIN32 & VMS versions.
+ closeDescriptors are ignored in the WIN32 & VMS versions.
NOTE that in WIN32 the fds are HANDLES.
If newPgrp is true, the subprocess will be established in a new process group.
- The processgroup will be equal to id.
- newPgrp is not used on WIN32 and VMS systems."
+ The processgroup will be equal to id.
+ newPgrp is not used on WIN32 and VMS systems."
|dirPath cmdPath cmdLine|
aDirectory notNil ifTrue:[
- dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory.
- (dirPath endsWith:':') ifTrue:[
- dirPath := dirPath , '\'.
- ].
+ dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory.
+ (dirPath endsWith:':') ifTrue:[
+ dirPath := dirPath , '\'.
+ ].
].
self isMSWINDOWSNTlike ifTrue:[
- cmdPath := aCommandPath.
- cmdLine := argString
+ cmdPath := aCommandPath.
+ cmdLine := argString
] ifFalse:[
- cmdPath := 'stxspawn.exe'.
- cmdLine := 'stxspawn.exe ' , aCommandPath , ' ' , argString
+ cmdPath := 'stxspawn.exe'.
+ cmdLine := 'stxspawn.exe ' , aCommandPath , ' ' , argString
].
^ self
- primExec:cmdPath
- commandLine:cmdLine
- fileDescriptors:fdArray
- closeDescriptors:closeFdArray
- fork:doFork
- newPgrp:newPgrp
- inPath:dirPath
- createFlags:nil
+ primExec:cmdPath
+ commandLine:cmdLine
+ fileDescriptors:fdArray
+ closeDescriptors:closeFdArray
+ fork:doFork
+ newPgrp:newPgrp
+ inPath:dirPath
+ createFlags:nil
"Modified: / 31.1.1998 / 10:54:24 / md"
"Modified: / 15.5.1999 / 18:07:51 / cg"
@@ -2844,172 +2844,175 @@
DWORD fdwCreate = 0;
STARTUPINFO lpsiStartInfo;
PROCESS_INFORMATION lppiProcInfo;
- SECURITY_ATTRIBUTES process;
+ SECURITY_ATTRIBUTES sa;
if (__isString(dirName)) {
- dir = __stringVal(dirName);
+ dir = __stringVal(dirName);
}
if ((__isString(commandPath) || (commandPath == nil))
&& __isString(commandLine)) {
#if 0
- /*
- * generate command line (cmd plus args)
- */
- if (__isWinNT) {
- char *d;
-
- strcpy(fullCmdPath, __stringVal(aCommandPath));
- d = strchr(fullCmdPath,' ');
- if (d) {
- *d++ = 0;
- strcpy(fullCmdLine, d);
- } else {
- fullCmdLine[0] = '\0';
- }
- } else {
- //fullCmdPath = 0;
- strcpy(fullCmdPath,"stxspawn.exe");
- strcpy(fullCmdLine,"stxspawn.exe ");
- strcat(fullCmdLine, __stringVal(aCommandPath));
- }
-
- if (__isString(argArray)) {
- if (strlen(fullCmdLine) > 0) {
- strcat(fullCmdLine, " ");
- }
- strcat(fullCmdLine, __stringVal(argArray));
- } else {
- int i;
-
- for (i=0; i<__arraySize(argArray); i++) {
- OBJ arg = __ArrayInstPtr(argArray)->a_element[i];
-
- if (__isString(arg)) {
- strcat(fullCmdLine, " ");
- strcat(fullCmdLine, __stringVal(arg));
- } else {
- /* ignore */
- fprintf(stderr, "bad (non-string) arg\n");
- }
- }
- }
-#endif
- if (commandPath != nil) {
- cmdPath = __stringVal(commandPath);
- }
- cmdLine = __stringVal(commandLine);
-
- /*
- * create descriptors as req'd
- */
- process.nLength = sizeof( process );
- process.lpSecurityDescriptor = NULL;
- process.bInheritHandle = TRUE;
-
- lpsiStartInfo.cb = sizeof(PROCESS_INFORMATION);
- lpsiStartInfo.lpReserved = NULL;
- lpsiStartInfo.lpDesktop = NULL;
- lpsiStartInfo.lpTitle = NULL;
- lpsiStartInfo.dwX = 0;
- lpsiStartInfo.dwY = 0;
- lpsiStartInfo.dwXSize = 100;
- lpsiStartInfo.dwYSize = 100;
- lpsiStartInfo.dwXCountChars = 0;
- lpsiStartInfo.dwYCountChars = 0;
- lpsiStartInfo.dwFillAttribute = 0;
- if (0/*__isWinNT*/) {
- lpsiStartInfo.dwFlags = STARTF_USESTDHANDLES;
- lpsiStartInfo.wShowWindow = SW_SHOWDEFAULT;
- } else {
- lpsiStartInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/;
- lpsiStartInfo.wShowWindow = SW_HIDE /*SW_SHOWDEFAULT*/;
- }
- lpsiStartInfo.cbReserved2 = 0;
- lpsiStartInfo.lpReserved2 = NULL;
- lpsiStartInfo.hStdInput = NULL;
- lpsiStartInfo.hStdOutput = NULL;
- lpsiStartInfo.hStdError = NULL;
-
- /*
- * set create process flags
- * if the flags arg is nil, use common defaults;
- * if non-nil, it must be a positive integer containing the fdwCreate bits.
- */
- if (flagsOrNil != nil) {
- fdwCreate = __longIntVal(flagsOrNil);
- } else {
- if (__isWinNT)
- fdwCreate = 0; //IDLE_PRIORITY_CLASS;
- else
- fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ;
-
- if (newPgrp == true) {
- fdwCreate |= CREATE_NEW_PROCESS_GROUP;
- }
- }
-
- if (fdArray == nil) {
- lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (0);
- lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (1);
- lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (2);
- } else if (__isArray(fdArray) && (__arraySize(fdArray) == 3)) {
- if (__ArrayInstPtr(fdArray)->a_element[0] != nil) {
- if (__isExternalAddress(__ArrayInstPtr(fdArray)->a_element[0])) {
- lpsiStartInfo.hStdInput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]);
- } else {
- lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0]));
- }
- }
- if (__ArrayInstPtr(fdArray)->a_element[1] != nil) {
- if (__isExternalAddress(__ArrayInstPtr(fdArray)->a_element[1])) {
- lpsiStartInfo.hStdOutput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]);
- } else {
- lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1]));
- }
- }
- if (__ArrayInstPtr(fdArray)->a_element[2] != nil) {
- if (__isExternalAddress(__ArrayInstPtr(fdArray)->a_element[2])) {
- lpsiStartInfo.hStdError = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]);
- } else {
- lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2]));
- }
- }
+ /*
+ * generate command line (cmd plus args)
+ */
+ if (__isWinNT) {
+ char *d;
+
+ strcpy(fullCmdPath, __stringVal(aCommandPath));
+ d = strchr(fullCmdPath,' ');
+ if (d) {
+ *d++ = 0;
+ strcpy(fullCmdLine, d);
+ } else {
+ fullCmdLine[0] = '\0';
+ }
+ } else {
+ //fullCmdPath = 0;
+ strcpy(fullCmdPath,"stxspawn.exe");
+ strcpy(fullCmdLine,"stxspawn.exe ");
+ strcat(fullCmdLine, __stringVal(aCommandPath));
+ }
+
+ if (__isString(argArray)) {
+ if (strlen(fullCmdLine) > 0) {
+ strcat(fullCmdLine, " ");
+ }
+ strcat(fullCmdLine, __stringVal(argArray));
+ } else {
+ int i;
+
+ for (i=0; i<__arraySize(argArray); i++) {
+ OBJ arg = __ArrayInstPtr(argArray)->a_element[i];
+
+ if (__isString(arg)) {
+ strcat(fullCmdLine, " ");
+ strcat(fullCmdLine, __stringVal(arg));
+ } else {
+ /* ignore */
+ fprintf(stderr, "bad (non-string) arg\n");
+ }
+ }
+ }
+#endif
+ if (commandPath != nil) {
+ cmdPath = __stringVal(commandPath);
+ }
+ cmdLine = __stringVal(commandLine);
+
+ /*
+ * create descriptors as req'd
+ */
+ sa.nLength = sizeof( sa );
+ sa.lpSecurityDescriptor = NULL;
+ sa.bInheritHandle = TRUE;
+
+ memset(&lppiProcInfo, 0, sizeof (lppiProcInfo));
+
+ memset(&lpsiStartInfo, 0, sizeof (lpsiStartInfo));
+ lpsiStartInfo.cb = sizeof(lpsiStartInfo);
+ lpsiStartInfo.lpReserved = NULL;
+ lpsiStartInfo.lpDesktop = NULL;
+ lpsiStartInfo.lpTitle = NULL;
+ lpsiStartInfo.dwX = 0;
+ lpsiStartInfo.dwY = 0;
+ lpsiStartInfo.dwXSize = 100;
+ lpsiStartInfo.dwYSize = 100;
+ lpsiStartInfo.dwXCountChars = 0;
+ lpsiStartInfo.dwYCountChars = 0;
+ lpsiStartInfo.dwFillAttribute = 0;
+ if (0 /*__isWinNT*/) {
+ lpsiStartInfo.dwFlags = STARTF_USESTDHANDLES;
+ lpsiStartInfo.wShowWindow = SW_SHOWDEFAULT;
+ } else {
+ lpsiStartInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/;
+ lpsiStartInfo.wShowWindow = SW_HIDE /*SW_SHOWDEFAULT*/;
+ }
+ lpsiStartInfo.cbReserved2 = 0;
+ lpsiStartInfo.lpReserved2 = NULL;
+ lpsiStartInfo.hStdInput = NULL;
+ lpsiStartInfo.hStdOutput = NULL;
+ lpsiStartInfo.hStdError = NULL;
+
+ /*
+ * set create process flags
+ * if the flags arg is nil, use common defaults;
+ * if non-nil, it must be a positive integer containing the fdwCreate bits.
+ */
+ if (flagsOrNil != nil) {
+ fdwCreate = __longIntVal(flagsOrNil);
+ } else {
+ if (0 /* __isWinNT */)
+ fdwCreate = 0; //IDLE_PRIORITY_CLASS;
+ else
+ fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ;
+
+ if (newPgrp == true) {
+ fdwCreate |= CREATE_NEW_PROCESS_GROUP;
+ }
+ }
+
+ if (fdArray == nil) {
+ lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (0);
+ lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (1);
+ lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (2);
+ } else if (__isArray(fdArray) && (__arraySize(fdArray) >= 3)) {
+ if (__ArrayInstPtr(fdArray)->a_element[0] != nil) {
+ if (__isExternalAddress(__ArrayInstPtr(fdArray)->a_element[0])) {
+ lpsiStartInfo.hStdInput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]);
+ } else {
+ lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0]));
+ }
+ }
+ if (__ArrayInstPtr(fdArray)->a_element[1] != nil) {
+ if (__isExternalAddress(__ArrayInstPtr(fdArray)->a_element[1])) {
+ lpsiStartInfo.hStdOutput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]);
+ } else {
+ lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1]));
+ }
+ }
+ if (__ArrayInstPtr(fdArray)->a_element[2] != nil) {
+ if (__isExternalAddress(__ArrayInstPtr(fdArray)->a_element[2])) {
+ lpsiStartInfo.hStdError = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]);
+ } else {
+ lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2]));
+ }
+ }
#ifdef PROCESSDEBUGWIN32
- fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput);
- fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput);
- fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError);
-#endif
- } else {
- fprintf(stderr, "Win32OS: bad fd arg in createProcess\n");
- }
-
- if (doFork == true) {
+ fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput);
+ fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput);
+ fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError);
+#endif
+ } else {
+ fprintf(stderr, "Win32OS: bad fd arg in createProcess\n");
+ }
+
+ if (doFork == true) {
#ifdef PROCESSDEBUGWIN32
- fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir);
-#endif
- if (CreateProcess( cmdPath,
- cmdLine,
- &process, &process, /* sec-attribs */
- TRUE, /* inherit handles */
- fdwCreate,
- NULL, /* env */
- dir,
- &lpsiStartInfo,
- &lppiProcInfo ))
- {
- CloseHandle(lppiProcInfo.hThread);
+ fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir);
+#endif
+ if (CreateProcess( cmdPath,
+ cmdLine,
+ &sa, &sa, /* sec-attribs */
+ sa.bInheritHandle, /* inherit handles */
+ fdwCreate,
+ NULL, /* env */
+ dir,
+ &lpsiStartInfo,
+ &lppiProcInfo ))
+ {
+ CloseHandle(lppiProcInfo.hThread);
#ifdef PROCESSDEBUGWIN32
- fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess);
-#endif
- RETURN (__MKEXTERNALADDRESS(lppiProcInfo.hProcess));
- }
+ fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess);
+#endif
+ RETURN (__MKEXTERNALADDRESS(lppiProcInfo.hProcess));
+ }
#ifdef PROCESSDEBUGWIN32
- fprintf(stderr, "created process error %d\n", GetLastError());
-#endif
- RETURN (nil);
- } else {
- ; /* should never be called that way */
- }
+ fprintf(stderr, "created process error %d\n", GetLastError());
+#endif
+ RETURN (nil);
+ } else {
+ ; /* should never be called that way */
+ }
}
%}.
"
@@ -3037,55 +3040,55 @@
aCommandString isNil ifTrue:[^ nil].
anExternalInStream notNil ifTrue:[
- in := anExternalInStream fileDescriptor.
+ in := anExternalInStream fileDescriptor.
] ifFalse:[
- self isMSWINDOWSNTlike ifTrue:[
- inStream := 'nul' asFilename readStream.
- inStream notNil ifTrue:[
- in := inStream fileDescriptor.
- ]
- ]
+ self isMSWINDOWSNTlike ifTrue:[
+ inStream := 'nul' asFilename readStream.
+ inStream notNil ifTrue:[
+ in := inStream fileDescriptor.
+ ]
+ ]
].
anExternalOutStream notNil ifTrue:[
- out := anExternalOutStream fileDescriptor.
+ out := anExternalOutStream fileDescriptor.
] ifFalse:[
- self isMSWINDOWSNTlike ifTrue:[
- outStream := 'nul' asFilename writeStream.
- outStream notNil ifTrue:[
- out := outStream fileDescriptor.
- ]
- ]
+ self isMSWINDOWSNTlike ifTrue:[
+ outStream := 'nul' asFilename writeStream.
+ outStream notNil ifTrue:[
+ out := outStream fileDescriptor.
+ ]
+ ]
].
anExternalErrStream notNil ifTrue:[
- err := anExternalErrStream fileDescriptor.
+ err := anExternalErrStream fileDescriptor.
] ifFalse:[
- self isMSWINDOWSNTlike ifTrue:[
- errStream := 'nul' asFilename writeStream.
- errStream notNil ifTrue:[
- err := errStream fileDescriptor.
- ]
- ]
+ self isMSWINDOWSNTlike ifTrue:[
+ errStream := 'nul' asFilename writeStream.
+ errStream notNil ifTrue:[
+ err := errStream fileDescriptor.
+ ]
+ ]
].
shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
ret := self
- exec:(shellAndArgs at:1)
- withArguments:(shellAndArgs at:2)
- environment:nil
- fileDescriptors:(Array with:in with:out with:err)
- closeDescriptors:nil
- fork:true
- newPgrp:false
- inDirectory:dirOrNil.
+ exec:(shellAndArgs at:1)
+ withArguments:(shellAndArgs at:2)
+ environment:nil
+ fileDescriptors:(Array with:in with:out with:err)
+ closeDescriptors:nil
+ fork:true
+ newPgrp:false
+ inDirectory:dirOrNil.
inStream notNil ifTrue:[
- inStream close
+ inStream close
].
outStream notNil ifTrue:[
- outStream close
+ outStream close
].
errStream notNil ifTrue:[
- errStream close
+ errStream close
].
^ ret
@@ -3816,16 +3819,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.
@@ -3851,136 +3854,136 @@
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);
- } 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
+ */
+ 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.
- ].
+ (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 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
- created:ctime
- path:nil
- fullName:fileName
- alternativeName:alternativeName.
- ^ 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
+ created:ctime
+ path:nil
+ fullName:fileName
+ alternativeName:alternativeName.
+ ^ info
].
^ nil
@@ -4313,7 +4316,7 @@
For nonexistent files, nil is returned."
"could be implemented as:
- (self infoOf:aPathName) accessed
+ (self infoOf:aPathName) accessed
"
| i|
@@ -4331,7 +4334,7 @@
For nonexistent files, nil is returned."
"could be implemented as:
- (self infoOf:aPathName) modified
+ (self infoOf:aPathName) modified
"
| i|
@@ -4804,15 +4807,15 @@
"terminate a process.
The process has a chance to do some cleanup.
WIN32:
- Under unix, we have terminateProcess, which does a soft
- terminate (giving the process a chance to cleanup) and
- killProcess, which does a hard terminate.
- Under WIN32, both (currently) use the TerminateProcess
- function, which unconditionally causes a process to exit.
- I.e. under WIN32, the process has no chance to perform cleanup.
- Use it only in extreme circumstances. The state of
- global data maintained by dynamic-link libraries (DLLs)
- may be compromised if TerminateProcess is used.
+ Under unix, we have terminateProcess, which does a soft
+ terminate (giving the process a chance to cleanup) and
+ killProcess, which does a hard terminate.
+ Under WIN32, both (currently) use the TerminateProcess
+ function, which unconditionally causes a process to exit.
+ I.e. under WIN32, the process has no chance to perform cleanup.
+ Use it only in extreme circumstances. The state of
+ global data maintained by dynamic-link libraries (DLLs)
+ may be compromised if TerminateProcess is used.
TODO: send it a WM_QUIT instead, to allow for proper shutdown."
self terminateProcess:processId exitCode:0
@@ -4822,33 +4825,33 @@
"terminate a process.
The process has a chance to do some cleanup.
WIN32:
- Under unix, we have terminateProcess, which does a soft
- terminate (giving the process a chance to cleanup) and
- killProcess, which does a hard terminate.
- Under WIN32, both (currently) use the TerminateProcess
- function, which unconditionally causes a process to exit.
- I.e. under WIN32, the process has no chance to perform cleanup.
- Use it only in extreme circumstances. The state of
- global data maintained by dynamic-link libraries (DLLs)
- may be compromised if TerminateProcess is used.
+ Under unix, we have terminateProcess, which does a soft
+ terminate (giving the process a chance to cleanup) and
+ killProcess, which does a hard terminate.
+ Under WIN32, both (currently) use the TerminateProcess
+ function, which unconditionally causes a process to exit.
+ I.e. under WIN32, the process has no chance to perform cleanup.
+ Use it only in extreme circumstances. The state of
+ global data maintained by dynamic-link libraries (DLLs)
+ may be compromised if TerminateProcess is used.
TODO: send it a WM_QUIT instead, to allow for proper shutdown."
%{
if (__isExternalAddress(processId) ) {
- HANDLE __pid = _HANDLEVal(processId);
+ HANDLE __pid = _HANDLEVal(processId);
#ifdef PROCESS1DEBUGWIN32
- printf("Terminate ProcessHandle %x\n", __pid);
-#endif
- if (__pid != 0) {
- TerminateProcess(__pid, __intVal(exitCode));
- CloseHandle(__pid);
- _HANDLEVal(processId) = 0;
- }
+ printf("Terminate ProcessHandle %x\n", __pid);
+#endif
+ if (__pid != 0) {
+ TerminateProcess(__pid, __intVal(exitCode));
+ CloseHandle(__pid);
+ _HANDLEVal(processId) = 0;
+ }
}
#ifdef PROCESS1DEBUGWIN32
else {
- printf("Terminate wrong ProcessHandle\n");
+ printf("Terminate wrong ProcessHandle\n");
}
#endif
%}
@@ -5487,25 +5490,25 @@
This method is mainly provided to augment error reports with some system
information.
(in case of system/version specific OS errors, conditional workarounds and patches
- may be based upon this info).
+ may be based upon this info).
Your application should NOT depend upon this in any way.
The returned info may (or may not) contain:
- #system -> some operating system identification (irix, Linux, nt, win32s ...)
- #version -> OS version (some os version identification)
- #release -> OS release (3.5, 1.2.1 ...)
- #node -> some host identification (hostname)
- #domain -> domain name (hosts domain)
- #machine -> type of machine (i586, mips ...)
+ #system -> some operating system identification (irix, Linux, nt, win32s ...)
+ #version -> OS version (some os version identification)
+ #release -> OS release (3.5, 1.2.1 ...)
+ #node -> some host identification (hostname)
+ #domain -> domain name (hosts domain)
+ #machine -> type of machine (i586, mips ...)
win32:
- #physicalRam -> total amount of physical memory
- #freeRam -> amount of free memory
- #swapSize -> size of swapSpace (page file)
- #freeSwap -> free bytes in swapSpace
- #virtualRam -> total amount of virtual memory
- #freeVirtual -> amount of free virtual memory
- #memoryLoad -> percentage of memory usage (useless)
+ #physicalRam -> total amount of physical memory
+ #freeRam -> amount of free memory
+ #swapSize -> size of swapSpace (page file)
+ #freeSwap -> free bytes in swapSpace
+ #virtualRam -> total amount of virtual memory
+ #freeVirtual -> amount of free virtual memory
+ #memoryLoad -> percentage of memory usage (useless)
"
|sys node rel ver mach dom info arch
@@ -5527,14 +5530,14 @@
verMajor = LOBYTE(winVer);
if (HIWORD(vsn) & 0x8000) {
- s = "win95";
+ s = "win95";
} else {
- if ((verMajor > 5)
- || ((verMajor == 5) && (verMinor >= 1))) {
- s = "xp";
- } else {
- s = "nt";
- }
+ if ((verMajor > 5)
+ || ((verMajor == 5) && (verMinor >= 1))) {
+ s = "xp";
+ } else {
+ s = "nt";
+ }
}
sys = __MKSTRING(s);
sprintf(vsnBuffer, "%d.%d", verMajor, verMinor);
@@ -5561,103 +5564,103 @@
#endif
{
#ifdef PROCESSOR_ARCHITECTURE_INTEL
- case PROCESSOR_ARCHITECTURE_INTEL:
- s = "intel";
- break;
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ s = "intel";
+ break;
#endif
#ifdef PROCESSOR_ARCHITECTURE_MIPS
- case PROCESSOR_ARCHITECTURE_MIPS:
- s = "mips";
- break;
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ s = "mips";
+ break;
#endif
#ifdef PROCESSOR_ARCHITECTURE_ALPHA
- case PROCESSOR_ARCHITECTURE_ALPHA:
- s = "alpha";
- break;
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ s = "alpha";
+ break;
#endif
#ifdef PROCESSOR_ARCHITECTURE_PPC
- case PROCESSOR_ARCHITECTURE_PPC:
- s = "ppc";
- break;
+ case PROCESSOR_ARCHITECTURE_PPC:
+ s = "ppc";
+ break;
#endif
#ifdef PROCESSOR_ARCHITECTURE_ARM
- case PROCESSOR_ARCHITECTURE_ARM:
- s = "arm";
- break;
-#endif
- default:
- s = "unknown";
- break;
+ case PROCESSOR_ARCHITECTURE_ARM:
+ s = "arm";
+ break;
+#endif
+ default:
+ s = "unknown";
+ break;
}
arch = __MKSTRING(s);
switch (sysInfo.dwProcessorType) {
#ifdef PROCESSOR_INTEL_386
- case PROCESSOR_INTEL_386:
- s = "i386";
- break;
+ case PROCESSOR_INTEL_386:
+ s = "i386";
+ break;
#endif
#ifdef PROCESSOR_INTEL_486
- case PROCESSOR_INTEL_486:
- s = "i486";
- break;
+ case PROCESSOR_INTEL_486:
+ s = "i486";
+ break;
#endif
#ifdef PROCESSOR_INTEL_PENTIUM
- case PROCESSOR_INTEL_PENTIUM:
- s = "i586";
- break;
+ case PROCESSOR_INTEL_PENTIUM:
+ s = "i586";
+ break;
#endif
#ifdef PROCESSOR_INTEL_860
- case PROCESSOR_INTEL_860:
- s = "i860";
- break;
+ case PROCESSOR_INTEL_860:
+ s = "i860";
+ break;
#endif
#ifdef PROCESSOR_MIPS_R2000
- case PROCESSOR_MIPS_R2000:
- s = "r2000";
- break;
+ case PROCESSOR_MIPS_R2000:
+ s = "r2000";
+ break;
#endif
#ifdef PROCESSOR_MIPS_R3000
- case PROCESSOR_MIPS_R3000:
- s = "r3000";
- break;
+ case PROCESSOR_MIPS_R3000:
+ s = "r3000";
+ break;
#endif
#ifdef PROCESSOR_MIPS_R4000
- case PROCESSOR_MIPS_R4000:
- s = "r4000";
- break;
+ case PROCESSOR_MIPS_R4000:
+ s = "r4000";
+ break;
#endif
#ifdef PROCESSOR_ALPHA_21064
- case PROCESSOR_ALPHA_21064:
- s = "alpha21064";
- break;
+ case PROCESSOR_ALPHA_21064:
+ s = "alpha21064";
+ break;
#endif
#ifdef PROCESSOR_ARM_7TDMI
- case PROCESSOR_ARM_7TDMI:
- s = "arm70001";
- break;
-#endif
- default:
- sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
- s = vsnBuffer;
- break;
+ case PROCESSOR_ARM_7TDMI:
+ s = "arm70001";
+ break;
+#endif
+ default:
+ sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType);
+ s = vsnBuffer;
+ break;
}
mach = __MKSTRING(s);
%}.
sys isNil ifTrue:[
- sys := self getSystemType.
+ sys := self getSystemType.
].
node isNil ifTrue:[
- node := self getHostName.
+ node := self getHostName.
].
dom isNil ifTrue:[
- dom := self getDomainName.
+ dom := self getDomainName.
].
mach isNil ifTrue:[
- mach := self getCPUType.
+ mach := self getCPUType.
].
arch isNil ifTrue:[
- arch := 'unknown'.
+ arch := 'unknown'.
].
info := IdentityDictionary new.
@@ -7373,18 +7376,18 @@
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP 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 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
+ path:lP
+ fullName:fullName
+ alternativeName:name2
! !
!Win32OperatingSystem::FileStatusInfo methodsFor:'accessing'!
@@ -8753,7 +8756,7 @@
!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.120 2003-02-25 22:33:26 penk Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.121 2003-02-26 01:05:44 penk Exp $'
! !
!Win32OperatingSystem::Win32FILEHandle methodsFor:'release'!
@@ -8780,7 +8783,7 @@
!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.120 2003-02-25 22:33:26 penk Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.121 2003-02-26 01:05:44 penk Exp $'
! !
!Win32OperatingSystem::Win32Handle methodsFor:'io'!
@@ -9167,7 +9170,7 @@
!Win32OperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.120 2003-02-25 22:33:26 penk Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.121 2003-02-26 01:05:44 penk Exp $'
! !
Win32OperatingSystem initialize!