author | Claus Gittinger <cg@exept.de> |
Mon, 02 Feb 2004 17:24:45 +0100 | |
changeset 7865 | 67ea99d5edcc |
parent 7860 | d08a47772aa1 |
child 8078 | dc95f02fa4c5 |
permissions | -rw-r--r-- |
5133 | 1 |
" |
2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
3 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4 |
All Rights Reserved |
5133 | 5 |
|
6 |
This software is furnished under a license and may be used |
|
7 |
only in accordance with the terms of that license and with the |
|
8 |
inclusion of the above copyright notice. This software may not |
|
9 |
be provided or otherwise made available to, or used by, any |
|
10 |
other person. No title to or ownership of the software is |
|
11 |
hereby transferred. |
|
12 |
" |
|
13 |
||
6275 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
5133 | 16 |
AbstractOperatingSystem subclass:#Win32OperatingSystem |
7158 | 17 |
instanceVariableNames:'' |
18 |
classVariableNames:'HostName DomainName CurrentDirectory' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'OS-Windows' |
|
5133 | 21 |
! |
22 |
||
6275 | 23 |
Object subclass:#FileStatusInfo |
7158 | 24 |
instanceVariableNames:'type mode uid gid size id accessed modified created statusChanged |
25 |
path fullName alternativeName' |
|
26 |
classVariableNames:'' |
|
27 |
poolDictionaries:'' |
|
28 |
privateIn:Win32OperatingSystem |
|
5133 | 29 |
! |
30 |
||
31 |
Object subclass:#OSProcessStatus |
|
7158 | 32 |
instanceVariableNames:'pid status code core' |
33 |
classVariableNames:'' |
|
34 |
poolDictionaries:'' |
|
35 |
privateIn:Win32OperatingSystem |
|
5133 | 36 |
! |
37 |
||
6275 | 38 |
Object subclass:#RegistryEntry |
7158 | 39 |
instanceVariableNames:'path handle' |
40 |
classVariableNames:'Lobby HKEY_CLASSES_ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE |
|
41 |
HKEY_USERS HKEY_PERFORMANCE_DATA HKEY_CURRENT_CONFIG |
|
42 |
HKEY_DYN_DATA' |
|
43 |
poolDictionaries:'' |
|
44 |
privateIn:Win32OperatingSystem |
|
5133 | 45 |
! |
46 |
||
6293 | 47 |
OSFileHandle subclass:#Win32FILEHandle |
7158 | 48 |
instanceVariableNames:'' |
49 |
classVariableNames:'' |
|
50 |
poolDictionaries:'' |
|
51 |
privateIn:Win32OperatingSystem |
|
6293 | 52 |
! |
53 |
||
54 |
OSFileHandle subclass:#Win32Handle |
|
7158 | 55 |
instanceVariableNames:'' |
56 |
classVariableNames:'' |
|
57 |
poolDictionaries:'' |
|
58 |
privateIn:Win32OperatingSystem |
|
6293 | 59 |
! |
60 |
||
7749 | 61 |
Win32OperatingSystem::Win32Handle subclass:#Win32ProcessHandle |
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
62 |
instanceVariableNames:'' |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
63 |
classVariableNames:'' |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
64 |
poolDictionaries:'' |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
65 |
privateIn:Win32OperatingSystem |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
66 |
! |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
67 |
|
5133 | 68 |
!Win32OperatingSystem primitiveDefinitions! |
69 |
%{ |
|
70 |
||
7852 | 71 |
/* |
72 |
* if DO_WRAP_CALLS is not defined, API-calls are performed directly |
|
73 |
* if it is, they are performed by another thread. |
|
74 |
* The system does not work correctly without wrapCalls. |
|
75 |
*/ |
|
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
76 |
# ifndef DO_WRAP_CALLS |
7852 | 77 |
# define STX_C_CALL0(__nm__, __f__) __f__( ) |
78 |
# define STX_C_CALL1(__nm__, __f__, __a1__) __f__((__a1__)) |
|
79 |
# define STX_C_CALL2(__nm__, __f__, __a1__, __a2__) __f__((__a1__), (__a2__)) |
|
80 |
# define STX_C_CALL3(__nm__, __f__, __a1__, __a2__, __a3__) __f__((__a1__), (__a2__), (__a3__)) |
|
81 |
# define STX_API_CALL0(__nm__, __f__) __f__( ) |
|
82 |
# define STX_API_CALL1(__nm__, __f__, __a1__) __f__((__a1__)) |
|
83 |
# define STX_API_CALL2(__nm__, __f__, __a1__, __a2__) __f__((__a1__), (__a2__)) |
|
84 |
# define STX_API_CALL3(__nm__, __f__, __a1__, __a2__, __a3__) __f__((__a1__), (__a2__), (__a3__)) |
|
85 |
# define STX_API_CALL4(__nm__, __f__, __a1__, __a2__, __a3__, __a4__) __f__((__a1__), (__a2__), (__a3__), (__a4__)) |
|
86 |
# define STX_API_CALL5(__nm__, __f__, __a1__, __a2__, __a3__, __a4__, __a5__) __f__((__a1__), (__a2__), (__a3__), (__a4__), (__a5__)) |
|
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
87 |
# else |
7852 | 88 |
# define STX_C_CALL0(__nm__, __f__) __STX_C_CALL0(__nm__, (void*)__f__) |
89 |
# define STX_C_CALL1(__nm__, __f__, __a1__) __STX_C_CALL1(__nm__, (void*)__f__, (void*)(__a1__)) |
|
90 |
# define STX_C_CALL2(__nm__, __f__, __a1__, __a2__) __STX_C_CALL2(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__)) |
|
91 |
# define STX_C_CALL3(__nm__, __f__, __a1__, __a2__, __a3__) __STX_C_CALL3(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__), (void*)(__a3__)) |
|
92 |
# define STX_API_CALL0(__nm__, __f__) __STX_API_CALL0(__nm__, (void*)__f__) |
|
93 |
# define STX_API_CALL1(__nm__, __f__, __a1__) __STX_API_CALL1(__nm__, (void*)__f__, (void*)(__a1__)) |
|
94 |
# define STX_API_CALL2(__nm__, __f__, __a1__, __a2__) __STX_API_CALL2(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__)) |
|
95 |
# define STX_API_CALL3(__nm__, __f__, __a1__, __a2__, __a3__) __STX_API_CALL3(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__), (void*)(__a3__)) |
|
96 |
# define STX_API_CALL4(__nm__, __f__, __a1__, __a2__, __a3__, __a4__) __STX_API_CALL4(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__), (void*)(__a3__), (void*)(__a4__)) |
|
97 |
# define STX_API_CALL5(__nm__, __f__, __a1__, __a2__, __a3__, __a4__, __a5__) __STX_API_CALL5(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__), (void*)(__a3__), (void*)(__a4__), (void*)(__a5__)) |
|
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
98 |
# endif |
5133 | 99 |
|
7852 | 100 |
# ifndef MSDOS_LIKE /* windows is not a real operating system */ |
5133 | 101 |
# define MSDOS_LIKE |
102 |
# endif |
|
7852 | 103 |
# undef UNIX_LIKE |
6095 | 104 |
|
5133 | 105 |
# ifdef i386 |
106 |
# ifndef _X86_ |
|
107 |
# define _X86_ |
|
108 |
# endif |
|
109 |
# endif |
|
110 |
||
111 |
/* |
|
112 |
* notice: although many systems' include files |
|
113 |
* already block against multiple inclusion, some |
|
114 |
* do not. Therefore, this is done here again. |
|
115 |
* (it does not hurt) |
|
116 |
*/ |
|
117 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
118 |
# include <signal.h> |
|
119 |
# define _SIGNAL_H_INCLUDED_ |
|
120 |
# endif |
|
121 |
||
122 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
123 |
# include <sys/types.h> |
|
124 |
# define _SYS_TYPES_H_INCLUDED_ |
|
125 |
# endif |
|
126 |
||
127 |
# ifndef _TIME_H_INCLUDED_ |
|
128 |
# include <time.h> |
|
129 |
# define _TIME_H_INCLUDED_ |
|
130 |
# endif |
|
131 |
||
132 |
# ifndef _SYS_TIMEB_H_INCLUDED_ |
|
133 |
# include <sys/timeb.h> |
|
134 |
# define _SYS_TIMEB_H_INCLUDED_ |
|
135 |
# endif |
|
136 |
||
137 |
# ifndef _SYS_STAT_H_INCLUDED_ |
|
138 |
# include <sys/stat.h> |
|
139 |
# define _SYS_STAT_H_INCLUDED_ |
|
140 |
# endif |
|
141 |
||
142 |
# ifndef _ERRNO_H_INCLUDED_ |
|
143 |
# include <errno.h> |
|
144 |
# define _ERRNO_H_INCLUDED_ |
|
145 |
# endif |
|
146 |
||
147 |
# ifndef _STDIO_H_INCLUDED_ |
|
148 |
# include <stdio.h> |
|
149 |
# define _STDIO_H_INCLUDED_ |
|
150 |
# endif |
|
151 |
||
152 |
# ifndef _FCNTL_H_INCLUDED_ |
|
153 |
# include <fcntl.h> |
|
154 |
# define _FCNTL_H_INCLUDED_ |
|
155 |
# endif |
|
156 |
||
7852 | 157 |
/* # define PROCESSDEBUGWIN32 /* */ |
158 |
/* # define PROCESS1DEBUGWIN32 /* */ |
|
159 |
/* # define PROCESS2DEBUGWIN32 /* */ |
|
5133 | 160 |
/* # define SELECTDEBUGWIN32 /* */ |
161 |
/* # define SELECT1DEBUGWIN32 /* */ |
|
162 |
/* # define SELECT2DEBUGWIN32 /* */ |
|
163 |
/* # define WAITDEBUGWIN32 /* */ |
|
164 |
/* # define SIGNALDEBUGWIN32 /* */ |
|
7852 | 165 |
|
5133 | 166 |
# undef INT |
167 |
# undef Array |
|
168 |
# undef Number |
|
169 |
# undef Method |
|
170 |
# undef Point |
|
171 |
# undef Rectangle |
|
172 |
# undef Block |
|
173 |
# undef String |
|
174 |
# undef Message |
|
175 |
# undef Object |
|
176 |
# undef Context |
|
177 |
# undef Time |
|
178 |
# undef Date |
|
179 |
# undef Set |
|
180 |
# undef Signal |
|
181 |
# undef Delay |
|
182 |
||
7840 | 183 |
/* # define NO_GETADAPTERSINFO |
184 |
*/ |
|
6543 | 185 |
|
5133 | 186 |
# include <stdarg.h> /* */ |
7531 | 187 |
# ifndef WINDOWS_H_INCLUDED |
188 |
# define WINDOWS_H_INCLUDED |
|
189 |
# include <windows.h> |
|
190 |
# endif |
|
7840 | 191 |
|
6543 | 192 |
# ifndef NO_GETADAPTERSINFO |
7840 | 193 |
# include <iphlpapi.h> |
6543 | 194 |
# endif |
5133 | 195 |
|
196 |
# if !defined(__BORLANDC__) |
|
197 |
# undef stat |
|
198 |
# define stat _stat |
|
199 |
# undef chmod |
|
200 |
# define chmod _chmod |
|
201 |
# undef access |
|
202 |
# define access _access |
|
203 |
# define MAXFILELEN 256 |
|
204 |
# endif |
|
205 |
||
206 |
# ifdef __DEF_Array |
|
207 |
# define Array __DEF_Array |
|
208 |
# endif |
|
209 |
# ifdef __DEF_Number |
|
210 |
# define Number __DEF_Number |
|
211 |
# endif |
|
212 |
# ifdef __DEF_Method |
|
213 |
# define Method __DEF_Method |
|
214 |
# endif |
|
215 |
# ifdef __DEF_Point |
|
216 |
# define Point __DEF_Point |
|
217 |
# endif |
|
7860 | 218 |
# ifdef __DEF_Rectangle |
219 |
# define Rectangle __DEF_Rectangle |
|
220 |
# endif |
|
5133 | 221 |
# ifdef __DEF_Block |
222 |
# define Block __DEF_Block |
|
223 |
# endif |
|
224 |
# ifdef __DEF_String |
|
225 |
# define String __DEF_String |
|
226 |
# endif |
|
227 |
# ifdef __DEF_Message |
|
228 |
# define Message __DEF_Message |
|
229 |
# endif |
|
230 |
# ifdef __DEF_Object |
|
231 |
# define Object __DEF_Object |
|
232 |
# endif |
|
233 |
# ifdef __DEF_Context |
|
234 |
# define Context __DEF_Context |
|
235 |
# endif |
|
236 |
# ifdef __DEF_Date |
|
237 |
# define Date __DEF_Date |
|
238 |
# endif |
|
239 |
# ifdef __DEF_Time |
|
240 |
# define Time __DEF_Time |
|
241 |
# endif |
|
242 |
# ifdef __DEF_Set |
|
243 |
# define Set __DEF_Set |
|
244 |
# endif |
|
245 |
# ifdef __DEF_Signal |
|
246 |
# define Signal __DEF_Signal |
|
247 |
# endif |
|
248 |
# ifdef __DEF_Delay |
|
249 |
# define Delay __DEF_Delay |
|
250 |
# endif |
|
251 |
||
252 |
# define INT int |
|
253 |
||
254 |
typedef int (*intf)(int); |
|
255 |
BOOL __signalUserInterruptWIN32(DWORD sig); |
|
256 |
||
257 |
# if defined (HAS_LOCALECONV) |
|
258 |
# ifndef _LOCALE_H_INCLUDED_ |
|
259 |
# include <locale.h> |
|
260 |
# define _LOCALE_H_INCLUDED_ |
|
261 |
# endif |
|
262 |
# endif |
|
263 |
||
264 |
/* |
|
265 |
* posix systems should define these ... |
|
266 |
* but on some (older) systems, they are not. |
|
267 |
*/ |
|
268 |
# ifndef S_IXUSR |
|
269 |
# ifdef S_IEXEC |
|
270 |
# define S_IXUSR S_IEXEC |
|
271 |
# define S_IXGRP (S_IEXEC>>3) |
|
272 |
# define S_IXOTH (S_IEXEC>>6) |
|
273 |
# endif |
|
274 |
# endif |
|
275 |
||
276 |
# ifndef S_IXUSR |
|
277 |
# define S_IXUSR 0100 |
|
278 |
# define S_IXGRP 0010 |
|
279 |
# define S_IXOTH 0001 |
|
280 |
# endif |
|
281 |
||
282 |
# ifndef S_IRUSR |
|
283 |
# define S_IRUSR 0400 |
|
284 |
# define S_IRGRP 0040 |
|
285 |
# define S_IROTH 0004 |
|
286 |
# endif |
|
287 |
||
288 |
# ifndef S_IWUSR |
|
289 |
# define S_IWUSR 0200 |
|
290 |
# define S_IWGRP 0020 |
|
291 |
# define S_IWOTH 0002 |
|
292 |
# endif |
|
293 |
||
294 |
# ifdef __BORLANDC__ |
|
295 |
# include <dir.h> |
|
296 |
# define MAXPATHLEN MAXPATH |
|
297 |
# define MAXFILELEN MAXFILE |
|
298 |
# endif |
|
299 |
||
300 |
# ifndef MAXPATHLEN |
|
301 |
# ifndef MSDOS_LIKE |
|
302 |
# ifndef NO_SYS_PARAM_H |
|
303 |
# include <sys/param.h> |
|
304 |
# endif |
|
305 |
# endif |
|
306 |
# ifndef MAXPATHLEN |
|
307 |
# ifdef FILENAME_MAX /* i.e. MSDOS_LIKE */ |
|
308 |
# define MAXPATHLEN FILENAME_MAX |
|
309 |
# else |
|
310 |
# ifdef MAX_PATH |
|
311 |
# define MAXPATHLEN MAX_PATH |
|
312 |
# else |
|
313 |
# define MAXPATHLEN 1024 |
|
314 |
# endif |
|
315 |
# endif |
|
316 |
# endif |
|
317 |
# endif |
|
318 |
||
319 |
/* |
|
320 |
* sigaction dummies (you won't believe these call themself ``POSIX'' systems ...) |
|
321 |
*/ |
|
322 |
# ifndef SA_RESTART |
|
323 |
# define SA_RESTART 0 |
|
324 |
# endif |
|
325 |
# ifndef SA_SIGINFO |
|
326 |
# define SA_SIGINFO 0 |
|
327 |
# endif |
|
328 |
||
329 |
# if defined(HAS_WAITPID) || defined(HAS_WAIT3) |
|
330 |
# include <sys/wait.h> |
|
331 |
# endif |
|
332 |
||
333 |
# if defined(HAS_SYSINFO) |
|
334 |
# include <sys/systeminfo.h> |
|
335 |
# endif |
|
336 |
||
337 |
#define SIGHANDLER_ARG int |
|
338 |
||
339 |
#define _HANDLEVal(o) (HANDLE)(__externalAddressVal(o)) |
|
340 |
||
341 |
/* |
|
342 |
* not all systems have time_t and off_t |
|
343 |
* explicit add of those we know to have ... |
|
344 |
*/ |
|
345 |
||
346 |
#ifndef TIME_T |
|
347 |
# define TIME_T long |
|
348 |
#endif |
|
349 |
#ifndef OFF_T |
|
350 |
# define OFF_T long |
|
351 |
#endif |
|
352 |
||
353 |
/* |
|
354 |
* where is the timezone info ? |
|
355 |
*/ |
|
356 |
#if defined(HAS_NO_TIMEZONE) |
|
357 |
# if defined(HAS_NO_TM_GMTOFF) |
|
358 |
# define TIMEZONE(tmPtr) 0 |
|
359 |
# else |
|
360 |
# define TIMEZONE(tmPtr) ((tmPtr)->tm_gmtoff) |
|
361 |
# endif |
|
362 |
#else |
|
363 |
# ifdef MSDOS_LIKE |
|
364 |
# define TIMEZONE(tmPtr) 0 |
|
365 |
# else |
|
366 |
# define TIMEZONE(tmPtr) timezone |
|
367 |
# endif |
|
368 |
#endif |
|
369 |
||
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
370 |
|
5133 | 371 |
%} |
372 |
! ! |
|
373 |
||
374 |
!Win32OperatingSystem primitiveFunctions! |
|
375 |
%{ |
|
376 |
||
7852 | 377 |
/* isWindows-NT flag: |
378 |
* 1 for NT based systemes, such as NT,XP or 2k |
|
379 |
* 0 for w95 based systems, such as w95/w98/ME |
|
380 |
*/ |
|
5133 | 381 |
static int __isWinNT = 0; |
382 |
||
383 |
#define __wait wait |
|
384 |
||
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
385 |
|
7852 | 386 |
static int |
387 |
_canAccessIOWithoutBlocking (aFD, readMode) |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
388 |
int aFD; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
389 |
int readMode; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
390 |
{ |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
391 |
struct timeval tv; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
392 |
fd_set fds; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
393 |
int n; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
394 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
395 |
/* we use the osfhandle insteat of the fd !! WHY ?? (I do not know) |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
396 |
but otherwise it not works |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
397 |
*/ |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
398 |
int sock = (int) _get_osfhandle (aFD); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
399 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
400 |
FD_ZERO( & fds ); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
401 |
FD_SET ( sock, & fds ); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
402 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
403 |
tv.tv_sec = 0; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
404 |
tv.tv_usec = 0; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
405 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
406 |
if (readMode) { |
7840 | 407 |
n = select (sock + 1, & fds, NULL, NULL, & tv); |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
408 |
} else { |
7840 | 409 |
n = select (sock + 1, NULL, & fds, NULL, & tv); |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
410 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
411 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
412 |
if (n == 0) { |
7840 | 413 |
return (0); |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
414 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
415 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
416 |
if (n > 0) { |
7840 | 417 |
return ((FD_ISSET (sock, & fds)) ? 1 : 0); |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
418 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
419 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
420 |
switch (WSAGetLastError()) { |
7840 | 421 |
case WSAENOTSOCK: |
422 |
if (readMode) { |
|
423 |
||
424 |
DWORD w = 0; |
|
425 |
HANDLE h = (HANDLE) _get_osfhandle (aFD); |
|
426 |
||
427 |
if (PeekNamedPipe (h, 0, 0, 0, & w, 0)) { |
|
428 |
if( !__isWinNT || w > 0 ) |
|
429 |
return (1); |
|
430 |
||
431 |
return (0); |
|
432 |
} |
|
433 |
return (-1); |
|
434 |
} |
|
435 |
/* in writeMode we return allways true for none-sockets */ |
|
436 |
return (1); |
|
437 |
||
438 |
case WSAEINPROGRESS: |
|
439 |
case WSAEWOULDBLOCK: return (0); |
|
440 |
||
441 |
default: return (1); |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
442 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
443 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
444 |
return (0); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
445 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
446 |
|
7840 | 447 |
#define _canReadWithoutBlocking(fd) _canAccessIOWithoutBlocking(fd, 1) |
448 |
#define _canWriteWithoutBlocking(fd) _canAccessIOWithoutBlocking(fd, 0) |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
449 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
450 |
|
5133 | 451 |
%} |
452 |
! ! |
|
453 |
||
454 |
!Win32OperatingSystem class methodsFor:'documentation'! |
|
455 |
||
456 |
copyright |
|
457 |
" |
|
458 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
7852 | 459 |
COPYRIGHT (c) 1998-2004 by eXept Software AG |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
460 |
All Rights Reserved |
5133 | 461 |
|
462 |
This software is furnished under a license and may be used |
|
463 |
only in accordance with the terms of that license and with the |
|
464 |
inclusion of the above copyright notice. This software may not |
|
465 |
be provided or otherwise made available to, or used by, any |
|
466 |
other person. No title to or ownership of the software is |
|
467 |
hereby transferred. |
|
468 |
" |
|
469 |
! |
|
470 |
||
471 |
documentation |
|
472 |
" |
|
473 |
this class resulted from extracting WIN32 specifics of the old |
|
474 |
OperatingSystemClass into this sub-class. |
|
475 |
You may find some leftover unix stuff, which will go away sooner |
|
476 |
or later. |
|
477 |
||
478 |
this class realizes access to most (all ?) required operating system services; |
|
479 |
some of it is very specific for unix, so do not depend on |
|
480 |
things available here in your applications |
|
481 |
- some may not be found in other OS's or be slightly different ... |
|
482 |
||
483 |
(On the other hand: I do not want to hide all features |
|
484 |
from you - in some situations it MAY be interesting to be |
|
485 |
able to get down to a select or fork system call easily (at least on Unix systems). |
|
486 |
You decide - portability vs. functionality) |
|
487 |
||
488 |
[Class variables:] |
|
489 |
||
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
490 |
HostName <String> remembered hostname |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
491 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
492 |
DomainName <String> remembered domainname |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
493 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
494 |
CurrentDirectory <String> remembered currentDirectories path |
5133 | 495 |
|
496 |
[author:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
497 |
Claus Gittinger (initial version & cleanup) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
498 |
Manfred Dierolf (many features) |
5133 | 499 |
|
500 |
[see also:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
501 |
OSProcessStatus |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
502 |
Filename Date Time |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
503 |
ExternalStream FileStream PipeStream Socket |
5133 | 504 |
" |
505 |
! |
|
506 |
||
507 |
examples |
|
508 |
" |
|
509 |
various queries |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
510 |
[exBegin] |
5133 | 511 |
Transcript |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
512 |
showCR:'hello ' , (OperatingSystem getLoginName) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
513 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
514 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
515 |
[exBegin] |
5133 | 516 |
OperatingSystem isUNIXlike ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
517 |
Transcript showCR:'this is some UNIX-like OS' |
5133 | 518 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
519 |
Transcript showCR:'this OS is not UNIX-like' |
5133 | 520 |
] |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
521 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
522 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
523 |
[exBegin] |
5133 | 524 |
Transcript |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
525 |
showCR:'this machine is called ' , OperatingSystem getHostName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
526 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
527 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
528 |
[exBegin] |
5133 | 529 |
Transcript |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
530 |
showCR:('this machine is in the ' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
531 |
, OperatingSystem getDomainName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
532 |
, ' domain') |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
533 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
534 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
535 |
[exBegin] |
5133 | 536 |
Transcript |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
537 |
showCR:('this machine''s CPU is a ' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
538 |
, OperatingSystem getCPUType |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
539 |
) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
540 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
541 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
542 |
[exBegin] |
5133 | 543 |
Transcript showCR:'executing ls command ...'. |
544 |
OperatingSystem executeCommand:'ls'. |
|
545 |
Transcript showCR:'... done.'. |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
546 |
[exEnd] |
5133 | 547 |
|
548 |
locking a file |
|
549 |
(should be executed on two running smalltalks - not in two threads): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
550 |
[exBegin] |
5133 | 551 |
|f| |
552 |
||
553 |
f := 'testFile' asFilename readWriteStream. |
|
554 |
||
555 |
10 timesRepeat:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
556 |
'about to lock ...' printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
557 |
[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
558 |
OperatingSystem |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
559 |
lockFD:(f fileDescriptor) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
560 |
shared:false |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
561 |
blocking:false |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
562 |
] whileFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
563 |
'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
564 |
Delay waitForSeconds:1 |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
565 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
566 |
'LOCKED ...' printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
567 |
Delay waitForSeconds:10. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
568 |
'unlock ...' printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
569 |
(OperatingSystem |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
570 |
unlockFD:(f fileDescriptor)) printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
571 |
Delay waitForSeconds:3. |
5133 | 572 |
] |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
573 |
[exBegin] |
5133 | 574 |
" |
575 |
! ! |
|
576 |
||
577 |
!Win32OperatingSystem class methodsFor:'initialization'! |
|
578 |
||
579 |
initOSType |
|
7852 | 580 |
"internal - see if running under win-NT/XP/2k |
581 |
(as opposed to win-95/98/ME)" |
|
5133 | 582 |
|
583 |
%{ /* NOCONTEXT */ |
|
584 |
OSVERSIONINFO osvi; |
|
585 |
||
586 |
memset(&osvi, 0, sizeof(OSVERSIONINFO)); |
|
587 |
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); |
|
588 |
GetVersionEx (&osvi); |
|
589 |
||
590 |
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
591 |
__isWinNT = 1; |
5133 | 592 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
593 |
__isWinNT = 0; |
5133 | 594 |
} |
595 |
%}. |
|
596 |
! |
|
597 |
||
598 |
initialize |
|
599 |
"initialize the class" |
|
600 |
||
601 |
ObjectMemory addDependent:self. |
|
602 |
HostName := nil. |
|
603 |
DomainName := nil. |
|
604 |
LastErrorNumber := nil. |
|
605 |
PipeFailed := false. |
|
606 |
self initOSType |
|
607 |
||
608 |
"Modified: 13.9.1997 / 10:47:32 / cg" |
|
609 |
! |
|
610 |
||
611 |
update:something with:aParameter from:changedObject |
|
612 |
"catch image restart and flush some cached data" |
|
613 |
||
614 |
something == #earlyRestart ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
615 |
" |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
616 |
flush cached data |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
617 |
" |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
618 |
HostName := nil. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
619 |
DomainName := nil. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
620 |
LastErrorNumber := nil. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
621 |
PipeFailed := false. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
622 |
self initOSType |
5133 | 623 |
] |
624 |
||
625 |
"Modified: 22.4.1996 / 13:10:43 / cg" |
|
626 |
"Created: 15.6.1996 / 15:22:37 / cg" |
|
627 |
"Modified: 7.1.1997 / 19:36:11 / stefan" |
|
628 |
! ! |
|
629 |
||
630 |
!Win32OperatingSystem class methodsFor:'OS signal constants'! |
|
631 |
||
632 |
sigABRT |
|
633 |
"return the signal number for SIGABRT - 0 if not supported by OS |
|
634 |
(the numeric value is not the same across unix-systems)" |
|
635 |
||
636 |
%{ /* NOCONTEXT */ |
|
637 |
#ifdef SIGABRT |
|
638 |
RETURN ( __MKSMALLINT(SIGABRT) ); |
|
639 |
#else |
|
640 |
RETURN ( __MKSMALLINT(0) ); |
|
641 |
#endif |
|
642 |
%} |
|
643 |
! |
|
644 |
||
645 |
sigALRM |
|
646 |
"return the signal number for SIGALRM - 0 if not supported |
|
647 |
(the numeric value is not the same across unix-systems)" |
|
648 |
||
649 |
%{ /* NOCONTEXT */ |
|
650 |
#ifdef SIGALRM |
|
651 |
RETURN ( __MKSMALLINT(SIGALRM) ); |
|
652 |
#else |
|
653 |
RETURN ( __MKSMALLINT(0) ); |
|
654 |
#endif |
|
655 |
%} |
|
656 |
! |
|
657 |
||
658 |
sigBREAK |
|
659 |
"return the signal number for SIGBREAK - 0 if not supported. |
|
660 |
This is an MSDOS specific signal" |
|
661 |
||
662 |
%{ /* NOCONTEXT */ |
|
663 |
#ifdef SIGBREAK |
|
664 |
RETURN ( __MKSMALLINT(SIGBREAK) ); |
|
665 |
#else |
|
666 |
RETURN ( __MKSMALLINT(0) ); |
|
667 |
#endif |
|
668 |
%} |
|
669 |
! |
|
670 |
||
671 |
sigBUS |
|
672 |
"return the signal number for SIGBUS - 0 if not supported |
|
673 |
(the numeric value is not the same across unix-systems)" |
|
674 |
||
675 |
%{ /* NOCONTEXT */ |
|
676 |
#ifdef SIGBUS |
|
677 |
RETURN ( __MKSMALLINT(SIGBUS) ); |
|
678 |
#else |
|
679 |
RETURN ( __MKSMALLINT(0) ); |
|
680 |
#endif |
|
681 |
%} |
|
682 |
! |
|
683 |
||
684 |
sigCHLD |
|
685 |
"return the signal number for SIGCHLD - 0 if not supported |
|
686 |
(the numeric value is not the same across unix-systems)" |
|
687 |
||
688 |
%{ /* NOCONTEXT */ |
|
689 |
#if defined(SIGCHLD) |
|
690 |
RETURN ( __MKSMALLINT(SIGCHLD) ); |
|
691 |
#else |
|
692 |
# if defined(SIGCLD) |
|
693 |
RETURN ( __MKSMALLINT(SIGCLD) ); |
|
694 |
# else |
|
695 |
RETURN ( __MKSMALLINT(0) ); |
|
696 |
# endif |
|
697 |
#endif |
|
698 |
%} |
|
699 |
! |
|
700 |
||
701 |
sigCONT |
|
702 |
"return the signal number for SIGCONT - 0 if not supported |
|
703 |
(the numeric value is not the same across unix-systems)" |
|
704 |
||
705 |
%{ /* NOCONTEXT */ |
|
706 |
#if defined(SIGCONT) |
|
707 |
RETURN ( __MKSMALLINT(SIGCONT) ); |
|
708 |
#else |
|
709 |
RETURN ( __MKSMALLINT(0) ); |
|
710 |
#endif |
|
711 |
%} |
|
712 |
! |
|
713 |
||
714 |
sigDANGER |
|
715 |
"return the signal number for SIGDANGER - 0 if not supported |
|
716 |
(seems to be an AIX special)" |
|
717 |
||
718 |
%{ /* NOCONTEXT */ |
|
719 |
#if defined(SIGDANGER) |
|
720 |
RETURN ( __MKSMALLINT(SIGDANGER) ); |
|
721 |
#else |
|
722 |
RETURN ( __MKSMALLINT(0) ); |
|
723 |
#endif |
|
724 |
%} |
|
725 |
! |
|
726 |
||
727 |
sigEMT |
|
728 |
"return the signal number for SIGEMT - 0 if not supported by OS |
|
729 |
(the numeric value is not the same across unix-systems)" |
|
730 |
||
731 |
%{ /* NOCONTEXT */ |
|
732 |
#ifdef SIGEMT |
|
733 |
RETURN ( __MKSMALLINT(SIGEMT) ); |
|
734 |
#else |
|
735 |
RETURN ( __MKSMALLINT(0) ); |
|
736 |
#endif |
|
737 |
%} |
|
738 |
! |
|
739 |
||
740 |
sigFP |
|
741 |
"return the signal number for SIGFP - 0 if not supported by OS |
|
742 |
(the numeric value is not the same across unix-systems)" |
|
743 |
||
744 |
%{ /* NOCONTEXT */ |
|
745 |
#ifdef SIGFPE |
|
746 |
RETURN ( __MKSMALLINT(SIGFPE) ); |
|
747 |
#else |
|
748 |
RETURN ( __MKSMALLINT(0) ); |
|
749 |
#endif |
|
750 |
%} |
|
751 |
! |
|
752 |
||
753 |
sigGRANT |
|
754 |
"return the signal number for SIGGRANT - 0 if not supported |
|
755 |
(seems to be an AIX special)" |
|
756 |
||
757 |
%{ /* NOCONTEXT */ |
|
758 |
#if defined(SIGGRANT) |
|
759 |
RETURN ( __MKSMALLINT(SIGGRANT) ); |
|
760 |
#else |
|
761 |
RETURN ( __MKSMALLINT(0) ); |
|
762 |
#endif |
|
763 |
%} |
|
764 |
! |
|
765 |
||
766 |
sigHUP |
|
767 |
"return the signal number for SIGHUP |
|
768 |
(the numeric value is not the same across unix-systems)" |
|
769 |
||
770 |
%{ /* NOCONTEXT */ |
|
771 |
#ifdef SIGHUP |
|
772 |
RETURN ( __MKSMALLINT(SIGHUP) ); |
|
773 |
#else |
|
774 |
RETURN ( __MKSMALLINT(0) ); |
|
775 |
#endif |
|
776 |
%} |
|
777 |
! |
|
778 |
||
779 |
sigILL |
|
780 |
"return the signal number for SIGILL - 0 if not supported by OS |
|
781 |
(the numeric value is not the same across unix-systems)" |
|
782 |
||
783 |
%{ /* NOCONTEXT */ |
|
784 |
#ifdef SIGILL |
|
785 |
RETURN ( __MKSMALLINT(SIGILL) ); |
|
786 |
#else |
|
787 |
RETURN ( __MKSMALLINT(0) ); |
|
788 |
#endif |
|
789 |
%} |
|
790 |
! |
|
791 |
||
792 |
sigINT |
|
793 |
"return the signal number for SIGINT |
|
794 |
(the numeric value is not the same across unix-systems)" |
|
795 |
||
796 |
%{ /* NOCONTEXT */ |
|
797 |
#ifdef SIGINT |
|
798 |
RETURN ( __MKSMALLINT(SIGINT) ); |
|
799 |
#else |
|
800 |
RETURN ( __MKSMALLINT(0) ); |
|
801 |
#endif |
|
802 |
%} |
|
803 |
! |
|
804 |
||
805 |
sigIO |
|
806 |
"return the signal number for SIGIO - 0 if not supported |
|
807 |
(the numeric value is not the same across unix-systems)" |
|
808 |
||
809 |
%{ /* NOCONTEXT */ |
|
810 |
#if defined(SIGIO) |
|
811 |
RETURN ( __MKSMALLINT(SIGIO) ); |
|
812 |
#else |
|
813 |
RETURN ( __MKSMALLINT(0) ); |
|
814 |
#endif |
|
815 |
%} |
|
816 |
! |
|
817 |
||
818 |
sigIOT |
|
819 |
"return the signal number for SIGIOT - 0 if not supported by OS |
|
820 |
(the numeric value is not the same across unix-systems)" |
|
821 |
||
822 |
%{ /* NOCONTEXT */ |
|
823 |
#ifdef SIGIOT |
|
824 |
RETURN ( __MKSMALLINT(SIGIOT) ); |
|
825 |
#else |
|
826 |
RETURN ( __MKSMALLINT(0) ); |
|
827 |
#endif |
|
828 |
%} |
|
829 |
! |
|
830 |
||
831 |
sigKILL |
|
832 |
"return the signal number for SIGKILL |
|
833 |
(the numeric value is not the same across unix-systems)" |
|
834 |
||
835 |
%{ /* NOCONTEXT */ |
|
836 |
#ifdef SIGKILL |
|
837 |
RETURN ( __MKSMALLINT(SIGKILL) ); |
|
838 |
#else |
|
839 |
RETURN ( __MKSMALLINT(0) ); |
|
840 |
#endif |
|
841 |
%} |
|
842 |
! |
|
843 |
||
844 |
sigLOST |
|
845 |
"return the signal number for SIGLOST - 0 if not supported |
|
846 |
(the numeric value is not the same across unix-systems)" |
|
847 |
||
848 |
%{ /* NOCONTEXT */ |
|
849 |
#if defined(SIGLOST) |
|
850 |
RETURN ( __MKSMALLINT(SIGLOST) ); |
|
851 |
#else |
|
852 |
RETURN ( __MKSMALLINT(0) ); |
|
853 |
#endif |
|
854 |
%} |
|
855 |
! |
|
856 |
||
857 |
sigMIGRATE |
|
858 |
"return the signal number for SIGMIGRATE - 0 if not supported |
|
859 |
(seems to be an AIX special)" |
|
860 |
||
861 |
%{ /* NOCONTEXT */ |
|
862 |
#if defined(SIGMIGRATE) |
|
863 |
RETURN ( __MKSMALLINT(SIGMIGRATE) ); |
|
864 |
#else |
|
865 |
RETURN ( __MKSMALLINT(0) ); |
|
866 |
#endif |
|
867 |
%} |
|
868 |
! |
|
869 |
||
870 |
sigMSG |
|
871 |
"return the signal number for SIGMSG - 0 if not supported |
|
872 |
(seems to be an AIX special)" |
|
873 |
||
874 |
%{ /* NOCONTEXT */ |
|
875 |
#if defined(SIGMSG) |
|
876 |
RETURN ( __MKSMALLINT(SIGMSG) ); |
|
877 |
#else |
|
878 |
RETURN ( __MKSMALLINT(0) ); |
|
879 |
#endif |
|
880 |
%} |
|
881 |
! |
|
882 |
||
883 |
sigPIPE |
|
884 |
"return the signal number for SIGPIPE - 0 if not supported |
|
885 |
(the numeric value is not the same across unix-systems)" |
|
886 |
||
887 |
%{ /* NOCONTEXT */ |
|
888 |
#ifdef SIGPIPE |
|
889 |
RETURN ( __MKSMALLINT(SIGPIPE) ); |
|
890 |
#else |
|
891 |
RETURN ( __MKSMALLINT(0) ); |
|
892 |
#endif |
|
893 |
%} |
|
894 |
! |
|
895 |
||
896 |
sigPOLL |
|
897 |
"return the signal number for SIGPOLL - 0 if not supported |
|
898 |
(the numeric value is not the same across unix-systems)" |
|
899 |
||
900 |
%{ /* NOCONTEXT */ |
|
901 |
#if defined(SIGPOLL) |
|
902 |
RETURN ( __MKSMALLINT(SIGPOLL) ); |
|
903 |
#else |
|
904 |
RETURN ( __MKSMALLINT(0) ); |
|
905 |
#endif |
|
906 |
%} |
|
907 |
! |
|
908 |
||
909 |
sigPRE |
|
910 |
"return the signal number for SIGPRE - 0 if not supported |
|
911 |
(seems to be an AIX special)" |
|
912 |
||
913 |
%{ /* NOCONTEXT */ |
|
914 |
#if defined(SIGPRE) |
|
915 |
RETURN ( __MKSMALLINT(SIGPRE) ); |
|
916 |
#else |
|
917 |
RETURN ( __MKSMALLINT(0) ); |
|
918 |
#endif |
|
919 |
%} |
|
920 |
! |
|
921 |
||
922 |
sigPROF |
|
923 |
"return the signal number for SIGPROF - 0 if not supported |
|
924 |
(the numeric value is not the same across unix-systems)" |
|
925 |
||
926 |
%{ /* NOCONTEXT */ |
|
927 |
#if defined(SIGPROF) |
|
928 |
RETURN ( __MKSMALLINT(SIGPROF) ); |
|
929 |
#else |
|
930 |
RETURN ( __MKSMALLINT(0) ); |
|
931 |
#endif |
|
932 |
%} |
|
933 |
! |
|
934 |
||
935 |
sigPWR |
|
936 |
"return the signal number for SIGPWR - 0 if not supported |
|
937 |
(not available on all systems)" |
|
938 |
||
939 |
%{ /* NOCONTEXT */ |
|
940 |
#if defined(SIGPWR) |
|
941 |
RETURN ( __MKSMALLINT(SIGPWR) ); |
|
942 |
#else |
|
943 |
RETURN ( __MKSMALLINT(0) ); |
|
944 |
#endif |
|
945 |
%} |
|
946 |
! |
|
947 |
||
948 |
sigQUIT |
|
949 |
"return the signal number for SIGQUIT |
|
950 |
(the numeric value is not the same across unix-systems)" |
|
951 |
||
952 |
%{ /* NOCONTEXT */ |
|
953 |
#ifdef SIGQUIT |
|
954 |
RETURN ( __MKSMALLINT(SIGQUIT) ); |
|
955 |
#else |
|
956 |
RETURN ( __MKSMALLINT(0) ); |
|
957 |
#endif |
|
958 |
%} |
|
959 |
! |
|
960 |
||
961 |
sigRETRACT |
|
962 |
"return the signal number for SIGRETRACT - 0 if not supported |
|
963 |
(seems to be an AIX special)" |
|
964 |
||
965 |
%{ /* NOCONTEXT */ |
|
966 |
#if defined(SIGRETRACT) |
|
967 |
RETURN ( __MKSMALLINT(SIGRETRACT) ); |
|
968 |
#else |
|
969 |
RETURN ( __MKSMALLINT(0) ); |
|
970 |
#endif |
|
971 |
%} |
|
972 |
! |
|
973 |
||
974 |
sigSAK |
|
975 |
"return the signal number for SIGSAK - 0 if not supported |
|
976 |
(seems to be an AIX special)" |
|
977 |
||
978 |
%{ /* NOCONTEXT */ |
|
979 |
#if defined(SIGSAK) |
|
980 |
RETURN ( __MKSMALLINT(SIGSAK) ); |
|
981 |
#else |
|
982 |
RETURN ( __MKSMALLINT(0) ); |
|
983 |
#endif |
|
984 |
%} |
|
985 |
! |
|
986 |
||
987 |
sigSEGV |
|
988 |
"return the signal number for SIGSEGV - 0 if not supported |
|
989 |
(the numeric value is not the same across unix-systems)" |
|
990 |
||
991 |
%{ /* NOCONTEXT */ |
|
992 |
#ifdef SIGSEGV |
|
993 |
RETURN ( __MKSMALLINT(SIGSEGV) ); |
|
994 |
#else |
|
995 |
RETURN ( __MKSMALLINT(0) ); |
|
996 |
#endif |
|
997 |
%} |
|
998 |
! |
|
999 |
||
1000 |
sigSOUND |
|
1001 |
"return the signal number for SIGSOUND - 0 if not supported |
|
1002 |
(seems to be an AIX special)" |
|
1003 |
||
1004 |
%{ /* NOCONTEXT */ |
|
1005 |
#if defined(SIGSOUND) |
|
1006 |
RETURN ( __MKSMALLINT(SIGSOUND) ); |
|
1007 |
#else |
|
1008 |
RETURN ( __MKSMALLINT(0) ); |
|
1009 |
#endif |
|
1010 |
%} |
|
1011 |
! |
|
1012 |
||
1013 |
sigSTOP |
|
1014 |
"return the signal number for SIGSTOP - 0 if not supported |
|
1015 |
(the numeric value is not the same across unix-systems)" |
|
1016 |
||
1017 |
%{ /* NOCONTEXT */ |
|
1018 |
#if defined(SIGSTOP) |
|
1019 |
RETURN ( __MKSMALLINT(SIGSTOP) ); |
|
1020 |
#else |
|
1021 |
RETURN ( __MKSMALLINT(0) ); |
|
1022 |
#endif |
|
1023 |
%} |
|
1024 |
! |
|
1025 |
||
1026 |
sigSYS |
|
1027 |
"return the signal number for SIGSYS - 0 if not supported |
|
1028 |
(the numeric value is not the same across unix-systems)" |
|
1029 |
||
1030 |
%{ /* NOCONTEXT */ |
|
1031 |
#ifdef SIGSYS |
|
1032 |
RETURN ( __MKSMALLINT(SIGSYS) ); |
|
1033 |
#else |
|
1034 |
RETURN ( __MKSMALLINT(0) ); |
|
1035 |
#endif |
|
1036 |
%} |
|
1037 |
! |
|
1038 |
||
1039 |
sigTERM |
|
1040 |
"return the signal number for SIGTERM - 0 if not supported |
|
1041 |
(the numeric value is not the same across unix-systems)" |
|
1042 |
||
1043 |
%{ /* NOCONTEXT */ |
|
1044 |
#ifdef SIGTERM |
|
1045 |
RETURN ( __MKSMALLINT(SIGTERM) ); |
|
1046 |
#else |
|
1047 |
RETURN ( __MKSMALLINT(0) ); |
|
1048 |
#endif |
|
1049 |
%} |
|
1050 |
! |
|
1051 |
||
1052 |
sigTRAP |
|
1053 |
"return the signal number for SIGTRAP - 0 if not supported by OS |
|
1054 |
(the numeric value is not the same across unix-systems)" |
|
1055 |
||
1056 |
%{ /* NOCONTEXT */ |
|
1057 |
#ifdef SIGTRAP |
|
1058 |
RETURN ( __MKSMALLINT(SIGTRAP) ); |
|
1059 |
#else |
|
1060 |
RETURN ( __MKSMALLINT(0) ); |
|
1061 |
#endif |
|
1062 |
%} |
|
1063 |
! |
|
1064 |
||
1065 |
sigTSTP |
|
1066 |
"return the signal number for SIGTSTP - 0 if not supported |
|
1067 |
(the numeric value is not the same across unix-systems)" |
|
1068 |
||
1069 |
%{ /* NOCONTEXT */ |
|
1070 |
#if defined(SIGTSTP) |
|
1071 |
RETURN ( __MKSMALLINT(SIGTSTP) ); |
|
1072 |
#else |
|
1073 |
RETURN ( __MKSMALLINT(0) ); |
|
1074 |
#endif |
|
1075 |
%} |
|
1076 |
! |
|
1077 |
||
1078 |
sigTTIN |
|
1079 |
"return the signal number for SIGTTIN - 0 if not supported |
|
1080 |
(the numeric value is not the same across unix-systems)" |
|
1081 |
||
1082 |
%{ /* NOCONTEXT */ |
|
1083 |
#if defined(SIGTTIN) |
|
1084 |
RETURN ( __MKSMALLINT(SIGTTIN) ); |
|
1085 |
#else |
|
1086 |
RETURN ( __MKSMALLINT(0) ); |
|
1087 |
#endif |
|
1088 |
%} |
|
1089 |
! |
|
1090 |
||
1091 |
sigTTOU |
|
1092 |
"return the signal number for SIGTTOU - 0 if not supported |
|
1093 |
(the numeric value is not the same across unix-systems)" |
|
1094 |
||
1095 |
%{ /* NOCONTEXT */ |
|
1096 |
#if defined(SIGTTOU) |
|
1097 |
RETURN ( __MKSMALLINT(SIGTTOU) ); |
|
1098 |
#else |
|
1099 |
RETURN ( __MKSMALLINT(0) ); |
|
1100 |
#endif |
|
1101 |
%} |
|
1102 |
! |
|
1103 |
||
1104 |
sigURG |
|
1105 |
"return the signal number for SIGURG - 0 if not supported |
|
1106 |
(the numeric value is not the same across unix-systems)" |
|
1107 |
||
1108 |
%{ /* NOCONTEXT */ |
|
1109 |
#if defined(SIGURG) |
|
1110 |
RETURN ( __MKSMALLINT(SIGURG) ); |
|
1111 |
#else |
|
1112 |
RETURN ( __MKSMALLINT(0) ); |
|
1113 |
#endif |
|
1114 |
%} |
|
1115 |
! |
|
1116 |
||
1117 |
sigUSR1 |
|
1118 |
"return the signal number for SIGUSR1 - 0 if not supported |
|
1119 |
(the numeric value is not the same across unix-systems)" |
|
1120 |
||
1121 |
%{ /* NOCONTEXT */ |
|
1122 |
#if defined(SIGUSR1) |
|
1123 |
RETURN ( __MKSMALLINT(SIGUSR1) ); |
|
1124 |
#else |
|
1125 |
RETURN ( __MKSMALLINT(0) ); |
|
1126 |
#endif |
|
1127 |
%} |
|
1128 |
! |
|
1129 |
||
1130 |
sigUSR2 |
|
1131 |
"return the signal number for SIGUSR2 - 0 if not supported |
|
1132 |
(the numeric value is not the same across unix-systems)" |
|
1133 |
||
1134 |
%{ /* NOCONTEXT */ |
|
1135 |
#if defined(SIGUSR2) |
|
1136 |
RETURN ( __MKSMALLINT(SIGUSR2) ); |
|
1137 |
#else |
|
1138 |
RETURN ( __MKSMALLINT(0) ); |
|
1139 |
#endif |
|
1140 |
%} |
|
1141 |
! |
|
1142 |
||
1143 |
sigVTALRM |
|
1144 |
"return the signal number for SIGVTALRM - 0 if not supported |
|
1145 |
(the numeric value is not the same across unix-systems)" |
|
1146 |
||
1147 |
%{ /* NOCONTEXT */ |
|
1148 |
#if defined(SIGVTALRM) |
|
1149 |
RETURN ( __MKSMALLINT(SIGVTALRM) ); |
|
1150 |
#else |
|
1151 |
RETURN ( __MKSMALLINT(0) ); |
|
1152 |
#endif |
|
1153 |
%} |
|
1154 |
! |
|
1155 |
||
1156 |
sigWINCH |
|
1157 |
"return the signal number for SIGWINCH - 0 if not supported |
|
1158 |
(the numeric value is not the same across unix-systems)" |
|
1159 |
||
1160 |
%{ /* NOCONTEXT */ |
|
1161 |
#if defined(SIGWINCH) |
|
1162 |
RETURN ( __MKSMALLINT(SIGWINCH) ); |
|
1163 |
#else |
|
1164 |
RETURN ( __MKSMALLINT(0) ); |
|
1165 |
#endif |
|
1166 |
%} |
|
1167 |
! |
|
1168 |
||
1169 |
sigXCPU |
|
1170 |
"return the signal number for SIGXCPU - 0 if not supported |
|
1171 |
(the numeric value is not the same across unix-systems)" |
|
1172 |
||
1173 |
%{ /* NOCONTEXT */ |
|
1174 |
#if defined(SIGXCPU) |
|
1175 |
RETURN ( __MKSMALLINT(SIGXCPU) ); |
|
1176 |
#else |
|
1177 |
RETURN ( __MKSMALLINT(0) ); |
|
1178 |
#endif |
|
1179 |
%} |
|
1180 |
! |
|
1181 |
||
1182 |
sigXFSZ |
|
1183 |
"return the signal number for SIGXFSZ - 0 if not supported |
|
1184 |
(the numeric value is not the same across unix-systems)" |
|
1185 |
||
1186 |
%{ /* NOCONTEXT */ |
|
1187 |
#if defined(SIGXFSZ) |
|
1188 |
RETURN ( __MKSMALLINT(SIGXFSZ) ); |
|
1189 |
#else |
|
1190 |
RETURN ( __MKSMALLINT(0) ); |
|
1191 |
#endif |
|
1192 |
%} |
|
1193 |
! ! |
|
1194 |
||
1195 |
!Win32OperatingSystem class methodsFor:'error messages'! |
|
1196 |
||
1197 |
currentErrorNumber |
|
1198 |
"returns the OS's last error nr (i.e. the value of errno). |
|
1199 |
Notice, that the value of this flag is only valid immediately |
|
1200 |
after the error occurred - it gets updated with every other |
|
1201 |
request to the OS. |
|
1202 |
Use lastErrorNumber - currentErrorNumber is invalidated by |
|
1203 |
many, many internal calls." |
|
1204 |
||
1205 |
%{ /* NOCONTEXT */ |
|
1206 |
||
1207 |
RETURN ( __MKSMALLINT(__threadErrno) ); |
|
1208 |
%} |
|
1209 |
" |
|
1210 |
OperatingSystem currentErrorNumber |
|
1211 |
" |
|
1212 |
! |
|
1213 |
||
6275 | 1214 |
errorHolderForNumber:errNr |
1215 |
"return an osErrorHolder for the given error number (as returned by a system call)." |
|
1216 |
||
6277 | 1217 |
|sym typ holder| |
6275 | 1218 |
|
1219 |
%{ |
|
1220 |
/* claus: |
|
1221 |
* I made this primitive code, since errnos are not |
|
1222 |
* standard across unixes |
|
1223 |
*/ |
|
1224 |
||
1225 |
typ = @symbol(defaultOsErrorSignal); |
|
6277 | 1226 |
sym = @symbol(ERROR_OTHER); |
1227 |
||
6288 | 1228 |
if (__isSmallInteger(errNr)) { |
1229 |
int __eno = __intVal(errNr); |
|
6275 | 1230 |
|
1231 |
if (__isWIN32Error(__eno)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1232 |
switch (__eno & 0xFFFF) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1233 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1234 |
* WIN32 GetLastError returns |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1235 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1236 |
case ERROR_INVALID_FUNCTION: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1237 |
sym = @symbol(ERROR_INVALID_FUNCTION); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1238 |
typ = @symbol(illegalOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1239 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1240 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1241 |
case ERROR_BAD_FORMAT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1242 |
sym = @symbol(ERROR_BAD_FORMAT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1243 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1244 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1245 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1246 |
case ERROR_FILE_NOT_FOUND: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1247 |
sym = @symbol(ERROR_FILE_NOT_FOUND); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1248 |
typ = @symbol(nonexistentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1249 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1250 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1251 |
case ERROR_PATH_NOT_FOUND: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1252 |
sym = @symbol(ERROR_PATH_NOT_FOUND); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1253 |
typ = @symbol(nonexistentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1254 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1255 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1256 |
case ERROR_TOO_MANY_OPEN_FILES: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1257 |
sym = @symbol(ERROR_TOO_MANY_OPEN_FILES); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1258 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1259 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1260 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1261 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1262 |
* what a nice errorCode - thats the most "useful" one I ever |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1263 |
* encountered ... (... those stupid micro-softies ...) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1264 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1265 |
case ERROR_OPEN_FAILED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1266 |
sym = @symbol(ERROR_OPEN_FAILED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1267 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1268 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1269 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1270 |
case ERROR_ACCESS_DENIED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1271 |
sym = @symbol(ERROR_ACCESS_DENIED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1272 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1273 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1274 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1275 |
case ERROR_INVALID_HANDLE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1276 |
sym = @symbol(ERROR_INVALID_HANDLE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1277 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1278 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1279 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1280 |
case ERROR_NOT_ENOUGH_MEMORY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1281 |
sym = @symbol(ERROR_NOT_ENOUGH_MEMORY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1282 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1283 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1284 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1285 |
case ERROR_INVALID_ACCESS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1286 |
sym = @symbol(ERROR_INVALID_ACCESS); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1287 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1288 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1289 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1290 |
case ERROR_INVALID_DATA: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1291 |
sym = @symbol(ERROR_INVALID_DATA); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1292 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1293 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1294 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1295 |
case ERROR_INVALID_NAME: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1296 |
sym = @symbol(ERROR_INVALID_NAME); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1297 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1298 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1299 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1300 |
case ERROR_ARENA_TRASHED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1301 |
sym = @symbol(ERROR_ARENA_TRASHED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1302 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1303 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1304 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1305 |
case ERROR_OUTOFMEMORY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1306 |
sym = @symbol(ERROR_OUTOFMEMORY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1307 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1308 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1309 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1310 |
case ERROR_BROKEN_PIPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1311 |
sym = @symbol(ERROR_BROKEN_PIPE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1312 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1313 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1314 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1315 |
case ERROR_GEN_FAILURE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1316 |
sym = @symbol(ERROR_GEN_FAILURE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1317 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1318 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1319 |
case ERROR_WRITE_PROTECT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1320 |
sym = @symbol(ERROR_WRITE_PROTECT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1321 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1322 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1323 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1324 |
case ERROR_WRITE_FAULT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1325 |
sym = @symbol(ERROR_WRITE_FAULT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1326 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1327 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1328 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1329 |
case ERROR_READ_FAULT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1330 |
sym = @symbol(ERROR_READ_FAULT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1331 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1332 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1333 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1334 |
case ERROR_HANDLE_DISK_FULL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1335 |
sym = @symbol(ERROR_HANDLE_DISK_FULL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1336 |
typ = @symbol(volumeFullSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1337 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1338 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1339 |
case ERROR_DISK_FULL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1340 |
sym = @symbol(ERROR_DISK_FULL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1341 |
typ = @symbol(volumeFullSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1342 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1343 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1344 |
case ERROR_SHARING_VIOLATION: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1345 |
sym = @symbol(ERROR_SHARING_VIOLATION); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1346 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1347 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1348 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1349 |
case ERROR_LOCK_VIOLATION: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1350 |
sym = @symbol(ERROR_LOCK_VIOLATION); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1351 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1352 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1353 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1354 |
case ERROR_INVALID_PARAMETER: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1355 |
sym = @symbol(ERROR_INVALID_PARAMETER); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1356 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1357 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1358 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1359 |
case ERROR_NET_WRITE_FAULT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1360 |
sym = @symbol(ERROR_NET_WRITE_FAULT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1361 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1362 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1363 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1364 |
case ERROR_NOT_SUPPORTED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1365 |
sym = @symbol(ERROR_NOT_SUPPORTED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1366 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1367 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1368 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1369 |
case ERROR_REM_NOT_LIST: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1370 |
sym = @symbol(ERROR_REM_NOT_LIST); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1371 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1372 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1373 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1374 |
case ERROR_NETWORK_ACCESS_DENIED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1375 |
sym = @symbol(ERROR_NETWORK_ACCESS_DENIED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1376 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1377 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1378 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1379 |
case ERROR_DUP_NAME: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1380 |
sym = @symbol(ERROR_DUP_NAME); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1381 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1382 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1383 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1384 |
case ERROR_BAD_NETPATH: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1385 |
sym = @symbol(ERROR_BAD_NETPATH); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1386 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1387 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1388 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1389 |
case ERROR_NETWORK_BUSY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1390 |
sym = @symbol(ERROR_NETWORK_BUSY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1391 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1392 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1393 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1394 |
case ERROR_DRIVE_LOCKED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1395 |
sym = @symbol(ERROR_DRIVE_LOCKED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1396 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1397 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1398 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1399 |
case ERROR_INVALID_DRIVE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1400 |
sym = @symbol(ERROR_INVALID_DRIVE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1401 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1402 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1403 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1404 |
case ERROR_WRONG_DISK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1405 |
sym = @symbol(ERROR_WRONG_DISK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1406 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1407 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1408 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1409 |
case ERROR_CURRENT_DIRECTORY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1410 |
sym = @symbol(ERROR_CURRENT_DIRECTORY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1411 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1412 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1413 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1414 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1415 |
* what a nice errorCode - thats the most "useful" one I ever |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1416 |
* encountered ... (... those stupid micro-softies ...) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1417 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1418 |
case ERROR_CANNOT_MAKE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1419 |
sym = @symbol(ERROR_CANNOT_MAKE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1420 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1421 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1422 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1423 |
case ERROR_NO_MORE_FILES: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1424 |
sym = @symbol(ERROR_NO_MORE_FILES); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1425 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1426 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1427 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1428 |
case ERROR_NOT_READY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1429 |
sym = @symbol(ERROR_NOT_READY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1430 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1431 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1432 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1433 |
case ERROR_NOT_DOS_DISK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1434 |
sym = @symbol(ERROR_NOT_DOS_DISK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1435 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1436 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1437 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1438 |
case ERROR_OUT_OF_PAPER: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1439 |
sym = @symbol(ERROR_OUT_OF_PAPER); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1440 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1441 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1442 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1443 |
case ERROR_PRINTQ_FULL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1444 |
sym = @symbol(ERROR_PRINTQ_FULL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1445 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1446 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1447 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1448 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1449 |
sym = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1450 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1451 |
} |
6275 | 1452 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1453 |
switch (__eno) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1454 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1455 |
* POSIX errnos - these should be defined |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1456 |
*/ |
6275 | 1457 |
#ifdef EPERM |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1458 |
case EPERM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1459 |
sym = @symbol(EPERM); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1460 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1461 |
break; |
6275 | 1462 |
#endif |
1463 |
#ifdef ENOENT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1464 |
case ENOENT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1465 |
sym = @symbol(ENOENT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1466 |
typ = @symbol(nonexistentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1467 |
break; |
6275 | 1468 |
#endif |
1469 |
#ifdef ESRCH |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1470 |
case ESRCH: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1471 |
sym = @symbol(ESRCH); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1472 |
typ = @symbol(unavailableReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1473 |
break; |
6275 | 1474 |
#endif |
1475 |
#ifdef EINTR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1476 |
case EINTR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1477 |
sym = @symbol(EINTR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1478 |
typ = @symbol(transientErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1479 |
break; |
6275 | 1480 |
#endif |
1481 |
#ifdef EIO |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1482 |
case EIO: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1483 |
sym = @symbol(EIO); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1484 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1485 |
break; |
6275 | 1486 |
#endif |
1487 |
#ifdef ENXIO |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1488 |
case ENXIO: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1489 |
sym = @symbol(ENXIO); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1490 |
typ = @symbol(unavailableReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1491 |
break; |
6275 | 1492 |
#endif |
1493 |
#ifdef E2BIG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1494 |
case E2BIG: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1495 |
sym = @symbol(E2BIG); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1496 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1497 |
break; |
6275 | 1498 |
#endif |
1499 |
#ifdef ENOEXEC |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1500 |
case ENOEXEC: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1501 |
sym = @symbol(ENOEXEC); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1502 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1503 |
break; |
6275 | 1504 |
#endif |
1505 |
#ifdef EBADF |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1506 |
case EBADF: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1507 |
sym = @symbol(EBADF); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1508 |
typ = @symbol(badAccessorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1509 |
break; |
6275 | 1510 |
#endif |
1511 |
#ifdef ECHILD |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1512 |
case ECHILD: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1513 |
sym = @symbol(ECHILD); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1514 |
typ = @symbol(informationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1515 |
break; |
6275 | 1516 |
#endif |
1517 |
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN) |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1518 |
case EAGAIN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1519 |
sym = @symbol(EAGAIN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1520 |
typ = @symbol(notReadySignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1521 |
break; |
6275 | 1522 |
#endif |
1523 |
#ifdef ENOMEM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1524 |
case ENOMEM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1525 |
sym = @symbol(ENOMEM); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1526 |
typ = @symbol(noMemorySignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1527 |
break; |
6275 | 1528 |
#endif |
1529 |
#ifdef EACCES |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1530 |
case EACCES: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1531 |
sym = @symbol(EACCES); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1532 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1533 |
break; |
6275 | 1534 |
#endif |
1535 |
#ifdef EFAULT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1536 |
case EFAULT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1537 |
sym = @symbol(EFAULT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1538 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1539 |
break; |
6275 | 1540 |
#endif |
1541 |
#ifdef EBUSY |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1542 |
case EBUSY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1543 |
sym = @symbol(EBUSY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1544 |
typ = @symbol(unavailableReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1545 |
break; |
6275 | 1546 |
#endif |
1547 |
#ifdef EEXIST |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1548 |
case EEXIST: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1549 |
sym = @symbol(EEXIST); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1550 |
typ = @symbol(existingReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1551 |
break; |
6275 | 1552 |
#endif |
1553 |
#ifdef EXDEV |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1554 |
case EXDEV: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1555 |
sym = @symbol(EXDEV); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1556 |
typ = @symbol(inappropriateReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1557 |
break; |
6275 | 1558 |
#endif |
1559 |
#ifdef ENODEV |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1560 |
case ENODEV: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1561 |
sym = @symbol(ENODEV); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1562 |
typ = @symbol(inaccessibleSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1563 |
break; |
6275 | 1564 |
#endif |
1565 |
#ifdef ENOTDIR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1566 |
case ENOTDIR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1567 |
sym = @symbol(ENOTDIR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1568 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1569 |
break; |
6275 | 1570 |
#endif |
1571 |
#ifdef EISDIR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1572 |
case EISDIR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1573 |
sym = @symbol(EISDIR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1574 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1575 |
break; |
6275 | 1576 |
#endif |
1577 |
#ifdef EINVAL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1578 |
case EINVAL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1579 |
sym = @symbol(EINVAL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1580 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1581 |
break; |
6275 | 1582 |
#endif |
1583 |
#ifdef ENFILE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1584 |
case ENFILE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1585 |
sym = @symbol(ENFILE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1586 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1587 |
break; |
6275 | 1588 |
#endif |
1589 |
#ifdef EMFILE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1590 |
case EMFILE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1591 |
sym = @symbol(EMFILE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1592 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1593 |
break; |
6275 | 1594 |
#endif |
1595 |
#ifdef ENOTTY |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1596 |
case ENOTTY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1597 |
sym = @symbol(ENOTTY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1598 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1599 |
break; |
6275 | 1600 |
#endif |
1601 |
#ifdef EFBIG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1602 |
case EFBIG: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1603 |
sym = @symbol(EFBIG); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1604 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1605 |
break; |
6275 | 1606 |
#endif |
1607 |
#ifdef ENOSPC |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1608 |
case ENOSPC: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1609 |
sym = @symbol(ENOSPC); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1610 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1611 |
break; |
6275 | 1612 |
#endif |
1613 |
#ifdef ESPIPE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1614 |
case ESPIPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1615 |
sym = @symbol(ESPIPE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1616 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1617 |
break; |
6275 | 1618 |
#endif |
1619 |
#ifdef EROFS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1620 |
case EROFS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1621 |
sym = @symbol(EROFS); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1622 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1623 |
break; |
6275 | 1624 |
#endif |
1625 |
#ifdef EMLINK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1626 |
case EMLINK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1627 |
sym = @symbol(EMLINK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1628 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1629 |
break; |
6275 | 1630 |
#endif |
1631 |
#ifdef EPIPE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1632 |
case EPIPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1633 |
sym = @symbol(EPIPE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1634 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1635 |
break; |
6275 | 1636 |
#endif |
1637 |
#ifdef EDOM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1638 |
case EDOM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1639 |
sym = @symbol(EDOM); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1640 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1641 |
break; |
6275 | 1642 |
#endif |
1643 |
#ifdef ERANGE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1644 |
case ERANGE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1645 |
sym = @symbol(ERANGE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1646 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1647 |
break; |
6275 | 1648 |
#endif |
1649 |
#ifdef EDEADLK |
|
1650 |
# if EDEADLK != EWOULDBLOCK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1651 |
case EDEADLK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1652 |
sym = @symbol(EDEADLK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1653 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1654 |
break; |
6275 | 1655 |
# endif |
1656 |
#endif |
|
1657 |
#ifdef ENAMETOOLONG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1658 |
case ENAMETOOLONG: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1659 |
sym = @symbol(ENAMETOOLONG); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1660 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1661 |
break; |
6275 | 1662 |
#endif |
1663 |
#ifdef ENOLCK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1664 |
case ENOLCK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1665 |
sym = @symbol(ENOLCK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1666 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1667 |
break; |
6275 | 1668 |
#endif |
1669 |
#ifdef ENOSYS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1670 |
case ENOSYS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1671 |
sym = @symbol(ENOSYS); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1672 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1673 |
break; |
6275 | 1674 |
#endif |
1675 |
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1676 |
case ENOTEMPTY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1677 |
sym = @symbol(ENOTEMPTY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1678 |
typ = @symbol(inappropriateReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1679 |
break; |
6275 | 1680 |
#endif |
1681 |
#ifdef EILSEQ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1682 |
case EILSEQ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1683 |
sym = @symbol(EILSEQ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1684 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1685 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1686 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1687 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1688 |
* XPG3 errnos - defined on most systems |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1689 |
*/ |
6275 | 1690 |
#ifdef ENOTBLK |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1691 |
case ENOTBLK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1692 |
sym = @symbol(ENOTBLK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1693 |
typ = @symbol(inappropriateReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1694 |
break; |
6275 | 1695 |
#endif |
1696 |
#ifdef ETXTBSY |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1697 |
case ETXTBSY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1698 |
sym = @symbol(ETXTBSY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1699 |
typ = @symbol(inaccessibleSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1700 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1701 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1702 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1703 |
* some others |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1704 |
*/ |
6275 | 1705 |
#ifdef EWOULDBLOCK |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1706 |
case EWOULDBLOCK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1707 |
sym = @symbol(EWOULDBLOCK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1708 |
typ = @symbol(notReadySignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1709 |
break; |
6275 | 1710 |
#endif |
1711 |
#ifdef ENOMSG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1712 |
case ENOMSG: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1713 |
sym = @symbol(ENOMSG); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1714 |
typ = @symbol(noDataSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1715 |
break; |
6275 | 1716 |
#endif |
1717 |
#ifdef ELOOP |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1718 |
case ELOOP: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1719 |
sym = @symbol(ELOOP); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1720 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1721 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1722 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1723 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1724 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1725 |
* some stream errors |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1726 |
*/ |
6275 | 1727 |
#ifdef ETIME |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1728 |
case ETIME: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1729 |
sym = @symbol(ETIME); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1730 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1731 |
break; |
6275 | 1732 |
#endif |
1733 |
#ifdef ENOSR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1734 |
case ENOSR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1735 |
sym = @symbol(ENOSR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1736 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1737 |
break; |
6275 | 1738 |
#endif |
1739 |
#ifdef ENOSTR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1740 |
case ENOSTR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1741 |
sym = @symbol(ENOSTR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1742 |
typ = @symbol(inappropriateReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1743 |
break; |
6275 | 1744 |
#endif |
1745 |
#ifdef ECOMM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1746 |
case ECOMM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1747 |
sym = @symbol(ECOMM); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1748 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1749 |
break; |
6275 | 1750 |
#endif |
1751 |
#ifdef EPROTO |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1752 |
case EPROTO: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1753 |
sym = @symbol(EPROTO); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1754 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1755 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1756 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1757 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1758 |
* nfs errors |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1759 |
*/ |
6275 | 1760 |
#ifdef ESTALE |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1761 |
case ESTALE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1762 |
sym = @symbol(ESTALE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1763 |
typ = @symbol(unavailableReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1764 |
break; |
6275 | 1765 |
#endif |
1766 |
#ifdef EREMOTE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1767 |
case EREMOTE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1768 |
sym = @symbol(EREMOTE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1769 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1770 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1771 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1772 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1773 |
* some networking errors |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1774 |
*/ |
6275 | 1775 |
#ifdef EINPROGRESS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1776 |
case EINPROGRESS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1777 |
sym = @symbol(EINPROGRESS); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1778 |
typ = @symbol(operationStartedSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1779 |
break; |
6275 | 1780 |
#endif |
1781 |
#ifdef EALREADY |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1782 |
case EALREADY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1783 |
sym = @symbol(EALREADY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1784 |
typ = @symbol(operationStartedSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1785 |
break; |
6275 | 1786 |
#endif |
1787 |
#ifdef ENOTSOCK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1788 |
case ENOTSOCK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1789 |
sym = @symbol(ENOTSOCK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1790 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1791 |
break; |
6275 | 1792 |
#endif |
1793 |
#ifdef EDESTADDRREQ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1794 |
case EDESTADDRREQ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1795 |
sym = @symbol(EDESTADDRREQ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1796 |
typ = @symbol(underspecifiedSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1797 |
break; |
6275 | 1798 |
#endif |
1799 |
#ifdef EMSGSIZE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1800 |
case EMSGSIZE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1801 |
sym = @symbol(EMSGSIZE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1802 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1803 |
break; |
6275 | 1804 |
#endif |
1805 |
#ifdef EPROTOTYPE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1806 |
case EPROTOTYPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1807 |
sym = @symbol(EPROTOTYPE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1808 |
typ = @symbol(wrongSubtypeForOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1809 |
break; |
6275 | 1810 |
#endif |
1811 |
#ifdef ENOPROTOOPT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1812 |
case ENOPROTOOPT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1813 |
sym = @symbol(ENOPROTOOPT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1814 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1815 |
break; |
6275 | 1816 |
#endif |
1817 |
#ifdef EPROTONOSUPPORT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1818 |
case EPROTONOSUPPORT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1819 |
sym = @symbol(EPROTONOSUPPORT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1820 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1821 |
break; |
6275 | 1822 |
#endif |
1823 |
#ifdef ESOCKTNOSUPPORT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1824 |
case ESOCKTNOSUPPORT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1825 |
sym = @symbol(ESOCKTNOSUPPORT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1826 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1827 |
break; |
6275 | 1828 |
#endif |
1829 |
#ifdef EOPNOTSUPP |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1830 |
case EOPNOTSUPP: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1831 |
sym = @symbol(EOPNOTSUPP); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1832 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1833 |
break; |
6275 | 1834 |
#endif |
1835 |
#ifdef EPFNOSUPPORT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1836 |
case EPFNOSUPPORT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1837 |
sym = @symbol(EPFNOSUPPORT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1838 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1839 |
break; |
6275 | 1840 |
#endif |
1841 |
#ifdef EAFNOSUPPORT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1842 |
case EAFNOSUPPORT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1843 |
sym = @symbol(EAFNOSUPPORT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1844 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1845 |
break; |
6275 | 1846 |
#endif |
1847 |
#ifdef EADDRINUSE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1848 |
case EADDRINUSE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1849 |
sym = @symbol(EADDRINUSE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1850 |
typ = @symbol(existingReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1851 |
break; |
6275 | 1852 |
#endif |
1853 |
#ifdef EADDRNOTAVAIL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1854 |
case EADDRNOTAVAIL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1855 |
sym = @symbol(EADDRNOTAVAIL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1856 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1857 |
break; |
6275 | 1858 |
#endif |
1859 |
#ifdef ETIMEDOUT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1860 |
case ETIMEDOUT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1861 |
sym = @symbol(ETIMEDOUT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1862 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1863 |
break; |
6275 | 1864 |
#endif |
1865 |
#ifdef ECONNREFUSED |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1866 |
case ECONNREFUSED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1867 |
sym = @symbol(ECONNREFUSED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1868 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1869 |
break; |
6275 | 1870 |
#endif |
1871 |
#ifdef ENETDOWN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1872 |
case ENETDOWN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1873 |
sym = @symbol(ENETDOWN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1874 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1875 |
break; |
6275 | 1876 |
#endif |
1877 |
#ifdef ENETUNREACH |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1878 |
case ENETUNREACH: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1879 |
sym = @symbol(ENETUNREACH); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1880 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1881 |
break; |
6275 | 1882 |
#endif |
1883 |
#ifdef ENETRESET |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1884 |
case ENETRESET: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1885 |
sym = @symbol(ENETRESET); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1886 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1887 |
break; |
6275 | 1888 |
#endif |
1889 |
#ifdef ECONNABORTED |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1890 |
case ECONNABORTED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1891 |
sym = @symbol(ECONNABORTED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1892 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1893 |
break; |
6275 | 1894 |
#endif |
1895 |
#ifdef ECONNRESET |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1896 |
case ECONNRESET: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1897 |
sym = @symbol(ECONNRESET); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1898 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1899 |
break; |
6275 | 1900 |
#endif |
1901 |
#ifdef EISCONN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1902 |
case EISCONN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1903 |
sym = @symbol(EISCONN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1904 |
typ = @symbol(unpreparedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1905 |
break; |
6275 | 1906 |
#endif |
1907 |
#ifdef ENOTCONN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1908 |
case ENOTCONN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1909 |
sym = @symbol(ENOTCONN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1910 |
typ = @symbol(unpreparedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1911 |
break; |
6275 | 1912 |
#endif |
1913 |
#ifdef ESHUTDOWN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1914 |
case ESHUTDOWN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1915 |
sym = @symbol(ESHUTDOWN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1916 |
typ = @symbol(unpreparedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1917 |
break; |
6275 | 1918 |
#endif |
1919 |
#ifdef EHOSTDOWN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1920 |
case EHOSTDOWN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1921 |
sym = @symbol(EHOSTDOWN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1922 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1923 |
break; |
6275 | 1924 |
#endif |
1925 |
#ifdef EHOSTUNREACH |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1926 |
case EHOSTUNREACH: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1927 |
sym = @symbol(EHOSTUNREACH); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1928 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1929 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1930 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1931 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1932 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1933 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1934 |
} |
6275 | 1935 |
} |
1936 |
} |
|
1937 |
%}. |
|
1938 |
holder := OSErrorHolder new. |
|
6277 | 1939 |
holder errorSymbol:sym errorCategory:typ. |
6275 | 1940 |
^ holder |
1941 |
||
1942 |
" |
|
1943 |
OperatingSystem errorHolderForNumber:4 |
|
1944 |
self errorHolderForNumber:(self errorNumberFor:#EPERM) |
|
1945 |
self errorHolderForNumber:(self errorNumberFor:#EIO) |
|
1946 |
self errorHolderForNumber:(self errorNumberFor:#ENXIO) |
|
1947 |
" |
|
1948 |
! |
|
1949 |
||
5133 | 1950 |
errorNumberFor:aSymbol |
1951 |
"given a symbolic error, return the numeric; |
|
1952 |
(i.e. errorNumberFor:#EBADF returns EBADF's value). |
|
1953 |
Use this, since error numbers are really not standard across unix systems." |
|
1954 |
||
1955 |
%{ /* NOCONTEXT */ |
|
1956 |
OBJ sym = aSymbol; |
|
1957 |
||
1958 |
/* |
|
6277 | 1959 |
* WIN32 GetLastError returns |
1960 |
*/ |
|
1961 |
#ifdef ERROR_INVALID_FUNCTION |
|
1962 |
if (sym == @symbol(ERROR_INVALID_FUNCTION)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1963 |
RETURN ( __MKSMALLINT(ERROR_INVALID_FUNCTION) ); |
6277 | 1964 |
} |
1965 |
#endif |
|
1966 |
#ifdef ERROR_BAD_FORMAT |
|
1967 |
if (sym == @symbol(ERROR_BAD_FORMAT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1968 |
RETURN ( __MKSMALLINT(ERROR_BAD_FORMAT) ); |
6277 | 1969 |
} |
1970 |
#endif |
|
1971 |
#ifdef ERROR_FILE_NOT_FOUND |
|
1972 |
if (sym == @symbol(ERROR_FILE_NOT_FOUND)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1973 |
RETURN ( __MKSMALLINT(ERROR_FILE_NOT_FOUND) ); |
6277 | 1974 |
} |
1975 |
#endif |
|
1976 |
#ifdef ERROR_PATH_NOT_FOUND |
|
1977 |
if (sym == @symbol(ERROR_PATH_NOT_FOUND)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1978 |
RETURN ( __MKSMALLINT(ERROR_PATH_NOT_FOUND) ); |
6277 | 1979 |
} |
1980 |
#endif |
|
1981 |
#ifdef ERROR_TOO_MANY_OPEN_FILES |
|
1982 |
if (sym == @symbol(ERROR_TOO_MANY_OPEN_FILES)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1983 |
RETURN ( __MKSMALLINT(ERROR_TOO_MANY_OPEN_FILES) ); |
6277 | 1984 |
} |
1985 |
#endif |
|
1986 |
#ifdef ERROR_OPEN_FAILED |
|
1987 |
if (sym == @symbol(ERROR_OPEN_FAILED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1988 |
RETURN ( __MKSMALLINT(ERROR_OPEN_FAILED) ); |
6277 | 1989 |
} |
1990 |
#endif |
|
1991 |
#ifdef ERROR_ACCESS_DENIED |
|
1992 |
if (sym == @symbol(ERROR_ACCESS_DENIED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1993 |
RETURN ( __MKSMALLINT(ERROR_ACCESS_DENIED) ); |
6277 | 1994 |
} |
1995 |
#endif |
|
1996 |
#ifdef ERROR_INVALID_HANDLE |
|
1997 |
if (sym == @symbol(ERROR_INVALID_HANDLE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1998 |
RETURN ( __MKSMALLINT(ERROR_INVALID_HANDLE) ); |
6277 | 1999 |
} |
2000 |
#endif |
|
2001 |
#ifdef ERROR_NOT_ENOUGH_MEMORY |
|
2002 |
if (sym == @symbol(ERROR_NOT_ENOUGH_MEMORY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2003 |
RETURN ( __MKSMALLINT(ERROR_NOT_ENOUGH_MEMORY) ); |
6277 | 2004 |
} |
2005 |
#endif |
|
2006 |
#ifdef ERROR_INVALID_ACCESS |
|
2007 |
if (sym == @symbol(ERROR_INVALID_ACCESS)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2008 |
RETURN ( __MKSMALLINT(ERROR_INVALID_ACCESS) ); |
6277 | 2009 |
} |
2010 |
#endif |
|
2011 |
#ifdef ERROR_INVALID_DATA |
|
2012 |
if (sym == @symbol(ERROR_INVALID_DATA)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2013 |
RETURN ( __MKSMALLINT(ERROR_INVALID_DATA) ); |
6277 | 2014 |
} |
2015 |
#endif |
|
2016 |
#ifdef ERROR_INVALID_NAME |
|
2017 |
if (sym == @symbol(ERROR_INVALID_NAME)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2018 |
RETURN ( __MKSMALLINT(ERROR_INVALID_NAME) ); |
6277 | 2019 |
} |
2020 |
#endif |
|
2021 |
#ifdef ERROR_ARENA_TRASHED |
|
2022 |
if (sym == @symbol(ERROR_ARENA_TRASHED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2023 |
RETURN ( __MKSMALLINT(ERROR_ARENA_TRASHED) ); |
6277 | 2024 |
} |
2025 |
#endif |
|
2026 |
#ifdef ERROR_OUTOFMEMORY |
|
2027 |
if (sym == @symbol(ERROR_OUTOFMEMORY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2028 |
RETURN ( __MKSMALLINT(ERROR_OUTOFMEMORY) ); |
6277 | 2029 |
} |
2030 |
#endif |
|
2031 |
#ifdef ERROR_BROKEN_PIPE |
|
2032 |
if (sym == @symbol(ERROR_BROKEN_PIPE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2033 |
RETURN ( __MKSMALLINT(ERROR_BROKEN_PIPE) ); |
6277 | 2034 |
} |
2035 |
#endif |
|
2036 |
#ifdef ERROR_GEN_FAILURE |
|
2037 |
if (sym == @symbol(ERROR_GEN_FAILURE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2038 |
RETURN ( __MKSMALLINT(ERROR_GEN_FAILURE) ); |
6277 | 2039 |
} |
2040 |
#endif |
|
2041 |
#ifdef ERROR_WRITE_PROTECT |
|
2042 |
if (sym == @symbol(ERROR_WRITE_PROTECT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2043 |
RETURN ( __MKSMALLINT(ERROR_WRITE_PROTECT) ); |
6277 | 2044 |
} |
2045 |
#endif |
|
2046 |
#ifdef ERROR_WRITE_FAULT |
|
2047 |
if (sym == @symbol(ERROR_WRITE_FAULT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2048 |
RETURN ( __MKSMALLINT(ERROR_WRITE_FAULT) ); |
6277 | 2049 |
} |
2050 |
#endif |
|
2051 |
#ifdef ERROR_READ_FAULT |
|
2052 |
if (sym == @symbol(ERROR_READ_FAULT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2053 |
RETURN ( __MKSMALLINT(ERROR_READ_FAULT) ); |
6277 | 2054 |
} |
2055 |
#endif |
|
2056 |
#ifdef ERROR_HANDLE_DISK_FULL |
|
2057 |
if (sym == @symbol(ERROR_HANDLE_DISK_FULL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2058 |
RETURN ( __MKSMALLINT(ERROR_HANDLE_DISK_FULL) ); |
6277 | 2059 |
} |
2060 |
#endif |
|
2061 |
#ifdef ERROR_DISK_FULL |
|
2062 |
if (sym == @symbol(ERROR_DISK_FULL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2063 |
RETURN ( __MKSMALLINT(ERROR_DISK_FULL) ); |
6277 | 2064 |
} |
2065 |
#endif |
|
2066 |
#ifdef ERROR_ERROR_SHARING_VIOLATION |
|
2067 |
if (sym == @symbol(ERROR_ERROR_SHARING_VIOLATION)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2068 |
RETURN ( __MKSMALLINT(ERROR_ERROR_SHARING_VIOLATION) ); |
6277 | 2069 |
} |
2070 |
#endif |
|
2071 |
#ifdef ERROR_LOCK_VIOLATION |
|
2072 |
if (sym == @symbol(ERROR_LOCK_VIOLATION)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2073 |
RETURN ( __MKSMALLINT(ERROR_LOCK_VIOLATION) ); |
6277 | 2074 |
} |
2075 |
#endif |
|
2076 |
#ifdef ERROR_INVALID_PARAMETER |
|
2077 |
if (sym == @symbol(ERROR_INVALID_PARAMETER)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2078 |
RETURN ( __MKSMALLINT(ERROR_INVALID_PARAMETER) ); |
6277 | 2079 |
} |
2080 |
#endif |
|
2081 |
#ifdef ERROR_NET_WRITE_FAULT |
|
2082 |
if (sym == @symbol(ERROR_NET_WRITE_FAULT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2083 |
RETURN ( __MKSMALLINT(ERROR_NET_WRITE_FAULT) ); |
6277 | 2084 |
} |
2085 |
#endif |
|
2086 |
#ifdef ERROR_NOT_SUPPORTED |
|
2087 |
if (sym == @symbol(ERROR_NOT_SUPPORTED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2088 |
RETURN ( __MKSMALLINT(ERROR_NOT_SUPPORTED) ); |
6277 | 2089 |
} |
2090 |
#endif |
|
2091 |
#ifdef ERROR_REM_NOT_LIST |
|
2092 |
if (sym == @symbol(ERROR_REM_NOT_LIST)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2093 |
RETURN ( __MKSMALLINT(ERROR_REM_NOT_LIST) ); |
6277 | 2094 |
} |
2095 |
#endif |
|
2096 |
#ifdef ERROR_NETWORK_ACCESS_DENIED |
|
2097 |
if (sym == @symbol(ERROR_NETWORK_ACCESS_DENIED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2098 |
RETURN ( __MKSMALLINT(ERROR_NETWORK_ACCESS_DENIED) ); |
6277 | 2099 |
} |
2100 |
#endif |
|
2101 |
#ifdef ERROR_DUP_NAME |
|
2102 |
if (sym == @symbol(ERROR_DUP_NAME)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2103 |
RETURN ( __MKSMALLINT(ERROR_DUP_NAME) ); |
6277 | 2104 |
} |
2105 |
#endif |
|
2106 |
#ifdef ERROR_BAD_NETPATH |
|
2107 |
if (sym == @symbol(ERROR_BAD_NETPATH)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2108 |
RETURN ( __MKSMALLINT(ERROR_BAD_NETPATH) ); |
6277 | 2109 |
} |
2110 |
#endif |
|
2111 |
#ifdef ERROR_NETWORK_BUSY |
|
2112 |
if (sym == @symbol(ERROR_NETWORK_BUSY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2113 |
RETURN ( __MKSMALLINT(ERROR_NETWORK_BUSY) ); |
6277 | 2114 |
} |
2115 |
#endif |
|
2116 |
#ifdef ERROR_DRIVE_LOCKED |
|
2117 |
if (sym == @symbol(ERROR_DRIVE_LOCKED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2118 |
RETURN ( __MKSMALLINT(ERROR_DRIVE_LOCKED) ); |
6277 | 2119 |
} |
2120 |
#endif |
|
2121 |
#ifdef ERROR_INVALID_DRIVE |
|
2122 |
if (sym == @symbol(ERROR_INVALID_DRIVE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2123 |
RETURN ( __MKSMALLINT(ERROR_INVALID_DRIVE) ); |
6277 | 2124 |
} |
2125 |
#endif |
|
2126 |
#ifdef ERROR_WRONG_DISK |
|
2127 |
if (sym == @symbol(ERROR_WRONG_DISK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2128 |
RETURN ( __MKSMALLINT(ERROR_WRONG_DISK) ); |
6277 | 2129 |
} |
2130 |
#endif |
|
2131 |
#ifdef ERROR_CURRENT_DIRECTORY |
|
2132 |
if (sym == @symbol(ERROR_CURRENT_DIRECTORY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2133 |
RETURN ( __MKSMALLINT(ERROR_CURRENT_DIRECTORY) ); |
6277 | 2134 |
} |
2135 |
#endif |
|
2136 |
#ifdef ERROR_CANNOT_MAKE |
|
2137 |
if (sym == @symbol(ERROR_CANNOT_MAKE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2138 |
RETURN ( __MKSMALLINT(ERROR_CANNOT_MAKE) ); |
6277 | 2139 |
} |
2140 |
#endif |
|
2141 |
#ifdef ERROR_NO_MORE_FILES |
|
2142 |
if (sym == @symbol(ERROR_NO_MORE_FILES)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2143 |
RETURN ( __MKSMALLINT(ERROR_NO_MORE_FILES) ); |
6277 | 2144 |
} |
2145 |
#endif |
|
2146 |
#ifdef ERROR_NOT_READY |
|
2147 |
if (sym == @symbol(ERROR_NOT_READY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2148 |
RETURN ( __MKSMALLINT(ERROR_NOT_READY) ); |
6277 | 2149 |
} |
2150 |
#endif |
|
2151 |
#ifdef ERROR_NOT_DOS_DISK |
|
2152 |
if (sym == @symbol(ERROR_NOT_DOS_DISK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2153 |
RETURN ( __MKSMALLINT(ERROR_NOT_DOS_DISK) ); |
6277 | 2154 |
} |
2155 |
#endif |
|
2156 |
#ifdef ERROR_OUT_OF_PAPER |
|
2157 |
if (sym == @symbol(ERROR_OUT_OF_PAPER)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2158 |
RETURN ( __MKSMALLINT(ERROR_OUT_OF_PAPER) ); |
6277 | 2159 |
} |
2160 |
#endif |
|
2161 |
#ifdef ERROR_PRINTQ_FULL |
|
2162 |
if (sym == @symbol(ERROR_PRINTQ_FULL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2163 |
RETURN ( __MKSMALLINT(ERROR_PRINTQ_FULL) ); |
6277 | 2164 |
} |
2165 |
#endif |
|
2166 |
||
2167 |
/* |
|
5133 | 2168 |
* POSIX errnos - these should be defined |
2169 |
*/ |
|
2170 |
#ifdef EPERM |
|
2171 |
if (sym == @symbol(EPERM)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2172 |
RETURN ( __MKSMALLINT(EPERM) ); |
5133 | 2173 |
} |
2174 |
#endif |
|
2175 |
||
2176 |
#ifdef ENOENT |
|
2177 |
if (sym == @symbol(ENOENT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2178 |
RETURN ( __MKSMALLINT(ENOENT) ); |
5133 | 2179 |
} |
2180 |
#endif |
|
2181 |
||
2182 |
#ifdef ESRCH |
|
2183 |
if (sym == @symbol(ESRCH)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2184 |
RETURN ( __MKSMALLINT(ESRCH) ); |
5133 | 2185 |
} |
2186 |
#endif |
|
2187 |
||
2188 |
#ifdef EINTR |
|
2189 |
if (sym == @symbol(EINTR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2190 |
RETURN ( __MKSMALLINT(EINTR) ); |
5133 | 2191 |
} |
2192 |
#endif |
|
2193 |
||
2194 |
#ifdef EIO |
|
2195 |
if (sym == @symbol(EIO)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2196 |
RETURN ( __MKSMALLINT(EIO) ); |
5133 | 2197 |
} |
2198 |
#endif |
|
2199 |
||
2200 |
#ifdef ENXIO |
|
2201 |
if (sym == @symbol(ENXIO)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2202 |
RETURN ( __MKSMALLINT(ENXIO) ); |
5133 | 2203 |
} |
2204 |
#endif |
|
2205 |
||
2206 |
#ifdef E2BIG |
|
2207 |
if (sym == @symbol(E2BIG)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2208 |
RETURN ( __MKSMALLINT(E2BIG) ); |
5133 | 2209 |
} |
2210 |
#endif |
|
2211 |
||
2212 |
#ifdef ENOEXEC |
|
2213 |
if (sym == @symbol(ENOEXEC)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2214 |
RETURN ( __MKSMALLINT(ENOEXEC) ); |
5133 | 2215 |
} |
2216 |
#endif |
|
2217 |
||
2218 |
#ifdef EBADF |
|
2219 |
if (sym == @symbol(EBADF)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2220 |
RETURN ( __MKSMALLINT(EBADF) ); |
5133 | 2221 |
} |
2222 |
#endif |
|
2223 |
||
2224 |
#ifdef ECHILD |
|
2225 |
if (sym == @symbol(ECHILD)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2226 |
RETURN ( __MKSMALLINT(ECHILD) ); |
5133 | 2227 |
} |
2228 |
#endif |
|
2229 |
||
2230 |
#if defined(EAGAIN) |
|
2231 |
if (sym == @symbol(EAGAIN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2232 |
RETURN ( __MKSMALLINT(EAGAIN) ); |
5133 | 2233 |
} |
2234 |
#endif |
|
2235 |
||
2236 |
#ifdef ENOMEM |
|
2237 |
if (sym == @symbol(ENOMEM)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2238 |
RETURN ( __MKSMALLINT(ENOMEM) ); |
5133 | 2239 |
} |
2240 |
#endif |
|
2241 |
||
2242 |
#ifdef EACCES |
|
2243 |
if (sym == @symbol(EACCES)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2244 |
RETURN ( __MKSMALLINT(EACCES) ); |
5133 | 2245 |
} |
2246 |
#endif |
|
2247 |
||
2248 |
#ifdef EFAULT |
|
2249 |
if (sym == @symbol(EFAULT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2250 |
RETURN ( __MKSMALLINT(EFAULT) ); |
5133 | 2251 |
} |
2252 |
#endif |
|
2253 |
||
2254 |
#ifdef EBUSY |
|
2255 |
if (sym == @symbol(EBUSY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2256 |
RETURN ( __MKSMALLINT(EBUSY) ); |
5133 | 2257 |
} |
2258 |
#endif |
|
2259 |
||
2260 |
#ifdef EXDEV |
|
2261 |
if (sym == @symbol(EXDEV)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2262 |
RETURN ( __MKSMALLINT(EXDEV) ); |
5133 | 2263 |
} |
2264 |
#endif |
|
2265 |
||
2266 |
#ifdef ENODEV |
|
2267 |
if (sym == @symbol(ENODEV)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2268 |
RETURN ( __MKSMALLINT(ENODEV) ); |
5133 | 2269 |
} |
2270 |
#endif |
|
2271 |
||
2272 |
#ifdef ENOTDIR |
|
2273 |
if (sym == @symbol(ENOTDIR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2274 |
RETURN ( __MKSMALLINT(ENOTDIR) ); |
5133 | 2275 |
} |
2276 |
#endif |
|
2277 |
||
2278 |
#ifdef EISDIR |
|
2279 |
if (sym == @symbol(EISDIR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2280 |
RETURN ( __MKSMALLINT(EISDIR) ); |
5133 | 2281 |
} |
2282 |
#endif |
|
2283 |
||
2284 |
#ifdef EINVAL |
|
2285 |
if (sym == @symbol(EINVAL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2286 |
RETURN ( __MKSMALLINT(EINVAL) ); |
5133 | 2287 |
} |
2288 |
#endif |
|
2289 |
||
2290 |
#ifdef ENFILE |
|
2291 |
if (sym == @symbol(ENFILE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2292 |
RETURN ( __MKSMALLINT(ENFILE) ); |
5133 | 2293 |
} |
2294 |
#endif |
|
2295 |
||
2296 |
#ifdef EMFILE |
|
2297 |
if (sym == @symbol(EMFILE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2298 |
RETURN ( __MKSMALLINT(EMFILE) ); |
5133 | 2299 |
} |
2300 |
#endif |
|
2301 |
||
2302 |
#ifdef ENOTTY |
|
2303 |
if (sym == @symbol(ENOTTY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2304 |
RETURN ( __MKSMALLINT(ENOTTY) ); |
5133 | 2305 |
} |
2306 |
#endif |
|
2307 |
||
2308 |
#ifdef EFBIG |
|
2309 |
if (sym == @symbol(EFBIG)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2310 |
RETURN ( __MKSMALLINT(EFBIG) ); |
5133 | 2311 |
} |
2312 |
#endif |
|
2313 |
||
2314 |
#ifdef ENOSPC |
|
2315 |
if (sym == @symbol(ENOSPC)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2316 |
RETURN ( __MKSMALLINT(ENOSPC) ); |
5133 | 2317 |
} |
2318 |
#endif |
|
2319 |
||
2320 |
#ifdef ESPIPE |
|
2321 |
if (sym == @symbol(ESPIPE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2322 |
RETURN ( __MKSMALLINT(ESPIPE) ); |
5133 | 2323 |
} |
2324 |
#endif |
|
2325 |
||
2326 |
#ifdef EROFS |
|
2327 |
if (sym == @symbol(EROFS)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2328 |
RETURN ( __MKSMALLINT(EROFS) ); |
5133 | 2329 |
} |
2330 |
#endif |
|
2331 |
||
2332 |
#ifdef EMLINK |
|
2333 |
if (sym == @symbol(EMLINK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2334 |
RETURN ( __MKSMALLINT(EMLINK) ); |
5133 | 2335 |
} |
2336 |
#endif |
|
2337 |
||
2338 |
#ifdef EPIPE |
|
2339 |
if (sym == @symbol(EPIPE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2340 |
RETURN ( __MKSMALLINT(EPIPE) ); |
5133 | 2341 |
} |
2342 |
#endif |
|
2343 |
||
2344 |
#ifdef EDOM |
|
2345 |
if (sym == @symbol(EDOM)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2346 |
RETURN ( __MKSMALLINT(EDOM) ); |
5133 | 2347 |
} |
2348 |
#endif |
|
2349 |
||
2350 |
#ifdef ERANGE |
|
2351 |
if (sym == @symbol(ERANGE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2352 |
RETURN ( __MKSMALLINT(ERANGE) ); |
5133 | 2353 |
} |
2354 |
#endif |
|
2355 |
||
2356 |
#ifdef EDEADLK |
|
2357 |
if (sym == @symbol(EDEADLK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2358 |
RETURN ( __MKSMALLINT(EDEADLK) ); |
5133 | 2359 |
} |
2360 |
#endif |
|
2361 |
||
2362 |
#ifdef ENAMETOOLONG |
|
2363 |
if (sym == @symbol(ENAMETOOLONG)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2364 |
RETURN ( __MKSMALLINT(ENAMETOOLONG) ); |
5133 | 2365 |
} |
2366 |
#endif |
|
2367 |
||
2368 |
#ifdef ENOLCK |
|
2369 |
if (sym == @symbol(ENOLCK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2370 |
RETURN ( __MKSMALLINT(ENOLCK) ); |
5133 | 2371 |
} |
2372 |
#endif |
|
2373 |
||
2374 |
#ifdef ENOSYS |
|
2375 |
if (sym == @symbol(ENOSYS)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2376 |
RETURN ( __MKSMALLINT(ENOSYS) ); |
5133 | 2377 |
} |
2378 |
#endif |
|
2379 |
||
2380 |
#ifdef ENOTEMPTY |
|
2381 |
if (sym == @symbol(ENOTEMPTY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2382 |
RETURN ( __MKSMALLINT(ENOTEMPTY) ); |
5133 | 2383 |
} |
2384 |
#endif |
|
2385 |
||
2386 |
#ifdef EEXIST |
|
2387 |
if (sym == @symbol(EEXIST)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2388 |
RETURN ( __MKSMALLINT(EEXIST) ); |
5133 | 2389 |
} |
2390 |
#endif |
|
2391 |
||
2392 |
#ifdef EILSEQ |
|
2393 |
if (sym == @symbol(EILSEQ)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2394 |
RETURN ( __MKSMALLINT(EILSEQ) ); |
5133 | 2395 |
} |
2396 |
#endif |
|
2397 |
||
2398 |
/* |
|
2399 |
* XPG3 errnos - defined on most systems |
|
2400 |
*/ |
|
2401 |
#ifdef ENOTBLK |
|
2402 |
if (sym == @symbol(ENOTBLK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2403 |
RETURN ( __MKSMALLINT(ENOTBLK) ); |
5133 | 2404 |
} |
2405 |
#endif |
|
2406 |
||
2407 |
#ifdef ETXTBSY |
|
2408 |
if (sym == @symbol(ETXTBSY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2409 |
RETURN ( __MKSMALLINT(ETXTBSY) ); |
5133 | 2410 |
} |
2411 |
#endif |
|
2412 |
||
2413 |
/* |
|
2414 |
* some others |
|
2415 |
*/ |
|
2416 |
#ifdef EWOULDBLOCK |
|
2417 |
if (sym == @symbol(EWOULDBLOCK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2418 |
RETURN ( __MKSMALLINT(EWOULDBLOCK) ); |
5133 | 2419 |
} |
2420 |
#endif |
|
2421 |
||
2422 |
#ifdef ENOMSG |
|
2423 |
if (sym == @symbol(ENOMSG)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2424 |
RETURN ( __MKSMALLINT(ENOMSG) ); |
5133 | 2425 |
} |
2426 |
#endif |
|
2427 |
||
2428 |
#ifdef ELOOP |
|
2429 |
if (sym == @symbol(ELOOP)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2430 |
RETURN ( __MKSMALLINT(ELOOP) ); |
5133 | 2431 |
} |
2432 |
#endif |
|
2433 |
||
2434 |
/* |
|
2435 |
* some stream errors |
|
2436 |
*/ |
|
2437 |
#ifdef ETIME |
|
2438 |
if (sym == @symbol(ETIME)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2439 |
RETURN ( __MKSMALLINT(ETIME) ); |
5133 | 2440 |
} |
2441 |
#endif |
|
2442 |
||
2443 |
#ifdef ENOSR |
|
2444 |
if (sym == @symbol(ENOSR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2445 |
RETURN ( __MKSMALLINT(ENOSR) ); |
5133 | 2446 |
} |
2447 |
#endif |
|
2448 |
||
2449 |
#ifdef ENOSTR |
|
2450 |
if (sym == @symbol(ENOSTR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2451 |
RETURN ( __MKSMALLINT(ENOSTR) ); |
5133 | 2452 |
} |
2453 |
#endif |
|
2454 |
||
2455 |
#ifdef ECOMM |
|
2456 |
if (sym == @symbol(ECOMM)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2457 |
RETURN ( __MKSMALLINT(ECOMM) ); |
5133 | 2458 |
} |
2459 |
#endif |
|
2460 |
||
2461 |
#ifdef EPROTO |
|
2462 |
if (sym == @symbol(EPROTO)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2463 |
RETURN ( __MKSMALLINT(EPROTO) ); |
5133 | 2464 |
} |
2465 |
#endif |
|
2466 |
||
2467 |
/* |
|
2468 |
* nfs errors |
|
2469 |
*/ |
|
2470 |
#ifdef ESTALE |
|
2471 |
if (sym == @symbol(ESTALE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2472 |
RETURN ( __MKSMALLINT(ESTALE) ); |
5133 | 2473 |
} |
2474 |
#endif |
|
2475 |
||
2476 |
#ifdef EREMOTE |
|
2477 |
if (sym == @symbol(EREMOTE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2478 |
RETURN ( __MKSMALLINT(EREMOTE) ); |
5133 | 2479 |
} |
2480 |
#endif |
|
2481 |
||
2482 |
/* |
|
2483 |
* some networking errors |
|
2484 |
*/ |
|
2485 |
#ifdef EINPROGRESS |
|
2486 |
if (sym == @symbol(EINPROGRESS)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2487 |
RETURN ( __MKSMALLINT(EINPROGRESS) ); |
5133 | 2488 |
} |
2489 |
#endif |
|
2490 |
||
2491 |
#ifdef EALREADY |
|
2492 |
if (sym == @symbol(EALREADY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2493 |
RETURN ( __MKSMALLINT(EALREADY) ); |
5133 | 2494 |
} |
2495 |
#endif |
|
2496 |
||
2497 |
#ifdef ENOTSOCK |
|
2498 |
if (sym == @symbol(ENOTSOCK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2499 |
RETURN ( __MKSMALLINT(ENOTSOCK) ); |
5133 | 2500 |
} |
2501 |
#endif |
|
2502 |
||
2503 |
#ifdef EDESTADDRREQ |
|
2504 |
if (sym == @symbol(EDESTADDRREQ)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2505 |
RETURN ( __MKSMALLINT(EDESTADDRREQ) ); |
5133 | 2506 |
} |
2507 |
#endif |
|
2508 |
||
2509 |
#ifdef EMSGSIZE |
|
2510 |
if (sym == @symbol(EMSGSIZE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2511 |
RETURN ( __MKSMALLINT(EMSGSIZE) ); |
5133 | 2512 |
} |
2513 |
#endif |
|
2514 |
||
2515 |
#ifdef EPROTOTYPE |
|
2516 |
if (sym == @symbol(EPROTOTYPE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2517 |
RETURN ( __MKSMALLINT(EPROTOTYPE) ); |
5133 | 2518 |
} |
2519 |
#endif |
|
2520 |
||
2521 |
#ifdef ENOPROTOOPT |
|
2522 |
if (sym == @symbol(ENOPROTOOPT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2523 |
RETURN ( __MKSMALLINT(ENOPROTOOPT) ); |
5133 | 2524 |
} |
2525 |
#endif |
|
2526 |
||
2527 |
#ifdef EPROTONOSUPPORT |
|
2528 |
if (sym == @symbol(EPROTONOSUPPORT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2529 |
RETURN ( __MKSMALLINT(EPROTONOSUPPORT) ); |
5133 | 2530 |
} |
2531 |
#endif |
|
2532 |
||
2533 |
#ifdef ESOCKTNOSUPPORT |
|
2534 |
if (sym == @symbol(ESOCKTNOSUPPORT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2535 |
RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) ); |
5133 | 2536 |
} |
2537 |
#endif |
|
2538 |
||
2539 |
#ifdef EOPNOTSUPP |
|
2540 |
if (sym == @symbol(EOPNOTSUPP)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2541 |
RETURN ( __MKSMALLINT(EOPNOTSUPP) ); |
5133 | 2542 |
} |
2543 |
#endif |
|
2544 |
||
2545 |
#ifdef EPFNOSUPPORT |
|
2546 |
if (sym == @symbol(EPFNOSUPPORT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2547 |
RETURN ( __MKSMALLINT(EPFNOSUPPORT) ); |
5133 | 2548 |
} |
2549 |
#endif |
|
2550 |
||
2551 |
#ifdef EAFNOSUPPORT |
|
2552 |
if (sym == @symbol(EAFNOSUPPORT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2553 |
RETURN ( __MKSMALLINT(EAFNOSUPPORT) ); |
5133 | 2554 |
} |
2555 |
#endif |
|
2556 |
||
2557 |
#ifdef EADDRINUSE |
|
2558 |
if (sym == @symbol(EADDRINUSE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2559 |
RETURN ( __MKSMALLINT(EADDRINUSE) ); |
5133 | 2560 |
} |
2561 |
#endif |
|
2562 |
||
2563 |
#ifdef EADDRNOTAVAIL |
|
2564 |
if (sym == @symbol(EADDRNOTAVAIL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2565 |
RETURN ( __MKSMALLINT(EADDRNOTAVAIL) ); |
5133 | 2566 |
} |
2567 |
#endif |
|
2568 |
||
2569 |
#ifdef ETIMEDOUT |
|
2570 |
if (sym == @symbol(ETIMEDOUT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2571 |
RETURN ( __MKSMALLINT(ETIMEDOUT) ); |
5133 | 2572 |
} |
2573 |
#endif |
|
2574 |
||
2575 |
#ifdef ECONNREFUSED |
|
2576 |
if (sym == @symbol(ECONNREFUSED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2577 |
RETURN ( __MKSMALLINT(ECONNREFUSED) ); |
5133 | 2578 |
} |
2579 |
#endif |
|
2580 |
||
2581 |
#ifdef ENETDOWN |
|
2582 |
if (sym == @symbol(ENETDOWN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2583 |
RETURN ( __MKSMALLINT(ENETDOWN) ); |
5133 | 2584 |
} |
2585 |
#endif |
|
2586 |
||
2587 |
#ifdef ENETUNREACH |
|
2588 |
if (sym == @symbol(ENETUNREACH)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2589 |
RETURN ( __MKSMALLINT(ENETUNREACH) ); |
5133 | 2590 |
} |
2591 |
#endif |
|
2592 |
||
2593 |
#ifdef ENETRESET |
|
2594 |
if (sym == @symbol(ENETRESET)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2595 |
RETURN ( __MKSMALLINT(ENETRESET) ); |
5133 | 2596 |
} |
2597 |
#endif |
|
2598 |
||
2599 |
#ifdef ECONNABORTED |
|
2600 |
if (sym == @symbol(ECONNABORTED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2601 |
RETURN ( __MKSMALLINT(ECONNABORTED) ); |
5133 | 2602 |
} |
2603 |
#endif |
|
2604 |
||
2605 |
#ifdef ECONNRESET |
|
2606 |
if (sym == @symbol(ECONNRESET)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2607 |
RETURN ( __MKSMALLINT(ECONNRESET) ); |
5133 | 2608 |
} |
2609 |
#endif |
|
2610 |
||
2611 |
#ifdef EISCONN |
|
2612 |
if (sym == @symbol(EISCONN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2613 |
RETURN ( __MKSMALLINT(EISCONN) ); |
5133 | 2614 |
} |
2615 |
#endif |
|
2616 |
||
2617 |
#ifdef ENOTCONN |
|
2618 |
if (sym == @symbol(ENOTCONN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2619 |
RETURN ( __MKSMALLINT(ENOTCONN) ); |
5133 | 2620 |
} |
2621 |
#endif |
|
2622 |
||
2623 |
#ifdef ESHUTDOWN |
|
2624 |
if (sym == @symbol(ESHUTDOWN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2625 |
RETURN ( __MKSMALLINT(ESHUTDOWN) ); |
5133 | 2626 |
} |
2627 |
#endif |
|
2628 |
||
2629 |
#ifdef EHOSTDOWN |
|
2630 |
if (sym == @symbol(EHOSTDOWN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2631 |
RETURN ( __MKSMALLINT(EHOSTDOWN) ); |
5133 | 2632 |
} |
2633 |
#endif |
|
2634 |
||
2635 |
#ifdef EHOSTUNREACH |
|
2636 |
if (sym == @symbol(EHOSTUNREACH)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2637 |
RETURN ( __MKSMALLINT(EHOSTUNREACH) ); |
5133 | 2638 |
} |
2639 |
#endif |
|
2640 |
%}. |
|
2641 |
^ -1 |
|
2642 |
! ! |
|
2643 |
||
2644 |
!Win32OperatingSystem class methodsFor:'executing OS commands'! |
|
2645 |
||
7066 | 2646 |
canExecuteCommand:aCommandString |
2647 |
"return true, if the OS can execute aCommand." |
|
2648 |
||
2649 |
|fn| |
|
2650 |
||
2651 |
fn := aCommandString asFilename. |
|
2652 |
( #('com' 'exe') includes:fn suffix) ifFalse:[^ false]. |
|
2653 |
^ super canExecuteCommand:aCommandString |
|
2654 |
||
2655 |
" |
|
2656 |
OperatingSystem canExecuteCommand:'fooBar' |
|
2657 |
OperatingSystem canExecuteCommand:'ls' |
|
2658 |
OperatingSystem canExecuteCommand:'cvs' |
|
2659 |
OperatingSystem canExecuteCommand:'cvs.exe' |
|
2660 |
OperatingSystem canExecuteCommand:'C:\Dokumente und Einstellungen\penk\work\stx\projects\smalltalk\cvs.exe' |
|
2661 |
OperatingSystem canExecuteCommand:'C:\Windows\cvs.exe' |
|
2662 |
" |
|
2663 |
||
2664 |
"Created: 4.11.1995 / 19:13:54 / cg" |
|
2665 |
! |
|
2666 |
||
5133 | 2667 |
commandAndArgsForOSCommand:aCommandString |
2668 |
"get a shell and shell arguments for command execution" |
|
2669 |
||
2670 |
|shell args wDir path words hasRedirection| |
|
2671 |
||
2672 |
"/ |
|
2673 |
"/ 'x:\WINNT\System32\cmd /c <command>' |
|
2674 |
"/ or 'x:\WINDOWS\System32\cmd /c <command>' |
|
2675 |
"/ or 'x:\WINDOWS\System\cmd /c <command>' |
|
2676 |
"/ or whatever ... |
|
2677 |
"/ |
|
2678 |
||
2679 |
"/ to workaround a bug in win95's command.com |
|
2680 |
"/ (which always returns a 0-exit code |
|
2681 |
"/ - even if the command failed), |
|
2682 |
"/ Here, we see if the command is found along the path and |
|
2683 |
"/ call it directly if found. |
|
2684 |
"/ If not found, assume its a builtIn or batch command |
|
2685 |
"/ and pass it to command.com. |
|
2686 |
"/ Also use command.com, if any I/O redirection is |
|
2687 |
"/ involved, since that is (not yet) handled here. |
|
2688 |
"/ |
|
2689 |
"/ I know: this is a kludge but should work for now... |
|
2690 |
"/ ...this will change in an upcoming version to include |
|
2691 |
"/ command.com command-line parsing here (sigh). |
|
2692 |
||
7065 | 2693 |
hasRedirection := false. |
2694 |
(aCommandString isNil or:[aCommandString includesAny:'<>|']) ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2695 |
hasRedirection := true |
7065 | 2696 |
]. |
2697 |
||
7062 | 2698 |
self isMSWINDOWSNTlike ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2699 |
shell := self getEnvironment:'COMSPEC'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2700 |
shell isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2701 |
wDir := self getWindowsSystemDirectory asFilename. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2702 |
shell := (wDir construct:'cmd.exe'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2703 |
shell exists ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2704 |
shell := (wDir construct:'command.com'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2705 |
shell exists ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2706 |
self error:'no command.com available'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2707 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2708 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2709 |
shell := shell pathName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2710 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2711 |
aCommandString isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2712 |
^ Array with:nil with:shell |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2713 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2714 |
^ Array with:nil with:(shell , ' /c ' , aCommandString) |
5133 | 2715 |
]. |
2716 |
||
7065 | 2717 |
"/ I/O redirection is not yet handled directly |
2718 |
"/ fallBack to command.com (below) to do it. |
|
2719 |
||
2720 |
hasRedirection ifFalse:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2721 |
words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2722 |
args := ' '. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2723 |
words from:2 to:(words size) do:[:s | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2724 |
args := args , (s , ' '). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2725 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2726 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2727 |
path := self pathOfCommand:(words at:1). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2728 |
path notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2729 |
"/ execute the command directly - |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2730 |
"/ without going through command.com |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2731 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2732 |
self isMSWINDOWSNTlike ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2733 |
args := path , args. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2734 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2735 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2736 |
^ Array with:path with:args |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2737 |
]. |
5133 | 2738 |
]. |
2739 |
||
2740 |
"/ windows-NT (where command.com works) |
|
2741 |
"/ or I/O redirection or no executable was found |
|
2742 |
||
2743 |
shell := self getEnvironment:'COMSPEC'. |
|
2744 |
shell isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2745 |
wDir := self getWindowsSystemDirectory asFilename. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2746 |
shell := (wDir construct:'cmd.exe'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2747 |
shell exists ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2748 |
shell := (wDir construct:'command.com'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2749 |
shell exists ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2750 |
self error:'no command.com available'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2751 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2752 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2753 |
shell := shell pathName. |
5133 | 2754 |
]. |
2755 |
aCommandString isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2756 |
^ Array with:shell with:shell |
5133 | 2757 |
]. |
2758 |
^ Array with:shell with:(shell , ' /c ' , aCommandString) |
|
2759 |
||
2760 |
"Modified: / 20.1.1998 / 16:57:19 / md" |
|
2761 |
"Modified: / 19.5.1999 / 10:01:24 / cg" |
|
2762 |
! |
|
2763 |
||
7080
a82683bc1843
Cleanup closeDescriptor handling in exec:withArguments:...
Stefan Vogel <sv@exept.de>
parents:
7077
diff
changeset
|
2764 |
exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inDirectory:aDirectory |
7062 | 2765 |
"Internal lowLevel entry for combined fork & exec for WIN32 |
2766 |
||
2767 |
If fork is false (chain a command): |
|
7852 | 2768 |
execute the OS command specified by the argument, aCommandPath, with |
2769 |
arguments in argArray (no arguments, if nil). |
|
2770 |
If successful, this method does not return and smalltalk is gone. |
|
2771 |
If not successful, it does return. |
|
2772 |
Normal use is with forkForCommand. |
|
7062 | 2773 |
|
2774 |
If fork is true (subprocess command execution): |
|
7852 | 2775 |
fork a child to do the above. |
2776 |
The process id of the child process is returned; nil if the fork failed. |
|
7062 | 2777 |
|
2778 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
|
7852 | 2779 |
fdArray[1] = 15 -> use fd 15 as stdin. |
2780 |
If an element of the array is set to nil, the corresponding filedescriptor |
|
2781 |
will be closed for the child. |
|
2782 |
fdArray[0] == StdIn for child |
|
2783 |
fdArray[1] == StdOut for child |
|
2784 |
fdArray[2] == StdErr for child |
|
2785 |
on VMS, these must be channels as returned by createMailBox. |
|
7062 | 2786 |
|
2787 |
NOTE that in WIN32 the fds are HANDLES. |
|
2788 |
||
2789 |
If newPgrp is true, the subprocess will be established in a new process group. |
|
7852 | 2790 |
The processgroup will be equal to id. |
2791 |
newPgrp is not used on WIN32 and VMS systems." |
|
7638 | 2792 |
|
2793 |
|dirPath cmdPath cmdLine rslt| |
|
7062 | 2794 |
|
2795 |
aDirectory notNil ifTrue:[ |
|
7852 | 2796 |
dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory. |
2797 |
(dirPath endsWith:':') ifTrue:[ |
|
2798 |
dirPath := dirPath , '\'. |
|
2799 |
]. |
|
7062 | 2800 |
]. |
2801 |
||
2802 |
self isMSWINDOWSNTlike ifTrue:[ |
|
7852 | 2803 |
cmdPath := aCommandPath. |
2804 |
cmdLine := argString |
|
7062 | 2805 |
] ifFalse:[ |
7852 | 2806 |
cmdPath := 'stxspawn.exe'. |
2807 |
cmdLine := 'stxspawn.exe ' , aCommandPath , ' ' , argString |
|
7062 | 2808 |
]. |
2809 |
||
7638 | 2810 |
rslt := self |
7852 | 2811 |
primExec:cmdPath |
2812 |
commandLine:cmdLine |
|
2813 |
fileDescriptors:fdArray |
|
2814 |
fork:doFork |
|
2815 |
newPgrp:newPgrp |
|
2816 |
inPath:dirPath |
|
2817 |
createFlags:nil. |
|
7841 | 2818 |
|
2819 |
"/ 'created ' print. cmdLine print. ' -> ' print. rslt printCR. |
|
7638 | 2820 |
^ rslt |
7062 | 2821 |
|
2822 |
"Modified: / 31.1.1998 / 10:54:24 / md" |
|
2823 |
"Modified: / 15.5.1999 / 18:07:51 / cg" |
|
2824 |
! |
|
2825 |
||
5133 | 2826 |
getStatusOfProcess:aProcessId |
2827 |
"wait for a process to terminate and fetch its exit status. |
|
2828 |
This is required to avoid zombie processes." |
|
2829 |
||
2830 |
%{ |
|
2831 |
DWORD endStatus; |
|
2832 |
int status = -1; |
|
2833 |
||
7662 | 2834 |
if (__isExternalAddressLike(aProcessId)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2835 |
HANDLE handle = _HANDLEVal(aProcessId); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2836 |
if (handle) { |
5133 | 2837 |
#ifdef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2838 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2839 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2840 |
endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, handle, INFINITE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2841 |
} while ((endStatus < 0) && (__threadErrno == EINTR)); |
5133 | 2842 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2843 |
endStatus = WaitForSingleObject(handle , INFINITE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2844 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2845 |
if (endStatus != WAIT_FAILED) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2846 |
if (GetExitCodeProcess(handle,&endStatus)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2847 |
status = endStatus; |
5133 | 2848 |
#ifdef PROCESSDEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2849 |
fprintf(stderr, "getexitcode status = %d\n",status); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2850 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2851 |
fprintf(stderr, "getexitcode failed.\n"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2852 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2853 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2854 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2855 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2856 |
RETURN ( __MKSMALLINT(status)); |
5133 | 2857 |
} |
2858 |
%}. |
|
2859 |
self primitiveFailed |
|
2860 |
! |
|
2861 |
||
2862 |
pathOfCommand:aCommand |
|
2863 |
"find where aCommand's executable file is; |
|
2864 |
return its full pathName if there is such a command, otherwise |
|
2865 |
return nil." |
|
2866 |
||
2867 |
|path f fExt| |
|
2868 |
||
2869 |
aCommand asFilename isAbsolute ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2870 |
aCommand asFilename exists ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2871 |
^ aCommand |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2872 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2873 |
^ nil |
5133 | 2874 |
]. |
2875 |
||
2876 |
path := self getEnvironment:'PATH'. |
|
2877 |
path notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2878 |
(path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2879 |
path isEmpty ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2880 |
f := aCommand asFilename |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2881 |
] ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2882 |
f := path asFilename construct:aCommand. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2883 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2884 |
self executableFileExtensions do:[:ext | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2885 |
ext notEmpty ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2886 |
fExt := (f pathName , '.' , ext) asFilename. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2887 |
] ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2888 |
fExt := f. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2889 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2890 |
fExt isExecutable ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2891 |
^ fExt pathName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2892 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2893 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2894 |
]. |
5133 | 2895 |
]. |
2896 |
^ nil |
|
2897 |
||
2898 |
"windows: |
|
2899 |
||
2900 |
OperatingSystem pathOfCommand:'bcc32' |
|
2901 |
" |
|
2902 |
||
2903 |
"Modified: / 10.9.1998 / 17:51:49 / cg" |
|
2904 |
! |
|
2905 |
||
7080
a82683bc1843
Cleanup closeDescriptor handling in exec:withArguments:...
Stefan Vogel <sv@exept.de>
parents:
7077
diff
changeset
|
2906 |
primExec:commandPath commandLine:commandLine fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inPath:dirName createFlags:flagsOrNil |
5133 | 2907 |
"Internal lowLevel entry for combined fork & exec for WIN32" |
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
2908 |
|
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
2909 |
|handle| |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
2910 |
|
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
2911 |
handle := Win32ProcessHandle new. |
5133 | 2912 |
%{ |
2913 |
||
2914 |
/* |
|
2915 |
* if fork is false, chain to another command (not yet supported) |
|
2916 |
* otherwise, spawn a subprocess and let it execute the command. |
|
2917 |
* Currently, only the forking version is supported (who chains anyway ?) |
|
2918 |
*/ |
|
2919 |
#if 0 |
|
2920 |
char fullCmdPathBuffer[1024]; |
|
2921 |
char fullCmdLine[1024]; |
|
2922 |
char fullDirName[1024]; |
|
2923 |
char *fullCmdPath = fullCmdPathBuffer; |
|
2924 |
#else |
|
2925 |
char *cmdPath = 0; |
|
2926 |
char *cmdLine = 0; |
|
2927 |
#endif |
|
2928 |
char *dir = 0; |
|
2929 |
DWORD fdwCreate = 0; |
|
2930 |
STARTUPINFO lpsiStartInfo; |
|
2931 |
PROCESS_INFORMATION lppiProcInfo; |
|
7070 | 2932 |
SECURITY_ATTRIBUTES sa; |
5133 | 2933 |
|
2934 |
if (__isString(dirName)) { |
|
7118 | 2935 |
dir = __stringVal(dirName); |
5133 | 2936 |
} |
2937 |
if ((__isString(commandPath) || (commandPath == nil)) |
|
2938 |
&& __isString(commandLine)) { |
|
2939 |
#if 0 |
|
7118 | 2940 |
/* |
2941 |
* generate command line (cmd plus args) |
|
2942 |
*/ |
|
2943 |
if (__isWinNT) { |
|
2944 |
char *d; |
|
2945 |
||
2946 |
strcpy(fullCmdPath, __stringVal(aCommandPath)); |
|
2947 |
d = strchr(fullCmdPath,' '); |
|
2948 |
if (d) { |
|
2949 |
*d++ = 0; |
|
2950 |
strcpy(fullCmdLine, d); |
|
2951 |
} else { |
|
2952 |
fullCmdLine[0] = '\0'; |
|
2953 |
} |
|
2954 |
} else { |
|
2955 |
//fullCmdPath = 0; |
|
2956 |
strcpy(fullCmdPath,"stxspawn.exe"); |
|
2957 |
strcpy(fullCmdLine,"stxspawn.exe "); |
|
2958 |
strcat(fullCmdLine, __stringVal(aCommandPath)); |
|
2959 |
} |
|
2960 |
||
2961 |
if (__isString(argArray)) { |
|
2962 |
if (strlen(fullCmdLine) > 0) { |
|
2963 |
strcat(fullCmdLine, " "); |
|
2964 |
} |
|
2965 |
strcat(fullCmdLine, __stringVal(argArray)); |
|
2966 |
} else { |
|
2967 |
int i; |
|
2968 |
||
2969 |
for (i=0; i<__arraySize(argArray); i++) { |
|
2970 |
OBJ arg = __ArrayInstPtr(argArray)->a_element[i]; |
|
2971 |
||
2972 |
if (__isString(arg)) { |
|
2973 |
strcat(fullCmdLine, " "); |
|
2974 |
strcat(fullCmdLine, __stringVal(arg)); |
|
2975 |
} else { |
|
2976 |
/* ignore */ |
|
2977 |
fprintf(stderr, "bad (non-string) arg\n"); |
|
2978 |
} |
|
2979 |
} |
|
2980 |
} |
|
2981 |
#endif |
|
2982 |
if (commandPath != nil) { |
|
2983 |
cmdPath = __stringVal(commandPath); |
|
2984 |
} |
|
2985 |
cmdLine = __stringVal(commandLine); |
|
2986 |
||
2987 |
/* |
|
2988 |
* create descriptors as req'd |
|
2989 |
*/ |
|
2990 |
sa.nLength = sizeof( sa ); |
|
2991 |
sa.lpSecurityDescriptor = NULL; |
|
2992 |
sa.bInheritHandle = TRUE; |
|
2993 |
||
2994 |
memset(&lppiProcInfo, 0, sizeof (lppiProcInfo)); |
|
2995 |
||
2996 |
memset(&lpsiStartInfo, 0, sizeof (lpsiStartInfo)); |
|
2997 |
lpsiStartInfo.cb = sizeof(lpsiStartInfo); |
|
2998 |
lpsiStartInfo.lpReserved = NULL; |
|
2999 |
lpsiStartInfo.lpDesktop = NULL; |
|
3000 |
lpsiStartInfo.lpTitle = NULL; |
|
3001 |
lpsiStartInfo.dwX = 0; |
|
3002 |
lpsiStartInfo.dwY = 0; |
|
3003 |
lpsiStartInfo.dwXSize = 100; |
|
3004 |
lpsiStartInfo.dwYSize = 100; |
|
3005 |
lpsiStartInfo.dwXCountChars = 0; |
|
3006 |
lpsiStartInfo.dwYCountChars = 0; |
|
3007 |
lpsiStartInfo.dwFillAttribute = 0; |
|
3008 |
if (0 /*__isWinNT*/) { |
|
3009 |
lpsiStartInfo.dwFlags = STARTF_USESTDHANDLES; |
|
3010 |
lpsiStartInfo.wShowWindow = SW_SHOWDEFAULT; |
|
3011 |
} else { |
|
3012 |
lpsiStartInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/; |
|
3013 |
lpsiStartInfo.wShowWindow = SW_HIDE /*SW_SHOWDEFAULT*/; |
|
3014 |
} |
|
3015 |
lpsiStartInfo.cbReserved2 = 0; |
|
3016 |
lpsiStartInfo.lpReserved2 = NULL; |
|
3017 |
lpsiStartInfo.hStdInput = NULL; |
|
3018 |
lpsiStartInfo.hStdOutput = NULL; |
|
3019 |
lpsiStartInfo.hStdError = NULL; |
|
3020 |
||
3021 |
/* |
|
3022 |
* set create process flags |
|
3023 |
* if the flags arg is nil, use common defaults; |
|
3024 |
* if non-nil, it must be a positive integer containing the fdwCreate bits. |
|
3025 |
*/ |
|
3026 |
if (flagsOrNil != nil) { |
|
3027 |
fdwCreate = __longIntVal(flagsOrNil); |
|
3028 |
} else { |
|
3029 |
if (0 /* __isWinNT */) |
|
3030 |
fdwCreate = 0; //IDLE_PRIORITY_CLASS; |
|
3031 |
else |
|
3032 |
fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ; |
|
3033 |
||
3034 |
if (newPgrp == true) { |
|
3035 |
fdwCreate |= CREATE_NEW_PROCESS_GROUP; |
|
3036 |
} |
|
3037 |
} |
|
3038 |
||
3039 |
if (fdArray == nil) { |
|
3040 |
lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (0); |
|
3041 |
lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (1); |
|
3042 |
lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (2); |
|
3043 |
} else if (__isArray(fdArray) && (__arraySize(fdArray) >= 3)) { |
|
3044 |
if (__ArrayInstPtr(fdArray)->a_element[0] != nil) { |
|
7662 | 3045 |
if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[0])) { |
7118 | 3046 |
lpsiStartInfo.hStdInput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]); |
3047 |
} else { |
|
3048 |
lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0])); |
|
3049 |
} |
|
3050 |
} |
|
3051 |
if (__ArrayInstPtr(fdArray)->a_element[1] != nil) { |
|
7662 | 3052 |
if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[1])) { |
7118 | 3053 |
lpsiStartInfo.hStdOutput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]); |
3054 |
} else { |
|
3055 |
lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1])); |
|
3056 |
} |
|
3057 |
} |
|
3058 |
if (__ArrayInstPtr(fdArray)->a_element[2] != nil) { |
|
7662 | 3059 |
if (__isExternalAddressLike(__ArrayInstPtr(fdArray)->a_element[2])) { |
7118 | 3060 |
lpsiStartInfo.hStdError = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]); |
3061 |
} else { |
|
3062 |
lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2])); |
|
3063 |
} |
|
3064 |
} |
|
5133 | 3065 |
#ifdef PROCESSDEBUGWIN32 |
7118 | 3066 |
fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput); |
3067 |
fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput); |
|
3068 |
fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError); |
|
3069 |
#endif |
|
3070 |
} else { |
|
3071 |
fprintf(stderr, "Win32OS: bad fd arg in createProcess\n"); |
|
3072 |
} |
|
3073 |
||
3074 |
if (doFork == true) { |
|
5133 | 3075 |
#ifdef PROCESSDEBUGWIN32 |
7118 | 3076 |
fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir); |
3077 |
#endif |
|
3078 |
if (CreateProcess( cmdPath, |
|
3079 |
cmdLine, |
|
3080 |
&sa, &sa, /* sec-attribs */ |
|
3081 |
sa.bInheritHandle, /* inherit handles */ |
|
3082 |
fdwCreate, |
|
3083 |
NULL, /* env */ |
|
3084 |
dir, |
|
3085 |
&lpsiStartInfo, |
|
3086 |
&lppiProcInfo )) |
|
3087 |
{ |
|
3088 |
CloseHandle(lppiProcInfo.hThread); |
|
5133 | 3089 |
#ifdef PROCESSDEBUGWIN32 |
7118 | 3090 |
fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess); |
3091 |
#endif |
|
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3092 |
__externalAddressVal(handle) = lppiProcInfo.hProcess; |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3093 |
RETURN (handle); |
7118 | 3094 |
} |
5133 | 3095 |
#ifdef PROCESSDEBUGWIN32 |
7118 | 3096 |
fprintf(stderr, "created process error %d\n", GetLastError()); |
3097 |
#endif |
|
3098 |
RETURN (nil); |
|
3099 |
} else { |
|
3100 |
; /* should never be called that way */ |
|
3101 |
} |
|
5133 | 3102 |
} |
3103 |
%}. |
|
3104 |
" |
|
3105 |
path-argument not string |
|
3106 |
or argArray not an array/nil |
|
3107 |
or malloc failed |
|
3108 |
or not supported by OS |
|
3109 |
" |
|
3110 |
^ self primitiveFailed |
|
3111 |
! |
|
3112 |
||
7638 | 3113 |
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream |
3114 |
errorTo:anExternalErrStream auxFrom:anAuxiliaryStream |
|
3115 |
environment:anEvironmentDictionary inDirectory:dir |
|
3116 |
||
5133 | 3117 |
"start executing the OS command as specified by the argument, aCommandString |
3118 |
as a separate process; do not wait for the command to finish. |
|
3119 |
The commandString is passed to a shell for execution - see the description of |
|
3120 |
'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual). |
|
3121 |
The command gets stdIn, stdOut and stdErr assigned from the arguments; |
|
3122 |
each may be nil. |
|
3123 |
Return the processId if successful, nil otherwise. |
|
3124 |
Use #monitorPid:action: for synchronization and exec status return, |
|
3125 |
or #killProcess: to stop it." |
|
3126 |
||
7638 | 3127 |
|nullStream in out err shellAndArgs rslt auxFd| |
5133 | 3128 |
|
3129 |
aCommandString isNil ifTrue:[^ nil]. |
|
3130 |
||
7638 | 3131 |
(in := anExternalInStream) isNil ifTrue:[ |
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3132 |
nullStream := Filename nullDevice readWriteStream. |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3133 |
in := nullStream. |
5133 | 3134 |
]. |
7638 | 3135 |
(out := anExternalOutStream) isNil ifTrue:[ |
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3136 |
nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream]. |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3137 |
out := nullStream. |
5133 | 3138 |
]. |
7638 | 3139 |
(err := anExternalErrStream) isNil ifTrue:[ |
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3140 |
err := out |
5133 | 3141 |
]. |
7638 | 3142 |
anAuxiliaryStream notNil ifTrue:[ |
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3143 |
auxFd := anAuxiliaryStream fileDescriptor |
7158 | 3144 |
]. |
5133 | 3145 |
|
3146 |
shellAndArgs := self commandAndArgsForOSCommand:aCommandString. |
|
7638 | 3147 |
|
3148 |
rslt := self |
|
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3149 |
exec:(shellAndArgs at:1) |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3150 |
withArguments:(shellAndArgs at:2) |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3151 |
environment:anEvironmentDictionary |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3152 |
fileDescriptors:(Array with:in fileDescriptor |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3153 |
with:out fileDescriptor |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3154 |
with:err fileDescriptor |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3155 |
with:auxFd) |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3156 |
fork:true |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3157 |
newPgrp:true "/ false |
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3158 |
inDirectory:dir. |
7638 | 3159 |
|
3160 |
nullStream notNil ifTrue:[ |
|
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3161 |
nullStream close. |
5133 | 3162 |
]. |
7638 | 3163 |
^ rslt |
3164 |
||
3165 |
"blocking at current prio (i.e. only higher prio threads execute): |
|
3166 |
||
3167 |
OperatingSystem executeCommand:'ls -l > out'. |
|
3168 |
" |
|
3169 |
||
3170 |
"non-blocking (lower prio threads continue): |
|
3171 |
||
3172 |
|in out err pid sema| |
|
3173 |
||
3174 |
in := 'out' asFilename readStream. |
|
3175 |
out := 'out2' asFilename writeStream. |
|
3176 |
err := 'err' asFilename writeStream. |
|
3177 |
||
3178 |
sema := Semaphore new. |
|
3179 |
pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err. |
|
3180 |
||
3181 |
The following will no longer work. monitorPid has disappeared |
|
3182 |
||
3183 |
pid notNil ifTrue:[ |
|
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
3184 |
Processor monitorPid:pid action:[:OSstatus | sema signal ]. |
7638 | 3185 |
]. |
3186 |
in close. |
|
3187 |
out close. |
|
3188 |
err close. |
|
3189 |
sema wait. |
|
3190 |
Transcript showCR:'finished' |
|
3191 |
" |
|
3192 |
||
3193 |
"Modified: / 21.3.1997 / 10:04:35 / dq" |
|
3194 |
"Modified: / 15.7.1997 / 16:03:51 / stefan" |
|
3195 |
"Modified: / 5.6.1998 / 19:03:51 / cg" |
|
3196 |
"Created: / 12.11.1998 / 14:39:20 / cg" |
|
5133 | 3197 |
! ! |
3198 |
||
3199 |
!Win32OperatingSystem class methodsFor:'file access'! |
|
3200 |
||
7662 | 3201 |
closeFd:anIntegerOrHandle |
5133 | 3202 |
"low level close of a filedescriptor" |
3203 |
||
3204 |
%{ |
|
7662 | 3205 |
if (__isExternalAddressLike(anIntegerOrHandle) ) { |
3206 |
if( !CloseHandle( anIntegerOrHandle ) ) { |
|
3207 |
fprintf( stderr, "Could not close handle : %x\n", anIntegerOrHandle); |
|
3208 |
} |
|
3209 |
RETURN(self); |
|
3210 |
} |
|
3211 |
if (__isSmallInteger(anIntegerOrHandle)) { |
|
3212 |
close(__intVal(anIntegerOrHandle)); |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3213 |
RETURN(self); |
7662 | 3214 |
} |
5133 | 3215 |
%}. |
7662 | 3216 |
^ self primitiveFailed. |
5133 | 3217 |
! |
3218 |
||
3219 |
createDirectory:aPathName |
|
3220 |
"create a new directory with name 'aPathName', which may be an absolute |
|
3221 |
path, or relative to the current directory. |
|
3222 |
Return true if successful (or the directory existed already), false if failed. |
|
3223 |
This is a low-level entry - use Filename protocol for compatibility." |
|
3224 |
||
3225 |
"/ if it already exists this is ok |
|
3226 |
||
3227 |
(self isDirectory:aPathName) ifTrue:[^ true]. |
|
3228 |
||
3229 |
%{ |
|
3230 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3231 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3232 |
SECURITY_ATTRIBUTES sa; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3233 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3234 |
sa.nLength = sizeof( sa ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3235 |
sa.lpSecurityDescriptor = NULL; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3236 |
sa.bInheritHandle = TRUE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3237 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3238 |
ret = CreateDirectory(__stringVal(aPathName), &sa); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3239 |
if (ret != TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3240 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3241 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3242 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3243 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3244 |
RETURN (true); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
3245 |
} |
5133 | 3246 |
%}. |
3247 |
self primitiveFailed |
|
3248 |
||
3249 |
" |
|
3250 |
OperatingSystem createDirectory:'foo' |
|
3251 |
" |
|
3252 |
||
3253 |
"Modified: 20.12.1995 / 11:24:13 / stefan" |
|
3254 |
"Modified: 29.6.1996 / 14:06:54 / cg" |
|
3255 |
! |
|
3256 |
||
6293 | 3257 |
createFileForReadAppend:pathName |
3258 |
^ self openFile:pathName attributes:#(#'GENERIC_READ' #'GENERIC_WRITE') |
|
3259 |
! |
|
3260 |
||
3261 |
createFileForReadWrite:pathName |
|
6297 | 3262 |
^ self openFile:pathName attributes:#(#'GENERIC_READ' #'GENERIC_WRITE' #'CREATE_ALWAYS') |
6293 | 3263 |
! |
3264 |
||
5133 | 3265 |
linkFile:oldPath to:newPath |
3266 |
"link the file 'oldPath' to 'newPath'. The link will be a hard link. |
|
3267 |
Return true if successful, false if not." |
|
3268 |
||
3269 |
(oldPath isString not or:[newPath isString not]) ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3270 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3271 |
"/ bad argument(s) given |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3272 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3273 |
^ self primitiveFailed |
5133 | 3274 |
]. |
3275 |
||
3276 |
"/ |
|
3277 |
"/ this OperatingSystem does not support links |
|
3278 |
"/ |
|
3279 |
^ UnsupportedOperationSignal raise |
|
3280 |
||
3281 |
" |
|
3282 |
OperatingSystem linkFile:'foo' to:'bar' |
|
3283 |
" |
|
3284 |
! |
|
3285 |
||
6293 | 3286 |
openFile:pathName attributes:attributeSpec |
3287 |
"non public internal helper. |
|
3288 |
open a file, return an os specific fileHandle. |
|
3289 |
attributes is a collection of symbols specifying how the file is |
|
3290 |
to be opened." |
|
3291 |
||
6297 | 3292 |
|fileHandle errorNumber argumentError| |
6293 | 3293 |
|
3294 |
fileHandle := Win32Handle new. |
|
3295 |
||
3296 |
%{ |
|
3297 |
HANDLE h; |
|
3298 |
char *name; |
|
3299 |
OBJ *ap = __ArrayInstPtr(attributeSpec)->a_element; |
|
3300 |
int numAttrib = __arraySize(attributeSpec); |
|
3301 |
int i; |
|
3302 |
DWORD access, share, create, attr; |
|
3303 |
||
3304 |
if (! __isString(pathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3305 |
fileHandle = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3306 |
argumentError = @symbol(badPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3307 |
goto badArgument; |
6293 | 3308 |
} |
3309 |
if (! __isArray(attributeSpec)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3310 |
fileHandle = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3311 |
argumentError = @symbol(badAttributeSpec); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3312 |
goto badArgument; |
6293 | 3313 |
} |
3314 |
||
3315 |
name = __stringVal(pathName); |
|
3316 |
||
3317 |
share = 0; |
|
3318 |
access = 0; |
|
3319 |
create = 0; |
|
3320 |
attr = 0; |
|
3321 |
||
3322 |
for (i=0; i<numAttrib;i++) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3323 |
OBJ attrSym = ap[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3324 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3325 |
if (attrSym == @symbol(FILE_SHARE_READ)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3326 |
share |= FILE_SHARE_READ; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3327 |
} else if (attrSym == @symbol(FILE_SHARE_WRITE)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3328 |
share |= FILE_SHARE_WRITE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3329 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3330 |
} else if (attrSym == @symbol(GENERIC_READ)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3331 |
access |= GENERIC_READ; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3332 |
} else if (attrSym == @symbol(GENERIC_WRITE)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3333 |
access |= GENERIC_WRITE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3334 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3335 |
} else if (attrSym == @symbol(CREATE_NEW)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3336 |
create |= CREATE_NEW; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3337 |
} else if (attrSym == @symbol(CREATE_ALWAYS)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3338 |
create |= CREATE_ALWAYS; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3339 |
} else if (attrSym == @symbol(OPEN_EXISTING)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3340 |
create |= OPEN_EXISTING; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3341 |
} else if (attrSym == @symbol(OPEN_ALWAYS)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3342 |
create |= OPEN_ALWAYS; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3343 |
} else if (attrSym == @symbol(TRUNCATE_EXISTING)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3344 |
create |= TRUNCATE_EXISTING; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3345 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3346 |
} else if (attrSym == @symbol(FILE_ATTRIBUTE_HIDDEN)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3347 |
attr |= FILE_ATTRIBUTE_HIDDEN; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3348 |
} else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3349 |
attr |= FILE_ATTRIBUTE_READONLY; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3350 |
} else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3351 |
attr |= FILE_ATTRIBUTE_READONLY; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3352 |
} else if (attrSym == @symbol(FILE_FLAG_WRITE_THROUGH)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3353 |
attr |= FILE_FLAG_WRITE_THROUGH; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3354 |
} else if (attrSym == @symbol(FILE_FLAG_SEQUENTIAL_SCAN)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3355 |
attr |= FILE_FLAG_SEQUENTIAL_SCAN; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3356 |
} else if (attrSym == @symbol(FILE_FLAG_DELETE_ON_CLOSE)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3357 |
attr |= FILE_FLAG_DELETE_ON_CLOSE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3358 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3359 |
fprintf(stderr, "Win32OS [warning]: unsupported open mode\n"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3360 |
} |
6293 | 3361 |
} |
6297 | 3362 |
if (create == 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3363 |
fileHandle = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3364 |
argumentError = @symbol(missingCreateMode); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3365 |
goto badArgument; |
6297 | 3366 |
} |
6293 | 3367 |
fprintf(stderr, "name:<%s> access:%x share:%x create:%x attr:%x\n", |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3368 |
name, access, share, create, attr); |
6293 | 3369 |
|
3370 |
h = CreateFile(name, access, share, 0 /* sa */, create, attr, 0 /* hTempl */); |
|
3371 |
if (h != INVALID_HANDLE_VALUE) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3372 |
__externalAddressVal(fileHandle) = (void *)h; |
6293 | 3373 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3374 |
fileHandle = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3375 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
6293 | 3376 |
} |
3377 |
||
3378 |
badArgument: ; |
|
3379 |
%}. |
|
3380 |
fileHandle notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3381 |
fileHandle registerForFinalization. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3382 |
^ fileHandle. |
6293 | 3383 |
]. |
3384 |
errorNumber isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3385 |
self error:'invalid argument(s): ', argumentError. |
6293 | 3386 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3387 |
(self errorHolderForNumber:errorNumber) reportError |
6293 | 3388 |
]. |
3389 |
! |
|
3390 |
||
3391 |
openFileForAppend:pathName |
|
3392 |
^ self halt |
|
3393 |
! |
|
3394 |
||
3395 |
openFileForRead:pathName |
|
6297 | 3396 |
^ self openFile:pathName attributes:#(#'GENERIC_READ' #'OPEN_EXISTING') |
6293 | 3397 |
! |
3398 |
||
3399 |
openFileForReadAppend:pathName |
|
3400 |
^ self halt |
|
3401 |
! |
|
3402 |
||
3403 |
openFileForReadWrite:pathName |
|
3404 |
^ self openFile:pathName attributes:#(#'GENERIC_READ' #'GENERIC_WRITE') |
|
3405 |
! |
|
3406 |
||
3407 |
openFileForWrite:pathName |
|
6304 | 3408 |
^ self openFile:pathName attributes:#(#'GENERIC_WRITE' #'OPEN_EXISTING') |
6293 | 3409 |
! |
3410 |
||
5133 | 3411 |
recursiveCopyDirectory:sourcePathName to:destination |
3412 |
"copy the directory named 'sourcePathName' and all contained files/directories to 'destination'. |
|
3413 |
Return true if successful." |
|
3414 |
||
3415 |
^ false |
|
3416 |
||
3417 |
"Modified: / 4.6.1998 / 04:29:49 / cg" |
|
3418 |
! |
|
3419 |
||
3420 |
removeDirectory:fullPathName |
|
3421 |
"remove the directory named 'fullPathName'. |
|
3422 |
The directory must be empty and you must have appropriate access rights. |
|
3423 |
Return true if successful, false if directory is not empty or no permission. |
|
3424 |
This is a lowLevel entry - use Filename protocol for compatibility." |
|
3425 |
||
3426 |
%{ |
|
3427 |
int ret; |
|
3428 |
||
3429 |
if (__isString(fullPathName)) { |
|
3430 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3431 |
{ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3432 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3433 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3434 |
strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3435 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3436 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3437 |
ret = STX_API_CALL1( "RemoveDirectory", RemoveDirectory, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3438 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3439 |
} |
5133 | 3440 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3441 |
ret = RemoveDirectory((char *)__stringVal(fullPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3442 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3443 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3444 |
if (ret != TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3445 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3446 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3447 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3448 |
RETURN (true); |
5133 | 3449 |
} |
3450 |
%}. |
|
3451 |
"/ |
|
3452 |
"/ either not a string argument, |
|
3453 |
"/ or not supported by OS |
|
3454 |
"/ |
|
3455 |
^ self primitiveFailed |
|
3456 |
||
3457 |
" |
|
3458 |
OperatingSystem createDirectory:'foo' |
|
3459 |
OperatingSystem removeDirectory:'foo' |
|
3460 |
" |
|
3461 |
! |
|
3462 |
||
3463 |
removeFile:fullPathName |
|
3464 |
"remove the file named 'fullPathName'; return true if successful. |
|
3465 |
This is a lowLevel entry - use Filename protocol for compatibility." |
|
3466 |
||
3467 |
%{ |
|
3468 |
int ret; |
|
3469 |
||
3470 |
if (__isString(fullPathName)) { |
|
3471 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3472 |
{ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3473 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3474 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3475 |
strncpy(_aPathName, __stringVal(fullPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3476 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3477 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3478 |
ret = STX_API_CALL1( "DeleteFile", DeleteFile, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3479 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3480 |
} |
5133 | 3481 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3482 |
ret = DeleteFile((char *)__stringVal(fullPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3483 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3484 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3485 |
if (ret != TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3486 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3487 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3488 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3489 |
RETURN (true); |
5133 | 3490 |
} |
3491 |
%}. |
|
3492 |
^ self primitiveFailed |
|
3493 |
! |
|
3494 |
||
3495 |
renameFile:oldPath to:newPath |
|
3496 |
"rename the file 'oldPath' to 'newPath'. |
|
3497 |
Someone else has to care for the names to be correct and |
|
3498 |
correct for the OS used - therefore, this should not be called |
|
3499 |
directlt. Instead, use Filename protocol to rename; this cares for |
|
3500 |
any invalid names. |
|
3501 |
Returns true if successful, false if not" |
|
3502 |
||
3503 |
%{ |
|
3504 |
int ret, eno; |
|
3505 |
||
3506 |
if (__isString(oldPath) && __isString(newPath)) { |
|
3507 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3508 |
char _oldPath[MAXPATHLEN], _newPath[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3509 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3510 |
strncpy(_oldPath, __stringVal(oldPath), MAXPATHLEN-1); _oldPath[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3511 |
strncpy(_newPath, __stringVal(newPath), MAXPATHLEN-1); _newPath[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3512 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3513 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3514 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3515 |
ret = STX_C_CALL2( "rename", rename, _oldPath, _newPath); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3516 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
3517 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3518 |
__BEGIN_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3519 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3520 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3521 |
ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3522 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3523 |
__END_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3524 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3525 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3526 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3527 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3528 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3529 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3530 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3531 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3532 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3533 |
RETURN (true); |
5133 | 3534 |
} |
3535 |
%}. |
|
3536 |
^ self primitiveFailed |
|
3537 |
||
3538 |
" |
|
3539 |
OperatingSystem renameFile:'foo' to:'bar' |
|
3540 |
" |
|
3541 |
! |
|
3542 |
||
3543 |
truncateFile:aPathName to:newSize |
|
3544 |
"change a files size return true on success, false on failure. |
|
3545 |
This may not be supported on all architectures. |
|
3546 |
||
3547 |
This is a low-level entry - use Filename protocol." |
|
3548 |
||
3549 |
^ self primitiveFailed |
|
3550 |
! ! |
|
3551 |
||
3552 |
!Win32OperatingSystem class methodsFor:'file access rights'! |
|
3553 |
||
3554 |
accessMaskFor:aSymbol |
|
3555 |
"return the access bits mask for numbers as returned by |
|
3556 |
OperatingSystem>>accessModeOf: |
|
3557 |
and expected by OperatingSystem>>changeAccessModeOf:to:. |
|
3558 |
Since these numbers are OS dependent, always use the mask |
|
3559 |
(never hardcode 8rxxx into your code)." |
|
3560 |
||
3561 |
%{ /* NOCONTEXT */ |
|
3562 |
/* posix systems should define these ... */ |
|
3563 |
# ifndef S_IRUSR |
|
3564 |
# define S_IRUSR 0400 |
|
3565 |
# endif |
|
3566 |
# ifndef S_IWUSR |
|
3567 |
# define S_IWUSR 0200 |
|
3568 |
# endif |
|
3569 |
# ifndef S_IXUSR |
|
3570 |
# define S_IXUSR 0100 |
|
3571 |
# endif |
|
3572 |
# ifndef S_IRGRP |
|
3573 |
# define S_IRGRP 0040 |
|
3574 |
# endif |
|
3575 |
# ifndef S_IWGRP |
|
3576 |
# define S_IWGRP 0020 |
|
3577 |
# endif |
|
3578 |
# ifndef S_IXGRP |
|
3579 |
# define S_IXGRP 0010 |
|
3580 |
# endif |
|
3581 |
# ifndef S_IROTH |
|
3582 |
# define S_IROTH 0004 |
|
3583 |
# endif |
|
3584 |
# ifndef S_IWOTH |
|
3585 |
# define S_IWOTH 0002 |
|
3586 |
# endif |
|
3587 |
# ifndef S_IXOTH |
|
3588 |
# define S_IXOTH 0001 |
|
3589 |
# endif |
|
3590 |
||
3591 |
if (aSymbol == @symbol(readUser)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3592 |
RETURN ( __MKSMALLINT(S_IRUSR) ); |
5133 | 3593 |
} |
3594 |
if (aSymbol == @symbol(writeUser)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3595 |
RETURN ( __MKSMALLINT(S_IWUSR) ); |
5133 | 3596 |
} |
3597 |
if (aSymbol == @symbol(executeUser)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3598 |
RETURN ( __MKSMALLINT(S_IXUSR) ); |
5133 | 3599 |
} |
3600 |
if (aSymbol == @symbol(readGroup)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3601 |
RETURN ( __MKSMALLINT(S_IRGRP) ); |
5133 | 3602 |
} |
3603 |
if (aSymbol == @symbol(writeGroup)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3604 |
RETURN ( __MKSMALLINT(S_IWGRP) ); |
5133 | 3605 |
} |
3606 |
if (aSymbol == @symbol(executeGroup)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3607 |
RETURN ( __MKSMALLINT(S_IXGRP) ); |
5133 | 3608 |
} |
3609 |
if (aSymbol == @symbol(readOthers)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3610 |
RETURN ( __MKSMALLINT(S_IROTH) ); |
5133 | 3611 |
} |
3612 |
if (aSymbol == @symbol(writeOthers)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3613 |
RETURN ( __MKSMALLINT(S_IWOTH) ); |
5133 | 3614 |
} |
3615 |
if (aSymbol == @symbol(executeOthers)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3616 |
RETURN ( __MKSMALLINT(S_IXOTH) ); |
5133 | 3617 |
} |
3618 |
%}. |
|
3619 |
^ self primitiveFailed |
|
3620 |
||
3621 |
" |
|
3622 |
OperatingSystem accessMaskFor:#readUser |
|
3623 |
" |
|
3624 |
! |
|
3625 |
||
3626 |
accessModeOf:aPathName |
|
3627 |
"return a number representing access rights rwxrwxrwx for owner, |
|
3628 |
group and others. Return nil if such a file does not exist. |
|
3629 |
Notice that the returned number is OS dependent - use the |
|
3630 |
modeMasks as returned by OperatingSystem>>accessMaskFor:" |
|
3631 |
||
3632 |
" |
|
3633 |
this could have been implemented as: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3634 |
(self infoOf:aPathName) at:#mode |
5133 | 3635 |
but for huge directory searches the code below is faster |
3636 |
" |
|
3637 |
||
3638 |
%{ |
|
3639 |
struct stat buf; |
|
3640 |
int ret; |
|
3641 |
||
3642 |
if (__isString(aPathName)) { |
|
3643 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3644 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3645 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3646 |
strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3647 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3648 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3649 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3650 |
ret = STX_C_CALL2( "stat", stat, _aPathName, &buf); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3651 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 3652 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3653 |
__BEGIN_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3654 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3655 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3656 |
ret = stat( (char *)__stringVal(aPathName), &buf); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3657 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3658 |
__END_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3659 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3660 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3661 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3662 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3663 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3664 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3665 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3666 |
RETURN ( nil ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3667 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3668 |
RETURN ( __MKSMALLINT(buf.st_mode & 0777) ); |
5133 | 3669 |
} |
3670 |
%}. |
|
3671 |
^ self primitiveFailed |
|
3672 |
||
3673 |
" |
|
3674 |
(OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
3675 |
" |
|
3676 |
! |
|
3677 |
||
3678 |
changeAccessModeOf:aPathName to:modeBits |
|
3679 |
"change the access rights of aPathName to the OS dependent modeBits. |
|
3680 |
You should construct this mask using accessMaskFor, to be OS |
|
3681 |
independent. Return true if changed, |
|
3682 |
false if such a file does not exist or change was not allowd." |
|
3683 |
||
3684 |
%{ |
|
3685 |
int ret; |
|
3686 |
||
3687 |
if (__isString(aPathName) && __isSmallInteger(modeBits)) { |
|
3688 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3689 |
int chmod(); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3690 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3691 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3692 |
strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3693 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3694 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3695 |
ret = STX_C_CALL2( "chmod", chmod, _aPathName, __intVal(modeBits)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3696 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 3697 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3698 |
__BEGIN_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3699 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3700 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3701 |
ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3702 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3703 |
__END_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3704 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3705 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3706 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3707 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3708 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3709 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3710 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3711 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3712 |
RETURN ( true ); |
5133 | 3713 |
} |
3714 |
%}. |
|
3715 |
^ self primitiveFailed |
|
3716 |
! ! |
|
3717 |
||
3718 |
!Win32OperatingSystem class methodsFor:'file queries'! |
|
3719 |
||
3720 |
caseSensitiveFilenames |
|
3721 |
"return true, if the OS has caseSensitive file naming. |
|
3722 |
On MSDOS, this will return false; |
|
3723 |
on a real OS, we return true." |
|
3724 |
||
3725 |
^ false |
|
3726 |
! |
|
3727 |
||
3728 |
compressPath:pathName |
|
3729 |
"return the pathName compressed - that is, remove all ..-entries |
|
3730 |
and . entries. This does not always (in case of symbolic links) |
|
3731 |
return the true pathName and is therefore used as a fallback |
|
3732 |
if realPath and popen failed." |
|
3733 |
||
3734 |
|names n "{ Class: SmallInteger }" | |
|
3735 |
||
3736 |
names := pathName |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3737 |
asCollectionOfSubstringsSeparatedBy:self fileSeparator. |
5133 | 3738 |
names := names asOrderedCollection. |
3739 |
" |
|
3740 |
cut off initial double-slashes |
|
3741 |
" |
|
3742 |
[names startsWith:#('' '')] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3743 |
names removeFirst. |
5133 | 3744 |
]. |
3745 |
" |
|
3746 |
cut off double-slashes at end |
|
3747 |
" |
|
3748 |
[names endsWith:#('')] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3749 |
names removeLast. |
5133 | 3750 |
]. |
3751 |
" |
|
3752 |
cut off current-dir at beginning |
|
3753 |
" |
|
3754 |
n := names size. |
|
3755 |
[(n >= 2) and:[names startsWith:#('.')]] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3756 |
names removeFirst. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3757 |
n := n - 1. |
5133 | 3758 |
]. |
3759 |
||
3760 |
" |
|
3761 |
cut off parent-dirs at end |
|
3762 |
" |
|
3763 |
[(n > 2) |
|
3764 |
and:[(names endsWith:#('..')) |
|
3765 |
and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3766 |
names removeLast; removeLast. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3767 |
n := n - 2. |
5133 | 3768 |
]. |
3769 |
||
3770 |
^ names asStringWith:self fileSeparator |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3771 |
from:1 |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3772 |
to:n |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3773 |
compressTabs:false final:nil |
7077 | 3774 |
|
3775 |
" |
|
3776 |
OperatingSystem compressPath:'.\..' |
|
3777 |
OperatingSystem compressPath:'\foo\bar\baz\..' |
|
7102 | 3778 |
OperatingSystem compressPath:'foo\bar\baz\..' |
7077 | 3779 |
OperatingSystem compressPath:'foo\bar\baz\..\' |
3780 |
OperatingSystem compressPath:'foo\bar\baz\..\\\' |
|
3781 |
OperatingSystem compressPath:'\\\foo\bar\baz\..\\\' |
|
5133 | 3782 |
" |
3783 |
||
3784 |
"Modified: 1.11.1996 / 20:13:48 / cg" |
|
3785 |
! |
|
3786 |
||
3787 |
fileSeparator |
|
3788 |
"return the character used to separate names in a path. |
|
3789 |
This character differs for MSDOS and other systems, |
|
3790 |
(but those are currently not supported - so this is some |
|
3791 |
preparation for the future)" |
|
3792 |
||
3793 |
^ $\ |
|
3794 |
! |
|
3795 |
||
3796 |
getDiskInfoOf:aVolumeName |
|
3797 |
"returns a dictionary filled with any of: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3798 |
freeBytes |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3799 |
totalBytes |
5133 | 3800 |
and possibly additional (OS-specific) information" |
3801 |
||
3802 |
|info ok sectorsPerCluster bytesPerSector freeClusters totalClusters |
|
3803 |
type| |
|
3804 |
||
3805 |
%{ |
|
3806 |
DWORD __sectorsPerCluster, __bytesPerSector, __freeClusters, __totalClusters; |
|
3807 |
||
3808 |
if (__isString(aVolumeName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3809 |
if (GetDiskFreeSpace(__stringVal(aVolumeName), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3810 |
&__sectorsPerCluster, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3811 |
&__bytesPerSector, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3812 |
&__freeClusters, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3813 |
&__totalClusters) == TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3814 |
sectorsPerCluster = __MKUINT(__sectorsPerCluster); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3815 |
bytesPerSector = __MKUINT(__bytesPerSector); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3816 |
freeClusters = __MKUINT(__freeClusters); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3817 |
totalClusters = __MKUINT(__totalClusters); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3818 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3819 |
switch (GetDriveType(__stringVal(aVolumeName))) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3820 |
case DRIVE_REMOVABLE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3821 |
type = @symbol(removable); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3822 |
case DRIVE_FIXED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3823 |
type = @symbol(fixed); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3824 |
case DRIVE_REMOTE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3825 |
type = @symbol(network); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3826 |
case DRIVE_CDROM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3827 |
type = @symbol(cdrom); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3828 |
case DRIVE_RAMDISK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3829 |
type = @symbol(ramdisk); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3830 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3831 |
ok = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3832 |
} |
5133 | 3833 |
} |
3834 |
%}. |
|
3835 |
ok == true ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3836 |
info := IdentityDictionary new. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3837 |
info at:#sectorsPerCluster put:sectorsPerCluster. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3838 |
info at:#bytesPerSector put:bytesPerSector. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3839 |
info at:#freeClusters put:freeClusters. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3840 |
info at:#totalClusters put:totalClusters. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3841 |
info at:#freeBytes put:(freeClusters * sectorsPerCluster * bytesPerSector). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3842 |
info at:#totalBytes put:(totalClusters * sectorsPerCluster * bytesPerSector). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3843 |
type notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3844 |
info at:#type put:type |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3845 |
]. |
5133 | 3846 |
]. |
3847 |
^ info |
|
3848 |
||
3849 |
" |
|
3850 |
self getDiskInfoOf:'c:\' |
|
3851 |
self getDiskInfoOf:'d:\' |
|
3852 |
" |
|
3853 |
! |
|
3854 |
||
3855 |
getDriveList |
|
3856 |
"return a list of volumes in the system. |
|
3857 |
On unix, no such thing like a volume exists |
|
3858 |
- there, a syntetic list with root, home & current is returned. |
|
3859 |
On MSDOS, a list of drive letters is (eventually) returned. |
|
3860 |
On VMS, a list of volumes is (eventually) returned." |
|
3861 |
||
3862 |
|list| |
|
3863 |
||
3864 |
list := OrderedCollection new. |
|
3865 |
%{ |
|
3866 |
/* |
|
3867 |
* add drive letters as strings to list ... |
|
3868 |
*/ |
|
3869 |
char buffer[1024]; |
|
3870 |
char *cp; |
|
3871 |
||
3872 |
GetLogicalDriveStrings(1023, buffer); |
|
3873 |
for (cp=buffer; *cp; ) { |
|
3874 |
__SSEND1(list, @symbol(add:), 0, __MKSTRING(cp)); |
|
3875 |
cp += strlen(cp) + 1; |
|
3876 |
} |
|
3877 |
%}. |
|
3878 |
^ list |
|
3879 |
! |
|
3880 |
||
3881 |
getFileVersionInfoOf:aPathName |
|
3882 |
"retrieves the versionData from an executable or dll. |
|
3883 |
The returned value is either a byteArray, which should be |
|
3884 |
processed further with extractVersionValue (VerQueryValue), |
|
3885 |
or nil. |
|
3886 |
This is a WIN32 specific entry, not for common usage." |
|
3887 |
%{ |
|
3888 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3889 |
int sz; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3890 |
DWORD dummy; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3891 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3892 |
sz = GetFileVersionInfoSize(__stringVal(aPathName), &dummy); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3893 |
if (sz > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3894 |
OBJ versionData; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3895 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3896 |
versionData = __BYTEARRAY_UNINITIALIZED_NEW_INT(sz); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3897 |
if (versionData == nil) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3898 |
RETURN (nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3899 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3900 |
if (GetFileVersionInfo(__stringVal(aPathName), 0, sz, __ByteArrayInstPtr(versionData)->ba_element) == FALSE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3901 |
RETURN (nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3902 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3903 |
RETURN (versionData); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3904 |
} |
5133 | 3905 |
} |
3906 |
%}. |
|
3907 |
^ nil |
|
3908 |
! |
|
3909 |
||
3910 |
getNullDevice |
|
3911 |
"get the name of the null-device." |
|
3912 |
||
3913 |
^ 'nul' |
|
3914 |
! |
|
3915 |
||
3916 |
infoOf:aPathName |
|
3917 |
"return some object filled with info for the file 'aPathName'; |
|
3918 |
the info (for which corresponding access methods are understood by |
|
3919 |
the returned object) is: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3920 |
type - a symbol giving the files type |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3921 |
mode - numeric access mode |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3922 |
uid - owners user id |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3923 |
gid - owners group id |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3924 |
size - files size |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3925 |
id - files number (i.e. inode number) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3926 |
accessed - last access time (as Timestamp) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3927 |
modified - last modification time (as Timestamp) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3928 |
statusChanged - last status change time (as Timestamp) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3929 |
alternativeName - (windows only:) the MSDOS name of the file |
5133 | 3930 |
|
3931 |
Some of the fields may be returned as nil on systems which do not provide |
|
3932 |
all of the information. |
|
3933 |
Return nil if such a file does not exist. |
|
3934 |
For symbolic links (if supported by the OS), |
|
3935 |
the info of the pointed-to-file (i.e. the target) is returned; |
|
3936 |
use #linkInfoOf: to get info about the link itself. |
|
3937 |
" |
|
3938 |
||
3939 |
|info type mode uid gid size id |
|
3940 |
atime mtime ctime |
|
3941 |
aYr aMon aDay aHr aMin aSec aMS |
|
3942 |
mYr mMon mDay mHr mMin mSec mMS |
|
3943 |
cYr cMon cDay cHr cMin cSec cMS |
|
7062 | 3944 |
fileName alternativeName| |
5133 | 3945 |
|
3946 |
%{ |
|
3947 |
struct stat buf; |
|
3948 |
int ret; |
|
7062 | 3949 |
char alternativeFileNameBuffer[15]; |
3950 |
char fileNameBuffer[MAX_PATH+1]; |
|
3951 |
||
5133 | 3952 |
unsigned INT ino; |
3953 |
||
3954 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3955 |
HANDLE hFile; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3956 |
SYSTEMTIME creationTime; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3957 |
SYSTEMTIME accessTime; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3958 |
SYSTEMTIME modificationTime; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3959 |
int modeBits = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3960 |
WIN32_FIND_DATA findStruct; |
5133 | 3961 |
|
3962 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3963 |
{ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3964 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3965 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3966 |
strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3967 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3968 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3969 |
hFile = STX_API_CALL2( "FindFirstFile", FindFirstFile, _aPathName, &findStruct); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3970 |
} while ((hFile < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3971 |
} |
5133 | 3972 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3973 |
hFile = FindFirstFile(__stringVal(aPathName), &findStruct); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3974 |
if (hFile < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3975 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3976 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3977 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3978 |
if (! hFile || (hFile == (HANDLE)(-1)) || (hFile == INVALID_HANDLE_VALUE)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3979 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3980 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3981 |
FindClose(hFile); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3982 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3983 |
id = __MKSMALLINT(0); /* could get it by opening ... */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3984 |
size = __MKLARGEINT64(1, findStruct.nFileSizeLow, findStruct.nFileSizeHigh); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3985 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3986 |
if (findStruct.cFileName[0] != '\0') { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3987 |
bcopy(findStruct.cFileName, fileNameBuffer, MAX_PATH); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3988 |
fileNameBuffer[MAX_PATH] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3989 |
fileName = __MKSTRING(fileNameBuffer); /* FULL name */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3990 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3991 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3992 |
if (findStruct.cAlternateFileName[0] != '\0') { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3993 |
bcopy(findStruct.cAlternateFileName, alternativeFileNameBuffer, 14); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3994 |
alternativeFileNameBuffer[14] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3995 |
alternativeName = __MKSTRING(alternativeFileNameBuffer); /* DOS name */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3996 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3997 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3998 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3999 |
* simulate access bits |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4000 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4001 |
if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4002 |
modeBits = 0444; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4003 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4004 |
modeBits = 0666; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4005 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4006 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4007 |
if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4008 |
type = @symbol(directory); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4009 |
modeBits |= 0111; /* executable */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4010 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4011 |
type = @symbol(regular); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4012 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4013 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4014 |
mode = __MKSMALLINT(modeBits); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4015 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4016 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4017 |
* sigh - convert from stupid time to useful time |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4018 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4019 |
FileTimeToSystemTime(&(findStruct.ftCreationTime), &creationTime); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4020 |
FileTimeToSystemTime(&(findStruct.ftLastAccessTime), &accessTime); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4021 |
FileTimeToSystemTime(&(findStruct.ftLastWriteTime), &modificationTime); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4022 |
aYr = __MKSMALLINT(accessTime.wYear); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4023 |
aMon = __MKSMALLINT(accessTime.wMonth); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4024 |
aDay = __MKSMALLINT(accessTime.wDay); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4025 |
aHr = __MKSMALLINT(accessTime.wHour); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4026 |
aMin = __MKSMALLINT(accessTime.wMinute); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4027 |
aSec = __MKSMALLINT(accessTime.wSecond); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4028 |
aMS = __MKSMALLINT(accessTime.wMilliseconds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4029 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4030 |
mYr = __MKSMALLINT(modificationTime.wYear); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4031 |
mMon = __MKSMALLINT(modificationTime.wMonth); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4032 |
mDay = __MKSMALLINT(modificationTime.wDay); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4033 |
mHr = __MKSMALLINT(modificationTime.wHour); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4034 |
mMin = __MKSMALLINT(modificationTime.wMinute); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4035 |
mSec = __MKSMALLINT(modificationTime.wSecond); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4036 |
mMS = __MKSMALLINT(modificationTime.wMilliseconds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4037 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4038 |
cYr = __MKSMALLINT(creationTime.wYear); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4039 |
cMon = __MKSMALLINT(creationTime.wMonth); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4040 |
cDay = __MKSMALLINT(creationTime.wDay); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4041 |
cHr = __MKSMALLINT(creationTime.wHour); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4042 |
cMin = __MKSMALLINT(creationTime.wMinute); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4043 |
cSec = __MKSMALLINT(creationTime.wSecond); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4044 |
cMS = __MKSMALLINT(creationTime.wMilliseconds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4045 |
} |
5133 | 4046 |
} |
4047 |
%}. |
|
6377
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
4048 |
mode isNil ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4049 |
(self isDirectory:aPathName) ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4050 |
"/ the code above fails for root directories (these do not exist). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4051 |
"/ simulate |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4052 |
mode := 8r777. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4053 |
type := #directory. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4054 |
uid := gid := 0. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4055 |
size := 0. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4056 |
id := 0. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4057 |
atime := mtime := ctime := AbsoluteTime now. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4058 |
]. |
6377
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
4059 |
]. |
5133 | 4060 |
mode notNil ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4061 |
atime isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4062 |
atime := AbsoluteTime day:aDay month:aMon year:aYr hour:aHr minutes:aMin seconds:aSec milliseconds:aMS. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4063 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4064 |
mtime isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4065 |
mtime := AbsoluteTime day:mDay month:mMon year:mYr hour:mHr minutes:mMin seconds:mSec milliseconds:mMS. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4066 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4067 |
ctime isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4068 |
ctime := AbsoluteTime day:cDay month:cMon year:cYr hour:cHr minutes:cMin seconds:cSec milliseconds:cMS. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4069 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4070 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4071 |
info := FileStatusInfo |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4072 |
type:type |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4073 |
mode:mode |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4074 |
uid:uid |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4075 |
gid:gid |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4076 |
size:size |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4077 |
id:id |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4078 |
accessed:atime |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4079 |
modified:mtime |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4080 |
created:ctime |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4081 |
path:nil |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4082 |
fullName:fileName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4083 |
alternativeName:alternativeName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4084 |
^ info |
5133 | 4085 |
]. |
6726 | 4086 |
^ nil |
5133 | 4087 |
|
4088 |
" |
|
6377
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
4089 |
OperatingSystem infoOf:'c:\windows' |
5133 | 4090 |
OperatingSystem infoOf:'stx.exe' |
4091 |
(OperatingSystem infoOf:'/') uid |
|
4092 |
(OperatingSystem infoOf:'/') accessed |
|
4093 |
" |
|
6377
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
4094 |
|
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
4095 |
"Modified: / 4.2.2002 / 17:15:08 / cg" |
5133 | 4096 |
! |
4097 |
||
4098 |
isDirectory:aPathName |
|
4099 |
"return true, if 'aPathName' is a valid directory path name. |
|
4100 |
(i.e. exists and is a directory). |
|
4101 |
This also returns true for symbolic links pointing to a directory; |
|
4102 |
if you need to check for this, use #linkInfo:." |
|
4103 |
||
4104 |
%{ |
|
4105 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4106 |
int ret; |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
4107 |
|
5133 | 4108 |
#ifdef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4109 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4110 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4111 |
strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4112 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4113 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4114 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4115 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 4116 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4117 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4118 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4119 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4120 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4121 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4122 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4123 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4124 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4125 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4126 |
RETURN ( (ret & FILE_ATTRIBUTE_DIRECTORY) ? true : false); |
5133 | 4127 |
} |
4128 |
%}. |
|
4129 |
^ self primitiveFailed |
|
4130 |
||
4131 |
"an alternative implementation would be: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4132 |
^ (self infoOf:aPathName) type == #directory |
5133 | 4133 |
" |
4134 |
! |
|
4135 |
||
4136 |
isExecutable:aPathName |
|
4137 |
"return true, if the given file is executable. |
|
4138 |
For symbolic links, the pointed-to-file is checked." |
|
4139 |
||
4140 |
%{ |
|
4141 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4142 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4143 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4144 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4145 |
* under windows, there is no executable attribute ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4146 |
* so, only check for the files existence here. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4147 |
*/ |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
4148 |
#ifdef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4149 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4150 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4151 |
strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4152 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4153 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4154 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4155 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 4156 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4157 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4158 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4159 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4160 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4161 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4162 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4163 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4164 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4165 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4166 |
RETURN (true); |
5133 | 4167 |
} |
4168 |
%}. |
|
4169 |
! |
|
4170 |
||
4171 |
isReadable:aPathName |
|
4172 |
"return true, if the file/dir 'aPathName' is readable. |
|
4173 |
For symbolic links, the pointed-to-file is checked." |
|
4174 |
||
4175 |
%{ |
|
4176 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4177 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4178 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4179 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4180 |
* under windows, all files are readable ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4181 |
* so, only check for the files existence here. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4182 |
*/ |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
4183 |
#ifdef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4184 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4185 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4186 |
strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4187 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4188 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4189 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4190 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
4191 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4192 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4193 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4194 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4195 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4196 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4197 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4198 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4199 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4200 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4201 |
RETURN (true); |
5133 | 4202 |
} |
4203 |
%}. |
|
4204 |
^ self primitiveFailed |
|
4205 |
! |
|
4206 |
||
4207 |
isSymbolicLink:aPathName |
|
4208 |
"return true, if the given file is a symbolic link" |
|
4209 |
||
4210 |
^ (self linkInfoOf:aPathName) notNil |
|
4211 |
||
4212 |
" |
|
4213 |
OperatingSystem isSymbolicLink:'Make.proto' |
|
4214 |
OperatingSystem isSymbolicLink:'Makefile' |
|
4215 |
" |
|
4216 |
! |
|
4217 |
||
4218 |
isValidPath:aPathName |
|
4219 |
"return true, if 'aPathName' is a valid path name |
|
4220 |
(i.e. the file or directory exists)" |
|
4221 |
||
4222 |
%{ |
|
4223 |
struct stat buf; |
|
4224 |
int ret; |
|
4225 |
||
4226 |
if (__isString(aPathName) || __isSymbol(aPathName) ) { |
|
4227 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4228 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4229 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4230 |
strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4231 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4232 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4233 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4234 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 4235 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4236 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4237 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4238 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4239 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4240 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4241 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4242 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4243 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4244 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4245 |
RETURN (true); |
5133 | 4246 |
} |
4247 |
%}. |
|
4248 |
^ self primitiveFailed |
|
4249 |
! |
|
4250 |
||
4251 |
isWritable:aPathName |
|
4252 |
"return true, if the given file is writable. |
|
4253 |
For symbolic links, the pointed-to-file is checked." |
|
4254 |
||
4255 |
%{ |
|
4256 |
int ret; |
|
4257 |
||
4258 |
if (__isString(aPathName)) { |
|
4259 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4260 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4261 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4262 |
strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4263 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4264 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4265 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4266 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 4267 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4268 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4269 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4270 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4271 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4272 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4273 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4274 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4275 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4276 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4277 |
RETURN ( (ret & FILE_ATTRIBUTE_READONLY) ? false : true); |
5133 | 4278 |
} |
4279 |
%}. |
|
4280 |
^ self primitiveFailed |
|
4281 |
! |
|
4282 |
||
4283 |
linkInfoOf:aPathName |
|
4284 |
"return a dictionary filled with info for the file 'aPathName', |
|
4285 |
IFF aPathName is a symbolic link. |
|
4286 |
If aPathName is invalid, or its NOT a symbolic link, nil is returned. |
|
4287 |
(which means, that systems like VMS or MSDOS always return nil here.) |
|
4288 |
||
4289 |
The contents of the dictionary gives info about the link itself, |
|
4290 |
on contrast to #infoOf:, which returns the info of the pointed to file |
|
4291 |
in case of a symbolic link." |
|
4292 |
||
4293 |
^ nil |
|
4294 |
! |
|
4295 |
||
4296 |
mimeTypeForSuffix:aFileSuffix |
|
4297 |
"given a file suffix, return a corresponding mimeType. |
|
4298 |
Here, the Registry is consulted. |
|
4299 |
Returns nil if no mimeType for the given suffix is known." |
|
4300 |
||
4301 |
^ RegistryEntry |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4302 |
stringValueFor:'Content Type' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4303 |
atKey:('HKEY_CLASSES_ROOT\.' , aFileSuffix) |
5133 | 4304 |
|
4305 |
" |
|
4306 |
self mimeTypeForSuffix:'au' |
|
4307 |
" |
|
4308 |
||
4309 |
! |
|
4310 |
||
4311 |
parentDirectoryName |
|
4312 |
"return the name used to refer to parent directories. |
|
4313 |
In MSDOS, Unix and other systems this is '..', but maybe different |
|
4314 |
for other systems. |
|
4315 |
(but those are currently not supported - so this is some |
|
4316 |
preparation for the future)" |
|
4317 |
||
4318 |
^ '..' |
|
4319 |
! |
|
4320 |
||
4321 |
pathNameOf:pathName |
|
4322 |
"return the pathName of the argument, aPathString, |
|
4323 |
- thats the full pathname of the directory, starting at '/'. |
|
4324 |
This method needs the path to be valid |
|
4325 |
(i.e. all directories must exist, be readable and executable). |
|
4326 |
Notice: if symbolic links are involved, the result may look different |
|
4327 |
from what you expect." |
|
4328 |
||
4329 |
|p path| |
|
4330 |
||
4331 |
"some systems have a convenient function for this ..." |
|
4332 |
path := self primPathNameOf:pathName. |
|
4333 |
||
4334 |
path isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4335 |
(self isValidPath:pathName) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4336 |
p := pathName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4337 |
[(p size > 1) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4338 |
and:[p endsWith:(self fileSeparator)] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4339 |
] whileTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4340 |
p := p copyWithoutLast:1. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4341 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4342 |
^ p |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4343 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4344 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4345 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4346 |
"/ return the original - there is nothing else can we do |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4347 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4348 |
path := self compressPath:pathName |
5133 | 4349 |
]. |
4350 |
^ path. |
|
4351 |
||
4352 |
" |
|
4353 |
OperatingSystem pathNameOf:'.' |
|
4354 |
OperatingSystem pathNameOf:'../smalltalk/../smalltalk' |
|
4355 |
OperatingSystem pathNameOf:'../../..' |
|
4356 |
OperatingSystem pathNameOf:'..' |
|
4357 |
OperatingSystem pathNameOf:'/tmp////' |
|
4358 |
OperatingSystem pathNameOf:'/foo/bar' |
|
4359 |
OperatingSystem pathNameOf:'/foo/bar/' |
|
4360 |
OperatingSystem pathNameOf:'/foo/bar//' |
|
4361 |
" |
|
4362 |
||
4363 |
"Modified: 29.11.1996 / 18:02:12 / stefan" |
|
4364 |
"Modified: 10.1.1997 / 19:10:42 / cg" |
|
4365 |
! |
|
4366 |
||
4367 |
primIdOf:aPathName |
|
4368 |
"the actual code to return the fileNumber (i.e. inode number) of a file." |
|
4369 |
||
4370 |
^ nil |
|
4371 |
! |
|
4372 |
||
4373 |
primPathNameOf:aPathName |
|
4374 |
"return the pathName of the argument, aPathString, |
|
4375 |
- thats the full pathname of the directory, starting at '/'. |
|
4376 |
This method here returns nil, if the OS does not provide a |
|
4377 |
realPath library function. |
|
4378 |
Notice: if symbolic links are involved, the result may look different |
|
4379 |
from what you expect." |
|
4380 |
||
4381 |
%{ /* xxSTACK: 16000 */ |
|
4382 |
||
4383 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4384 |
char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4385 |
char *pFinal; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4386 |
int rslt; |
5133 | 4387 |
|
4388 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4389 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4390 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4391 |
strncpy(_aPathName, __stringVal(aPathName), MAXPATHLEN-1); _aPathName[MAXPATHLEN-1] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4392 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4393 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4394 |
rslt = STX_API_CALL4( "GetFullPathName", GetFullPathName, _aPathName, sizeof(nameBuffer), nameBuffer, &pFinal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4395 |
} while ((rslt < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4396 |
if (rslt > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4397 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4398 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4399 |
rslt = STX_API_CALL3( "GetLongPathName", GetLongPathName, nameBuffer, nameBuffer, sizeof(nameBuffer)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4400 |
} while ((rslt < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4401 |
} |
5133 | 4402 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4403 |
rslt = GetFullPathName(__stringVal(aPathName), sizeof(nameBuffer), nameBuffer, &pFinal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4404 |
if (rslt > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4405 |
rslt = GetLongPathName(nameBuffer, nameBuffer, sizeof(nameBuffer)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4406 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4407 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4408 |
if (rslt > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4409 |
RETURN ( __MKSTRING(nameBuffer) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4410 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4411 |
__threadErrno = __WIN32_ERR(GetLastError()); |
5133 | 4412 |
} |
4413 |
%}. |
|
4414 |
^ nil |
|
7102 | 4415 |
" |
4416 |
self primPathNameOf:'.' |
|
4417 |
" |
|
5133 | 4418 |
! |
4419 |
||
4420 |
timeOfLastAccess:aPathName |
|
4421 |
"return the time, when the file was last accessed. |
|
4422 |
For nonexistent files, nil is returned." |
|
4423 |
||
4424 |
"could be implemented as: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4425 |
(self infoOf:aPathName) accessed |
5133 | 4426 |
" |
4427 |
| i| |
|
4428 |
||
4429 |
i := self infoOf:aPathName. |
|
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
4430 |
i notNil ifTrue:[^ i accessTime]. |
5133 | 4431 |
^ nil. |
4432 |
||
4433 |
" |
|
4434 |
OperatingSystem timeOfLastAccess:'/' |
|
4435 |
" |
|
4436 |
! |
|
4437 |
||
4438 |
timeOfLastChange:aPathName |
|
4439 |
"return the time, when the file was last changed. |
|
4440 |
For nonexistent files, nil is returned." |
|
4441 |
||
4442 |
"could be implemented as: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4443 |
(self infoOf:aPathName) modified |
5133 | 4444 |
" |
4445 |
||
4446 |
| i| |
|
4447 |
||
4448 |
i := self infoOf:aPathName. |
|
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
4449 |
i notNil ifTrue:[^ i modificationTime]. |
5133 | 4450 |
^ nil. |
4451 |
||
4452 |
" |
|
4453 |
OperatingSystem timeOfLastChange:'/' |
|
4454 |
" |
|
4455 |
! |
|
4456 |
||
4457 |
typeOf:aPathName |
|
4458 |
"return the type of a file as a symbol; for nonexistent files, |
|
4459 |
nil is returned. |
|
4460 |
Notice: for symbolic links, the type of the pointed-to file is returned." |
|
4461 |
||
4462 |
|i| |
|
4463 |
||
4464 |
" |
|
4465 |
this could have been implemented as: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4466 |
(self infoOf:aPathName) type |
5133 | 4467 |
" |
4468 |
||
4469 |
i := self infoOf:aPathName. |
|
4470 |
i notNil ifTrue:[^ i type]. |
|
4471 |
^ nil. |
|
4472 |
||
4473 |
" |
|
4474 |
OperatingSystem typeOf:'/' |
|
4475 |
OperatingSystem typeOf:'.' |
|
4476 |
OperatingSystem typeOf:'Make.proto' |
|
4477 |
OperatingSystem typeOf:'resources/motif.style' |
|
4478 |
" |
|
4479 |
! |
|
4480 |
||
4481 |
volumeNameOf:aPathString |
|
4482 |
"return the volumeName of the argument, aPath |
|
4483 |
- thats the name of the volume where aPath is. |
|
4484 |
Not all OperatingSystem support/use volumes; on unix, |
|
4485 |
this always returns an empty string." |
|
4486 |
||
7102 | 4487 |
aPathString size < 2 ifTrue:[^ '']. |
5133 | 4488 |
(aPathString at:2) == $: ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4489 |
^ (aPathString at:1) asString. |
5133 | 4490 |
]. |
4491 |
^ '' |
|
4492 |
! ! |
|
4493 |
||
4494 |
!Win32OperatingSystem class methodsFor:'interrupts & signals'! |
|
4495 |
||
4496 |
blockingTest |
|
4497 |
"this is a test method; |
|
4498 |
For testing double CTRL-C in blocking primitives" |
|
4499 |
||
4500 |
%{ |
|
4501 |
while(1) { |
|
7852 | 4502 |
printf("blocking..."); |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4503 |
Sleep(50); |
5133 | 4504 |
} |
4505 |
%}. |
|
4506 |
" |
|
4507 |
OperatingSystem blockingTest |
|
4508 |
" |
|
4509 |
! |
|
4510 |
||
7852 | 4511 |
blockingTest2 |
4512 |
"this is a test method; |
|
4513 |
For testing double CTRL-C in blocking primitives" |
|
4514 |
||
4515 |
%{ |
|
4516 |
while(1) { |
|
4517 |
printf("blocking..."); |
|
4518 |
STX_API_CALL1("Sleep", Sleep, 50); |
|
4519 |
} |
|
4520 |
%}. |
|
4521 |
" |
|
4522 |
OperatingSystem blockingTest2 |
|
4523 |
" |
|
4524 |
! |
|
4525 |
||
5133 | 4526 |
defaultSignal:signalNumber |
4527 |
"revert to the default action on arrival of a (Unix-)signal. |
|
4528 |
Dont confuse Unix signals with smalltalk signals. |
|
4529 |
WARNING: for some signals, it is no good idea to revert to default; |
|
4530 |
for example, the default for SIGINT (i.e. ^C) is to exit; while the |
|
4531 |
default for SIGQUIT (^ \) is to dump core. |
|
4532 |
Also, NOTICE that signal numbers are not portable between unix |
|
4533 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4534 |
a signal." |
|
4535 |
||
4536 |
%{ /* NOCONTEXT */ |
|
4537 |
||
4538 |
if (__isSmallInteger(signalNumber)) { |
|
4539 |
#ifdef SIG_DFL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4540 |
signal(__intVal(signalNumber), SIG_DFL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4541 |
RETURN (self); |
5133 | 4542 |
#endif |
4543 |
} |
|
4544 |
%}. |
|
4545 |
" |
|
4546 |
this error is triggered on non-integer argument |
|
4547 |
" |
|
4548 |
^ self primitiveFailed |
|
4549 |
||
4550 |
"you better save a snapshot image before trying this ..." |
|
4551 |
" |
|
4552 |
'if you hit ^C now, Smalltalk will exit immediately' printNewline. |
|
4553 |
OperatingSystem defaultSignal:(OperatingSystem sigINT). |
|
4554 |
1 to:1000000 do:[:i| ]. |
|
4555 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4556 |
'normal ^C handling again.' printNewline |
|
4557 |
" |
|
4558 |
! |
|
4559 |
||
4560 |
disableIOInterruptsOn:fd |
|
4561 |
"turn off IO interrupts for a filedescriptor" |
|
4562 |
||
4563 |
" |
|
4564 |
this error is triggered on non-integer argument |
|
4565 |
or if the OS does not support IO interrupts. |
|
4566 |
" |
|
4567 |
^ self primitiveFailed |
|
4568 |
! |
|
4569 |
||
4570 |
disableSignal:signalNumber |
|
4571 |
"disable (Unix-) signal processing for signalNumber. |
|
4572 |
Dont confuse Unix signals with smalltalk signals. |
|
4573 |
WARNING: for some signals, it is no good idea to disable |
|
4574 |
them; for example, disabling the SIGINT signal turns off ^C |
|
4575 |
handling. |
|
4576 |
Also, NOTICE that signal numbers are not portable between unix |
|
4577 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4578 |
a signal. |
|
4579 |
Use only for fully debugged stand alone applications." |
|
4580 |
||
4581 |
%{ /* NOCONTEXT */ |
|
4582 |
||
4583 |
if (__isSmallInteger(signalNumber)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4584 |
int sigNo = __intVal(signalNumber); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4585 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4586 |
if (sigNo == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4587 |
RETURN (self); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4588 |
} |
5133 | 4589 |
#ifdef SIG_IGN |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4590 |
signal(sigNo, SIG_IGN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4591 |
RETURN (self); |
5133 | 4592 |
#endif |
4593 |
} |
|
4594 |
%}. |
|
4595 |
" |
|
4596 |
this error is triggered on non-integer argument |
|
4597 |
" |
|
4598 |
^ self primitiveFailed |
|
4599 |
||
4600 |
" |
|
4601 |
'now, ^C is totally ignored ...' printNewline. |
|
4602 |
OperatingSystem disableSignal:(OperatingSystem sigINT). |
|
4603 |
1 to:1000000 do:[:i| ]. |
|
4604 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4605 |
'^C handled again.' printNewline |
|
4606 |
" |
|
4607 |
! |
|
4608 |
||
4609 |
disableTimer |
|
4610 |
"disable timer interrupts. |
|
4611 |
WARNING: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4612 |
the system will not operate correctly with timer interrupts |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4613 |
disabled, because no scheduling or timeouts are possible." |
5133 | 4614 |
|
4615 |
%{ /* NOCONTEXT */ |
|
4616 |
||
4617 |
extern void __win32ClearTimer(); |
|
4618 |
||
4619 |
__win32ClearTimer(); |
|
4620 |
%}. |
|
4621 |
^ true |
|
4622 |
! |
|
4623 |
||
4624 |
enableChildSignalInterrupts |
|
4625 |
"enable childSignal interrupts |
|
4626 |
(SIGCHLD, if the architecture supports it). |
|
4627 |
After enabling, these signals will send the message |
|
4628 |
'childSignalInterrupt' to the ChildSignalInterruptHandler object." |
|
4629 |
||
4630 |
self enableSignal:(self sigCHLD) |
|
4631 |
! |
|
4632 |
||
4633 |
enableIOInterruptsOn:fd |
|
4634 |
"turn on IO interrupts for a filedescriptor" |
|
4635 |
||
4636 |
" |
|
4637 |
this error is triggered on non-integer argument |
|
4638 |
or if the system does not support SIGIO |
|
4639 |
" |
|
4640 |
^ self primitiveFailed |
|
4641 |
! |
|
4642 |
||
4643 |
enableSignal:signalNumber |
|
4644 |
"enable (Unix-)signal processing for signalNumber. |
|
4645 |
Dont confuse Unix signals with smalltalk signals. |
|
4646 |
The signal will be delivered to one of the standard handlers |
|
4647 |
(SIGINT, SIGQUIT, etc) or to a general handler, which |
|
4648 |
sends #signalInterrupt:. |
|
4649 |
||
4650 |
NOTICE that signal numbers are not portable between unix |
|
4651 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4652 |
a signal." |
|
4653 |
||
4654 |
%{ /* NOCONTEXT */ |
|
4655 |
||
4656 |
#ifdef NSIG |
|
4657 |
# define SIG_LIMIT NSIG |
|
4658 |
#else |
|
4659 |
# ifdef SIGUSR2 |
|
4660 |
# define SIG_LIMIT SIGUSR2 |
|
4661 |
# else |
|
4662 |
# ifdef SIGUSR |
|
4663 |
# define SIG_LIMIT SIGUSR |
|
4664 |
# endif |
|
4665 |
# endif |
|
4666 |
#endif |
|
4667 |
||
4668 |
#if defined(SIGPOLL) && !defined(SIGIO) |
|
4669 |
# define SIGIO SIGPOLL |
|
4670 |
#endif |
|
4671 |
||
4672 |
#ifdef SIGCHLD |
|
4673 |
# define CHILD_SIGNAL SIGCHLD |
|
4674 |
#else |
|
4675 |
# ifdef SIGCLD |
|
4676 |
# define CHILD_SIGNAL SIGCLD |
|
4677 |
# endif |
|
4678 |
#endif |
|
4679 |
||
4680 |
int sigNr; |
|
4681 |
||
4682 |
#if defined(SIGINT) || defined(SIGQUIT) |
|
4683 |
# ifndef __signalUserInterrupt |
|
4684 |
extern void __signalUserInterrupt(SIGHANDLER_ARG); |
|
4685 |
# endif |
|
4686 |
#endif |
|
4687 |
||
4688 |
#ifdef SIGFPE |
|
4689 |
# ifndef __signalFpExceptionInterrupt |
|
4690 |
extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG); |
|
4691 |
# endif |
|
4692 |
#endif |
|
4693 |
||
4694 |
#ifdef SIGIO |
|
4695 |
# ifndef __signalIoInterrupt |
|
4696 |
extern void __signalIoInterrupt(SIGHANDLER_ARG); |
|
4697 |
# endif |
|
4698 |
#endif |
|
4699 |
||
4700 |
#ifdef CHILD_SIGNAL |
|
4701 |
# ifndef __signalChildInterrupt |
|
4702 |
extern void __signalChildInterrupt(SIGHANDLER_ARG); |
|
4703 |
# endif |
|
4704 |
#endif |
|
4705 |
||
4706 |
#ifdef SIGPIPE |
|
4707 |
# ifndef __signalPIPEInterrupt |
|
4708 |
extern void __signalPIPEInterrupt(SIGHANDLER_ARG); |
|
4709 |
# endif |
|
4710 |
#endif |
|
4711 |
||
4712 |
#ifdef SIGBUS |
|
4713 |
# ifndef __signalBUSInterrupt |
|
4714 |
extern void __signalBUSInterrupt(SIGHANDLER_ARG); |
|
4715 |
# endif |
|
4716 |
#endif |
|
4717 |
||
4718 |
#ifdef SIGSEGV |
|
4719 |
# ifndef __signalSEGVInterrupt |
|
4720 |
extern void __signalSEGVInterrupt(SIGHANDLER_ARG); |
|
4721 |
# endif |
|
4722 |
#endif |
|
4723 |
||
4724 |
#if defined(SIGILL) || defined(SIGEMT) |
|
4725 |
# ifndef __signalTrapInterrupt |
|
4726 |
extern void __signalTrapInterrupt(SIGHANDLER_ARG); |
|
4727 |
# endif |
|
4728 |
#endif |
|
4729 |
||
4730 |
#ifdef SIGALRM |
|
4731 |
# ifndef WIN32 |
|
4732 |
# ifndef __signalTimerInterrupt |
|
4733 |
extern void __signalTimerInterrupt(SIGHANDLER_ARG); |
|
4734 |
# endif |
|
4735 |
# endif |
|
4736 |
#endif |
|
4737 |
||
4738 |
#ifndef __signalInterrupt |
|
4739 |
extern void __signalInterrupt(SIGHANDLER_ARG); |
|
4740 |
#endif |
|
4741 |
void (*handler)(SIGHANDLER_ARG); |
|
4742 |
||
4743 |
if (__isSmallInteger(signalNumber) |
|
4744 |
&& ((sigNr = __intVal(signalNumber)) >= 0) |
|
4745 |
#ifdef SIG_LIMIT |
|
4746 |
&& (sigNr <= SIG_LIMIT) |
|
4747 |
#endif |
|
4748 |
) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4749 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4750 |
* standard signals are forced into standard handlers |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4751 |
* - all others go into general signalInterrupt |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4752 |
*/ |
5133 | 4753 |
#if defined(SIGPOLL) && defined(SIGIO) |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4754 |
if (sigNr == SIGPOLL) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4755 |
sigNr = SIGIO; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4756 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4757 |
switch (sigNr) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4758 |
case 0: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4759 |
/* enabling a non-supported signal */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4760 |
RETURN (self); |
5133 | 4761 |
|
4762 |
#ifdef SIGBREAK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4763 |
case SIGBREAK: |
5133 | 4764 |
#endif |
4765 |
#ifdef SIGINT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4766 |
case SIGINT: |
5133 | 4767 |
#endif |
4768 |
#ifdef SIGQUIT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4769 |
case SIGQUIT: |
5133 | 4770 |
#endif |
4771 |
#ifdef SIGNALDEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4772 |
printf("ConsoleSignal %d\n",sigNr); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4773 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4774 |
SetConsoleCtrlHandler((PHANDLER_ROUTINE)__signalUserInterruptWIN32,TRUE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4775 |
RETURN (self); |
5133 | 4776 |
#ifdef SIGFPE |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4777 |
case SIGFPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4778 |
handler = __signalFpExceptionInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4779 |
break; |
5133 | 4780 |
#endif |
4781 |
||
4782 |
#ifdef SIGPIPE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4783 |
case SIGPIPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4784 |
handler = __signalPIPEInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4785 |
break; |
5133 | 4786 |
#endif |
4787 |
#ifdef SIGBUS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4788 |
case SIGBUS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4789 |
handler = __signalBUSInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4790 |
break; |
5133 | 4791 |
#endif |
4792 |
#ifdef SIGSEGV |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4793 |
case SIGSEGV: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4794 |
handler = __signalSEGVInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4795 |
break; |
5133 | 4796 |
#endif |
4797 |
#ifdef SIGILL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4798 |
case SIGILL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4799 |
handler = __signalTrapInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4800 |
break; |
5133 | 4801 |
#endif |
4802 |
#ifdef SIGEMT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4803 |
case SIGEMT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4804 |
handler = __signalTrapInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4805 |
break; |
5133 | 4806 |
#endif |
4807 |
#ifdef SIGIO |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4808 |
case SIGIO: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4809 |
handler = __signalIoInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4810 |
break; |
5133 | 4811 |
#endif |
4812 |
||
4813 |
#ifdef CHILD_SIGNAL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4814 |
case CHILD_SIGNAL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4815 |
handler = __signalChildInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4816 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4817 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4818 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4819 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4820 |
handler = __signalInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4821 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4822 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4823 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4824 |
{ |
5133 | 4825 |
#ifdef HAS_SIGACTION |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4826 |
struct sigaction act; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4827 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4828 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4829 |
* Do not add SA_RESTART here. A signal can cause a |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4830 |
* thread switch, another thread can do a garbage collect |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4831 |
* and restarted system calls may write into old |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4832 |
* (collected) addresses. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4833 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4834 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4835 |
act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4836 |
sigemptyset(&act.sa_mask); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4837 |
act.sa_handler = handler; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4838 |
sigaction(sigNr, &act, 0); |
5133 | 4839 |
#else |
4840 |
# ifdef HAS_SIGVEC |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4841 |
struct sigvec vec; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4842 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4843 |
vec.sv_flags = SV_INTERRUPT; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4844 |
sigemptyset(&vec.sv_mask); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4845 |
vec.sv_handler = handler; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4846 |
sigvec(sigNr, &vec, NULL); |
5133 | 4847 |
# else |
4848 |
# ifdef WIN32 |
|
4849 |
# ifdef SIGNALDEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4850 |
printf("signal %d can't change handler\n",sigNr); |
5133 | 4851 |
# endif |
4852 |
# else |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4853 |
(void) signal(sigNr, handler); |
5133 | 4854 |
# endif |
4855 |
# endif |
|
4856 |
#endif |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4857 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4858 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4859 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4860 |
* maybe, we should Return the old enable-status |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4861 |
* as boolean here ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4862 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4863 |
RETURN (self); |
5133 | 4864 |
} |
4865 |
%}. |
|
4866 |
||
4867 |
" |
|
4868 |
this error is triggered on non-integer argument, or |
|
4869 |
if the signal number is not in the valid range (1..NSIG) |
|
4870 |
" |
|
4871 |
^ self primitiveFailed |
|
4872 |
! |
|
4873 |
||
4874 |
enableTimer:milliSeconds |
|
4875 |
"setup for a timerInterrupt, to be signalled after some (real) time." |
|
4876 |
||
4877 |
%{ /* NOCONTEXT */ |
|
4878 |
extern void __win32SetTimer(); |
|
4879 |
||
4880 |
if (__isSmallInteger(milliSeconds)) { |
|
7852 | 4881 |
__win32SetTimer( __intVal(milliSeconds) ); |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4882 |
RETURN (true); |
5133 | 4883 |
} |
4884 |
%}. |
|
4885 |
^ false |
|
4886 |
! |
|
4887 |
||
6535 | 4888 |
isFatalSignal:aNumber |
4889 |
"return true if a signal with number aNumber is a fatal signal, |
|
4890 |
i.e. some severe internal error occured" |
|
4891 |
||
4892 |
^ (aNumber == self sigSEGV) |
|
4893 |
or:[aNumber == self sigILL |
|
4894 |
or:[aNumber == self sigBUS]] |
|
4895 |
! |
|
4896 |
||
5133 | 4897 |
killProcess:processId |
4898 |
"kill a process. |
|
4899 |
The process terminates immediately and has no chance to perform any cleanup actions. |
|
4900 |
||
4901 |
WARNING: in order to avoid zombie processes (on unix), |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4902 |
you have to fetch the processes exitstatus with |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4903 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
5133 | 4904 |
|
4905 |
self terminateProcess:processId |
|
4906 |
! |
|
4907 |
||
4908 |
sendSignal:signalNumber to:processId |
|
4909 |
"send a unix signal to some process (maybe myself). |
|
4910 |
Returns false if any error occurred, true otherwise. |
|
4911 |
||
4912 |
Do not confuse UNIX signals with Smalltalk-Signals. |
|
4913 |
||
4914 |
WARNING: in order to avoid zombie processes (on unix), |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4915 |
you may have to fetch the processes exitstatus with |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4916 |
OperatingSystem>>getStatusOfProcess:aProcessId |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4917 |
if the signal terminates that process." |
5133 | 4918 |
|
4919 |
"/ |
|
4920 |
"/ either invalid argument (non-integers) |
|
4921 |
"/ or not supported by OS |
|
4922 |
"/ |
|
4923 |
^ self primitiveFailed |
|
4924 |
! |
|
4925 |
||
4926 |
terminateProcess:processId |
|
4927 |
"terminate a process. |
|
4928 |
The process has a chance to do some cleanup. |
|
4929 |
WIN32: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4930 |
Under unix, we have terminateProcess, which does a soft |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4931 |
terminate (giving the process a chance to cleanup) and |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4932 |
killProcess, which does a hard terminate. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4933 |
Under WIN32, both (currently) use the TerminateProcess |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4934 |
function, which unconditionally causes a process to exit. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4935 |
I.e. under WIN32, the process has no chance to perform cleanup. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4936 |
Use it only in extreme circumstances. The state of |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4937 |
global data maintained by dynamic-link libraries (DLLs) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4938 |
may be compromised if TerminateProcess is used. |
7065 | 4939 |
TODO: send it a WM_QUIT instead, to allow for proper shutdown." |
4940 |
||
4941 |
self terminateProcess:processId exitCode:0 |
|
4942 |
! |
|
4943 |
||
4944 |
terminateProcess:processId exitCode:exitCode |
|
4945 |
"terminate a process. |
|
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
4946 |
The process should have a chance to do some cleanup. |
7065 | 4947 |
WIN32: |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4948 |
Under unix, we have terminateProcess, which does a soft |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4949 |
terminate (giving the process a chance to cleanup) and |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4950 |
killProcess, which does a hard terminate. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4951 |
Under WIN32, both (currently) use the TerminateProcess |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4952 |
function, which unconditionally causes a process to exit. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4953 |
I.e. under WIN32, the process has no chance to perform cleanup. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4954 |
Use it only in extreme circumstances. The state of |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4955 |
global data maintained by dynamic-link libraries (DLLs) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4956 |
may be compromised if TerminateProcess is used. |
5133 | 4957 |
TODO: send it a WM_QUIT instead, to allow for proper shutdown." |
4958 |
||
4959 |
%{ |
|
7662 | 4960 |
if (__isExternalAddressLike(processId) ) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4961 |
HANDLE __pid = _HANDLEVal(processId); |
5133 | 4962 |
|
4963 |
#ifdef PROCESS1DEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4964 |
printf("Terminate ProcessHandle %x\n", __pid); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4965 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4966 |
if (__pid != 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4967 |
TerminateProcess(__pid, __intVal(exitCode)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4968 |
} |
5133 | 4969 |
} |
4970 |
#ifdef PROCESS1DEBUGWIN32 |
|
4971 |
else { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4972 |
printf("Terminate wrong ProcessHandle\n"); |
5133 | 4973 |
} |
4974 |
#endif |
|
4975 |
%} |
|
4976 |
||
4977 |
"Modified: / 28.12.1995 / 15:05:37 / stefan" |
|
4978 |
"Modified: / 27.1.1998 / 20:05:47 / cg" |
|
4979 |
! |
|
4980 |
||
4981 |
terminateProcessGroup:processGroupId |
|
4982 |
"terminate a process group. |
|
7645
fd98d4cfa617
terminateProcess and closePid are now two separate operations.
Claus Gittinger <cg@exept.de>
parents:
7638
diff
changeset
|
4983 |
The processes should have a chance to do some cleanup. |
5133 | 4984 |
WIN32: |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4985 |
The TerminateProcess function is used to unconditionally cause |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4986 |
a process to exit. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4987 |
Use it only in extreme circumstances. The state of |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4988 |
global data maintained by dynamic-link libraries (DLLs) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4989 |
may be compromised if TerminateProcess is used. |
5133 | 4990 |
Not implemented - TODO: enumerate all sub-processes and terminate them all ..." |
4991 |
||
4992 |
%{ |
|
7662 | 4993 |
if (__isExternalAddressLike(processGroupId) ) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4994 |
HANDLE __pgid = _HANDLEVal(processGroupId); |
5133 | 4995 |
|
4996 |
#ifdef PROCESS1DEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4997 |
printf("primTerminateProcessGroup ProcessHandle %x not yet implemented.\n", __pgid); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4998 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4999 |
if (__pgid != 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5000 |
} |
5133 | 5001 |
} |
5002 |
#ifdef PROCESS1DEBUGWIN32 |
|
5003 |
else { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5004 |
printf("primTerminateProcessGroup wrong ProcessGroupHandle\n"); |
5133 | 5005 |
} |
5006 |
#endif |
|
5007 |
%} |
|
5008 |
! ! |
|
5009 |
||
5010 |
!Win32OperatingSystem class methodsFor:'ipc support'! |
|
5011 |
||
5012 |
makePipe |
|
5013 |
"make a pipe, return array with two filedescriptors on success, |
|
5014 |
nil on failure. |
|
5015 |
This is a lowLevel entry, not for public use. |
|
5016 |
See ExternalStream>>makePipe for a more user-friendly, public interface." |
|
5017 |
||
5018 |
|fd1 fd2| |
|
5019 |
||
5020 |
%{ |
|
5021 |
HANDLE pipeRead = (HANDLE)0; |
|
5022 |
HANDLE pipeWrite = (HANDLE)0; |
|
5023 |
||
5024 |
SECURITY_ATTRIBUTES process; |
|
5025 |
||
5026 |
process.nLength = sizeof( process ); |
|
5027 |
process.lpSecurityDescriptor = NULL; |
|
5028 |
process.bInheritHandle = TRUE; |
|
5029 |
||
5030 |
if( ! CreatePipe( &pipeRead, &pipeWrite, &process, 0 ) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5031 |
@global(LastErrorNumber) = __MKSMALLINT( __WIN32_ERR(GetLastError()) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5032 |
RETURN ( nil ); |
5133 | 5033 |
} |
5034 |
||
5035 |
#ifdef USE_HANDLES |
|
5036 |
fd1 = __MKEXTERNALADDRESS(pipeRead); |
|
5037 |
fd2 = __MKEXTERNALADDRESS(pipeWrite); |
|
5038 |
#else |
|
5039 |
/* |
|
5040 |
* make fileDescriptors from handles |
|
5041 |
*/ |
|
5042 |
# ifdef PROCESSDEBUGWIN32 |
|
5043 |
printf("piperead %x\n",pipeRead); |
|
5044 |
printf("pipewrite %x\n",pipeWrite); |
|
5045 |
# endif |
|
5046 |
fd1 = __MKSMALLINT(_open_osfhandle(pipeRead, O_BINARY)); |
|
5047 |
fd2 = __MKSMALLINT(_open_osfhandle(pipeWrite, O_BINARY)); |
|
5048 |
#endif |
|
5049 |
%}. |
|
5050 |
fd1 notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5051 |
^ Array with:fd1 with:fd2. |
5133 | 5052 |
]. |
5053 |
^ nil |
|
5054 |
! ! |
|
5055 |
||
5056 |
!Win32OperatingSystem class methodsFor:'misc'! |
|
5057 |
||
5058 |
closePid:pid |
|
5059 |
"free pid resource" |
|
5060 |
%{ |
|
7662 | 5061 |
if (__isExternalAddressLike(pid) ) { |
5062 |
HANDLE __pid = _HANDLEVal(pid); |
|
5063 |
||
5064 |
if (__pid != 0) { |
|
5133 | 5065 |
#ifdef PROCESSDEBUGWIN32 |
7662 | 5066 |
printf("Close ProcessHandle %x\n", __pid); |
5067 |
#endif |
|
5068 |
CloseHandle(__pid); |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5069 |
_HANDLEVal(pid) = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5070 |
} |
5133 | 5071 |
} |
5072 |
%}. |
|
5073 |
^ true. |
|
5074 |
||
5075 |
"Created: 28.1.1998 / 14:23:04 / md" |
|
5076 |
"Modified: 28.1.1998 / 14:27:18 / md" |
|
5077 |
! ! |
|
5078 |
||
5079 |
!Win32OperatingSystem class methodsFor:'os queries'! |
|
5080 |
||
5081 |
executableFileExtensions |
|
5082 |
"return a collection of extensions for executable program files. |
|
5083 |
Only req'd for msdos like systems ..." |
|
5084 |
||
5085 |
^ #('com' 'exe') |
|
5086 |
||
5087 |
"Created: 2.5.1997 / 11:42:29 / cg" |
|
5088 |
! |
|
5089 |
||
5090 |
getDomainName |
|
5091 |
"return the domain this host is in. |
|
5092 |
Notice: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5093 |
not all systems support this; on some, 'unknown' is returned." |
5133 | 5094 |
|
5095 |
|name idx hostName k| |
|
5096 |
||
5097 |
DomainName notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5098 |
^ DomainName |
5133 | 5099 |
]. |
5100 |
||
5101 |
name := self getEnvironment:'DOMAIN'. |
|
5102 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5103 |
name := self getEnvironment:'DOMAINNAME'. |
5133 | 5104 |
]. |
5105 |
||
5106 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5107 |
"/ sometimes, we can extract the domainName from the hostName ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5108 |
hostName := self getHostName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5109 |
hostName notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5110 |
idx := hostName indexOf:$.. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5111 |
idx ~~ 0 ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5112 |
name := hostName copyFrom:idx+1. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5113 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5114 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5115 |
name isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5116 |
"/ ok, search the registry ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5117 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5118 |
"/ under NT, it is found there ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5119 |
k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5120 |
k notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5121 |
k subKeysDo:[:subKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5122 |
subKey subKeysDo:[:subSubKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5123 |
|tcp params| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5124 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5125 |
(subSubKey path asLowercase endsWith:'services') ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5126 |
tcp := subSubKey subKeyNamed:'tcpip'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5127 |
tcp notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5128 |
params := tcp subKeyNamed:'parameters'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5129 |
params notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5130 |
name := params valueNamed:'Domain'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5131 |
params close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5132 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5133 |
tcp close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5134 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5135 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5136 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5137 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5138 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5139 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5140 |
name isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5141 |
"/ under Win95/Win98, it is found there ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5142 |
k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5143 |
k notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5144 |
name := k valueNamed:'Domain'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5145 |
k close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5146 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5147 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5148 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5149 |
name isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5150 |
'Win32OperatingSystem [warning]: cannot find out domainname' errorPrintCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5151 |
name := 'unknown'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5152 |
] |
5133 | 5153 |
]. |
5154 |
DomainName := name. |
|
5155 |
^ name |
|
5156 |
||
5157 |
" |
|
5158 |
DomainName := nil. OperatingSystem getDomainName |
|
5159 |
OperatingSystem getHostName |
|
5160 |
" |
|
5161 |
||
5162 |
"Modified: 26.4.1996 / 10:04:54 / stefan" |
|
5163 |
! |
|
5164 |
||
5165 |
getEnvironment:aStringOrSymbol |
|
5166 |
"get an environment string" |
|
5167 |
||
5168 |
%{ /* NOCONTEXT */ |
|
5169 |
||
5170 |
char *env; |
|
5171 |
||
5172 |
if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5173 |
char buff[512]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5174 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5175 |
env = NULL; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5176 |
if (GetEnvironmentVariable(__stringVal(aStringOrSymbol), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5177 |
buff, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5178 |
sizeof(buff)-1)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5179 |
env = buff; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5180 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5181 |
if (env) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5182 |
RETURN ( __MKSTRING(env) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5183 |
} |
5133 | 5184 |
} |
5185 |
%} |
|
5186 |
. |
|
5187 |
^ nil |
|
5188 |
||
5189 |
" |
|
5190 |
OperatingSystem getEnvironment:'LANG' |
|
5191 |
OperatingSystem getEnvironment:'LOGIN' |
|
5192 |
OperatingSystem getEnvironment:'HOME' |
|
5193 |
OperatingSystem getEnvironment:'NNTPSERVER' |
|
5194 |
OperatingSystem getEnvironment:'MAIL' |
|
5195 |
OperatingSystem getEnvironment:'PATH' |
|
5196 |
" |
|
5197 |
! |
|
5198 |
||
5199 |
getHostName |
|
5200 |
"return the hostname we are running on - if there is |
|
5201 |
a HOST environment variable, we are much faster here ... |
|
5202 |
Notice: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5203 |
not all systems support this; on some, 'unknown' is returned." |
5133 | 5204 |
|
5205 |
|name idx| |
|
5206 |
||
5207 |
HostName notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5208 |
^ HostName |
5133 | 5209 |
]. |
5210 |
||
5211 |
%{ /* STACK: 2048 */ |
|
5212 |
#if defined(HAS_GETHOSTNAME) |
|
5213 |
char buffer[256]; |
|
5214 |
||
5215 |
if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5216 |
name = __MKSTRING(buffer); |
5133 | 5217 |
} |
5218 |
#else |
|
5219 |
char buffer[128]; |
|
5220 |
int buffSize = sizeof(buffer); |
|
5221 |
||
5222 |
if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5223 |
name = __MKSTRING(buffer); |
5133 | 5224 |
} |
5225 |
#endif |
|
5226 |
%}. |
|
5227 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5228 |
name := self getEnvironment:'HOST'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5229 |
name isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5230 |
name := self getEnvironment:'HOSTNAME'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5231 |
] |
5133 | 5232 |
]. |
5233 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5234 |
'Win32OperatingSystem [warning]: cannot find out hostname' errorPrintCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5235 |
name := 'unknown'. |
5133 | 5236 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5237 |
"/ on some systems, the hostname already contains the domain. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5238 |
"/ decompose it here. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5239 |
idx := name indexOf:$.. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5240 |
idx ~~ 0 ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5241 |
DomainName := name copyFrom:(idx+1). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5242 |
name := name copyTo:(idx-1). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5243 |
] |
5133 | 5244 |
]. |
5245 |
HostName := name. |
|
5246 |
^ name |
|
5247 |
||
5248 |
" |
|
5249 |
OperatingSystem getHostName |
|
5250 |
" |
|
5251 |
! |
|
5252 |
||
7775 | 5253 |
getLanguage |
5254 |
"return the domain this host is in. |
|
5255 |
Notice: |
|
7852 | 5256 |
not all systems support this; on some, 'unknown' is returned." |
7777 | 5257 |
|
5258 |
|name| |
|
7775 | 5259 |
|
5260 |
name := self getEnvironment:'LANG'. |
|
5261 |
name isNil ifTrue:[ |
|
7852 | 5262 |
"/ ok, search the registry ... |
5263 |
"/ under XP, it is found there ... |
|
5264 |
name := RegistryEntry |
|
5265 |
stringValueFor:'sLanguage' |
|
5266 |
atKey:'HKEY_CURRENT_USER\Control Panel\International'. |
|
5267 |
name notNil ifTrue:[ |
|
5268 |
name := self mapLanguage:name. |
|
5269 |
]. |
|
7775 | 5270 |
]. |
5271 |
^ name |
|
5272 |
||
5273 |
" |
|
5274 |
OperatingSystem getLanguage |
|
5275 |
" |
|
5276 |
"Modified: 26.4.1996 / 10:04:54 / stefan" |
|
5277 |
! |
|
5278 |
||
5133 | 5279 |
getLocaleInfo |
5280 |
"return a dictionary filled with values from the locale information; |
|
5281 |
Not all fields may be present, depending on the OS's setup and capabilities. |
|
5282 |
Possible fields are: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5283 |
decimalPoint <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5284 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5285 |
thousandsSep <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5286 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5287 |
internationalCurrencySymbol <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5288 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5289 |
currencySymbol <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5290 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5291 |
monetaryDecimalPoint <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5292 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5293 |
monetaryThousandsSeparator <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5294 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5295 |
positiveSign <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5296 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5297 |
negativeSign <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5298 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5299 |
internationalFractionalDigits <Integer> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5300 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5301 |
fractionalDigits <Integer> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5302 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5303 |
positiveSignPrecedesCurrencySymbol <Boolean> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5304 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5305 |
negativeSignPrecedesCurrencySymbol <Boolean> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5306 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5307 |
positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5308 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5309 |
negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5310 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5311 |
positiveSignPosition <Symbol> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5312 |
one of: #parenthesesAround, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5313 |
#signPrecedes, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5314 |
#signSuceeds, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5315 |
#signPrecedesCurrencySymbol, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5316 |
#signSuceedsCurrencySymbol |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5317 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5318 |
negativeSignPosition <like above> |
5133 | 5319 |
|
5320 |
it is up to the application to deal with undefined values. |
|
5321 |
||
5322 |
Notice, that (for now), the system does not use this information; |
|
5323 |
it should be used by applications as required. |
|
5324 |
" |
|
5325 |
||
5326 |
|info val| |
|
5327 |
||
5328 |
LocaleInfo notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5329 |
"/ return the internal info; useful on systems which do not |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5330 |
"/ support this. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5331 |
^ LocaleInfo |
5133 | 5332 |
]. |
5333 |
||
5334 |
info := IdentityDictionary new. |
|
5335 |
%{ |
|
5336 |
char *decimalPoint; /* something like "." (US) or "," (german) */ |
|
5337 |
char *thousandsSep; /* something like "," (US) or "." (german) */ |
|
5338 |
char *intCurrencySymbol; /* international currency symbol; something like "USD " "DM " */ |
|
5339 |
char *currencySymbol; /* local currency symbol; something like "USD " "DM " */ |
|
5340 |
char *monDecimalPoint; /* money: decimal point */ |
|
5341 |
char *monThousandsSep; /* money: thousands sep */ |
|
5342 |
char *positiveSign; |
|
5343 |
char *negativeSign; |
|
5344 |
int intFractDigits; /* money: international digits after decPoint */ |
|
5345 |
int fractDigits; /* money: local digits after decPoint */ |
|
5346 |
int csPosPrecedes; /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */ |
|
5347 |
int csNegPrecedes; /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */ |
|
5348 |
int csPosSepBySpace; /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */ |
|
5349 |
int csNegSepBySpace; /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */ |
|
5350 |
int csPosSignPosition; /* money: 0: ()'s around the value & currency symbol */ |
|
5351 |
int csNegSignPosition; /* 1: sign precedes the value & currency symbol */ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5352 |
/* 2: sign succeeds the value & currency symbol */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5353 |
/* 3: sign immediately precedes the currency symbol */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5354 |
/* 4: sign immediately suceeds the currency symbol */ |
5133 | 5355 |
|
5356 |
#if defined(HAS_LOCALECONV) |
|
5357 |
struct lconv *conf; |
|
5358 |
||
5359 |
conf = localeconv(); |
|
5360 |
if (conf) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5361 |
decimalPoint = conf->decimal_point; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5362 |
thousandsSep = conf->thousands_sep; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5363 |
intCurrencySymbol = conf->int_curr_symbol; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5364 |
currencySymbol = conf->currency_symbol; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5365 |
monDecimalPoint = conf->mon_decimal_point; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5366 |
monThousandsSep = conf->mon_thousands_sep; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5367 |
positiveSign = conf->positive_sign; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5368 |
negativeSign = conf->negative_sign; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5369 |
intFractDigits = conf->int_frac_digits; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5370 |
fractDigits = conf->frac_digits; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5371 |
csPosPrecedes = conf->p_cs_precedes; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5372 |
csNegPrecedes = conf->n_cs_precedes; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5373 |
csPosSepBySpace = conf->p_sep_by_space; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5374 |
csNegSepBySpace = conf->n_sep_by_space; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5375 |
csPosSignPosition = conf->p_sign_posn; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5376 |
csNegSignPosition = conf->n_sign_posn; |
5133 | 5377 |
} |
5378 |
#else |
|
5379 |
decimalPoint = (char *)0; |
|
5380 |
thousandsSep = (char *)0; |
|
5381 |
intCurrencySymbol = (char *)0; |
|
5382 |
currencySymbol = (char *)0; |
|
5383 |
monDecimalPoint = (char *)0; |
|
5384 |
monThousandsSep = (char *)0; |
|
5385 |
positiveSign = (char *)0; |
|
5386 |
negativeSign =(char *)0; |
|
5387 |
intFractDigits = -1; |
|
5388 |
fractDigits = -1; |
|
5389 |
csPosPrecedes = -1; |
|
5390 |
csNegPrecedes = -1; |
|
5391 |
csPosSepBySpace = -1; |
|
5392 |
csNegSepBySpace = -1; |
|
5393 |
csPosSignPosition = -1; |
|
5394 |
csNegSignPosition = -1; |
|
5395 |
#endif |
|
5396 |
if (decimalPoint) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5397 |
val = __MKSTRING(decimalPoint); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5398 |
__AT_PUT_(info, @symbol(decimalPoint), val); |
5133 | 5399 |
} |
5400 |
if (thousandsSep) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5401 |
val = __MKSTRING(thousandsSep); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5402 |
__AT_PUT_(info, @symbol(thousandsSeparator), val); |
5133 | 5403 |
} |
5404 |
if (intCurrencySymbol) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5405 |
val = __MKSTRING(intCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5406 |
__AT_PUT_(info, @symbol(internationCurrencySymbol), val); |
5133 | 5407 |
} |
5408 |
if (currencySymbol) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5409 |
val = __MKSTRING(currencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5410 |
__AT_PUT_(info, @symbol(currencySymbol), val); |
5133 | 5411 |
} |
5412 |
if (monDecimalPoint) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5413 |
val = __MKSTRING(monDecimalPoint); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5414 |
__AT_PUT_(info, @symbol(monetaryDecimalPoint), val); |
5133 | 5415 |
} |
5416 |
if (monThousandsSep) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5417 |
val = __MKSTRING(monThousandsSep); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5418 |
__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val); |
5133 | 5419 |
} |
5420 |
if (positiveSign) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5421 |
val = __MKSTRING(positiveSign); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5422 |
__AT_PUT_(info, @symbol(positiveSign), val); |
5133 | 5423 |
} |
5424 |
if (negativeSign) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5425 |
val = __MKSTRING(negativeSign); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5426 |
__AT_PUT_(info, @symbol(negativeSign), val); |
5133 | 5427 |
} |
5428 |
if (intFractDigits >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5429 |
__AT_PUT_(info, @symbol(internationalFractionalDigits), __MKSMALLINT(intFractDigits)); |
5133 | 5430 |
} |
5431 |
if (fractDigits >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5432 |
__AT_PUT_(info, @symbol(fractionalDigits), __MKSMALLINT(fractDigits)); |
5133 | 5433 |
} |
5434 |
if (csPosPrecedes >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5435 |
if (csPosPrecedes == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5436 |
val = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5437 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5438 |
val = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5439 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5440 |
__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val ); |
5133 | 5441 |
} |
5442 |
if (csNegPrecedes >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5443 |
if (csNegPrecedes == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5444 |
val = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5445 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5446 |
val = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5447 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5448 |
__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val ); |
5133 | 5449 |
} |
5450 |
if (csPosSepBySpace >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5451 |
if (csPosSepBySpace == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5452 |
val = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5453 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5454 |
val = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5455 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5456 |
__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val); |
5133 | 5457 |
} |
5458 |
if (csNegSepBySpace >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5459 |
if (csNegSepBySpace == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5460 |
val = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5461 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5462 |
val = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5463 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5464 |
__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val); |
5133 | 5465 |
} |
5466 |
switch (csPosSignPosition) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5467 |
case 0: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5468 |
val = @symbol(parenthesesAround); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5469 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5470 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5471 |
case 1: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5472 |
val = @symbol(signPrecedes); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5473 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5474 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5475 |
case 2: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5476 |
val = @symbol(signSuceeds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5477 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5478 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5479 |
case 3: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5480 |
val = @symbol(signPrecedesCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5481 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5482 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5483 |
case 4: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5484 |
val = @symbol(signSuceedsCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5485 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5486 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5487 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5488 |
val = nil; |
5133 | 5489 |
} |
5490 |
if (val != nil) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5491 |
__AT_PUT_(info, @symbol(positiveSignPosition), val); |
5133 | 5492 |
} |
5493 |
||
5494 |
switch (csNegSignPosition) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5495 |
case 0: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5496 |
val = @symbol(parenthesesAround); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5497 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5498 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5499 |
case 1: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5500 |
val = @symbol(signPrecedes); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5501 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5502 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5503 |
case 2: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5504 |
val = @symbol(signSuceeds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5505 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5506 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5507 |
case 3: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5508 |
val = @symbol(signPrecedesCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5509 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5510 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5511 |
case 4: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5512 |
val = @symbol(signSuceedsCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5513 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5514 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5515 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5516 |
val = nil; |
5133 | 5517 |
} |
5518 |
if (val != nil) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5519 |
__AT_PUT_(info, @symbol(negativeSignPosition), val); |
5133 | 5520 |
} |
5521 |
%}. |
|
5522 |
^ info |
|
5523 |
||
5524 |
" |
|
5525 |
OperatingSystem getLocaleInfo |
|
5526 |
" |
|
5527 |
||
5528 |
"Created: 23.12.1995 / 14:19:20 / cg" |
|
5529 |
! |
|
5530 |
||
7287
b10efc6c9407
Fix spelling (getNetworkMACAddresses)
Stefan Vogel <sv@exept.de>
parents:
7199
diff
changeset
|
5531 |
getNetworkMACAddresses |
6542 | 5532 |
"return a dictionary filled with |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5533 |
key -> name of interface |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5534 |
value -> the MAC adress (as ByteArray) |
6542 | 5535 |
for each interface |
5536 |
" |
|
5537 |
||
7840 | 5538 |
|info nAdapters rawData entry |
5539 |
name description macAddress ipAddress ipAddressMask| |
|
5540 |
||
5541 |
rawData := Array new:50. |
|
6542 | 5542 |
%{ |
6543 | 5543 |
#ifndef NO_GETADAPTERSINFO |
6542 | 5544 |
IP_ADAPTER_INFO AdapterInfo[32]; |
5545 |
DWORD dwBufLen = sizeof(AdapterInfo); |
|
5546 |
DWORD dwStatus; |
|
5547 |
||
5548 |
dwStatus = GetAdaptersInfo( |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5549 |
AdapterInfo, // [out] buffer to receive data |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5550 |
&dwBufLen); // [in] size of receive data buffer |
6542 | 5551 |
|
5552 |
if (dwStatus == ERROR_SUCCESS) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5553 |
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5554 |
unsigned char *bP; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5555 |
int nA = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5556 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5557 |
bP = __byteArrayVal(rawData); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5558 |
do { |
7840 | 5559 |
/* |
5560 |
* temporary undef String to avoid a #define-conflict |
|
5561 |
* between ST/X's String and Windows String typedef |
|
5562 |
*/ |
|
5563 |
# undef String |
|
5564 |
name = __MKSTRING(pAdapterInfo->AdapterName); |
|
5565 |
description = __MKSTRING(pAdapterInfo->Description); |
|
5566 |
macAddress = __MKBYTEARRAY(pAdapterInfo->Address, 6); |
|
5567 |
ipAddress = __MKSTRING(pAdapterInfo->IpAddressList.IpAddress.String); |
|
5568 |
ipAddressMask = __MKSTRING(pAdapterInfo->IpAddressList.IpMask.String); |
|
5569 |
entry = __ARRAY_NEW_INT(5); |
|
5570 |
/* |
|
5571 |
* back to ST/X's String definition |
|
5572 |
*/ |
|
5573 |
# ifdef __DEF_String |
|
5574 |
# define String __DEF_String |
|
5575 |
# endif |
|
5576 |
__ArrayInstPtr(entry)->a_element[0] = name; __STORE(entry, name); |
|
5577 |
__ArrayInstPtr(entry)->a_element[1] = description; __STORE(entry, description); |
|
5578 |
__ArrayInstPtr(entry)->a_element[2] = macAddress; __STORE(entry, macAddress); |
|
5579 |
__ArrayInstPtr(entry)->a_element[3] = ipAddress; __STORE(entry, ipAddress); |
|
5580 |
__ArrayInstPtr(entry)->a_element[4] = ipAddressMask; __STORE(entry, ipAddressMask); |
|
5581 |
||
5582 |
__ArrayInstPtr(rawData)->a_element[nA] = entry; __STORE(rawData, entry); |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5583 |
nA++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5584 |
pAdapterInfo = pAdapterInfo->Next; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5585 |
} while(pAdapterInfo); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5586 |
nAdapters = __mkSmallInteger(nA); |
6542 | 5587 |
} |
6543 | 5588 |
#endif /* not NO_GETADAPTERSINFO */ |
6542 | 5589 |
%}. |
5590 |
nAdapters isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5591 |
self primitiveFailed. |
6542 | 5592 |
]. |
7840 | 5593 |
|
5594 |
info := Dictionary new. |
|
5595 |
1 to:nAdapters do:[:i | |
|
5596 |
|entry name macAddr| |
|
5597 |
||
5598 |
entry := rawData at:i. |
|
5599 |
name := entry at:1. |
|
5600 |
macAddr := entry at:3. |
|
5601 |
info at:name put:macAddr. |
|
5602 |
]. |
|
5603 |
^ info |
|
5604 |
||
5605 |
" |
|
5606 |
OperatingSystem getNetworkMACAddresses |
|
5607 |
" |
|
6542 | 5608 |
! |
5609 |
||
5133 | 5610 |
getProcessId |
5611 |
"return the (unix-)processId" |
|
5612 |
||
5613 |
%{ /* NOCONTEXT */ |
|
5614 |
||
5615 |
int pid = 0; |
|
5616 |
||
5617 |
pid = GetCurrentProcessId() & 0x3FFFFFFF; |
|
5618 |
RETURN ( __MKSMALLINT(pid) ); |
|
5619 |
%} |
|
5620 |
" |
|
5621 |
OperatingSystem getProcessId |
|
5622 |
" |
|
5623 |
! |
|
5624 |
||
5625 |
getSystemID |
|
5626 |
"if supported by the OS, return the systemID; |
|
5627 |
a unique per machine identification. |
|
5628 |
WARNING: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5629 |
not all systems support this; on some, 'unknown' is returned." |
5133 | 5630 |
|
5631 |
%{ /* NO_CONTEXT */ |
|
5632 |
#if defined(HAS_GETHOSTID) |
|
5633 |
int runningId; |
|
5634 |
OBJ arr; |
|
5635 |
||
5636 |
runningId = gethostid(); |
|
5637 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4); |
|
5638 |
*(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId; |
|
5639 |
RETURN (arr); |
|
5640 |
#endif |
|
5641 |
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL) |
|
5642 |
{ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5643 |
char buffer[128]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5644 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5645 |
buffer[0] = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5646 |
if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5647 |
buffer[127] = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5648 |
if (strlen(buffer) > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5649 |
RETURN(__MKSTRING(buffer)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5650 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5651 |
} |
5133 | 5652 |
} |
5653 |
#endif |
|
5654 |
%}. |
|
5655 |
^ 'unknown' |
|
5656 |
||
5657 |
" |
|
5658 |
OperatingSystem getSystemID |
|
5659 |
" |
|
5660 |
! |
|
5661 |
||
5662 |
getSystemInfo |
|
5663 |
"return info on the system weare running on. |
|
5664 |
If the system supports the uname system call, that info is returned; |
|
5665 |
otherwise, some simulated info is returned. |
|
5666 |
||
5667 |
WARNING: |
|
5668 |
Do not depend on the amount and contents of the returned information, some |
|
5669 |
systems may return more/less than others. Also, the contents depends on the |
|
5670 |
OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
|
5671 |
||
5672 |
This method is mainly provided to augment error reports with some system |
|
5673 |
information. |
|
5674 |
(in case of system/version specific OS errors, conditional workarounds and patches |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5675 |
may be based upon this info). |
5133 | 5676 |
Your application should NOT depend upon this in any way. |
5677 |
||
5678 |
The returned info may (or may not) contain: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5679 |
#system -> some operating system identification (irix, Linux, nt, win32s ...) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5680 |
#version -> OS version (some os version identification) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5681 |
#release -> OS release (3.5, 1.2.1 ...) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5682 |
#node -> some host identification (hostname) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5683 |
#domain -> domain name (hosts domain) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5684 |
#machine -> type of machine (i586, mips ...) |
5133 | 5685 |
|
5686 |
win32: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5687 |
#physicalRam -> total amount of physical memory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5688 |
#freeRam -> amount of free memory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5689 |
#swapSize -> size of swapSpace (page file) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5690 |
#freeSwap -> free bytes in swapSpace |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5691 |
#virtualRam -> total amount of virtual memory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5692 |
#freeVirtual -> amount of free virtual memory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5693 |
#memoryLoad -> percentage of memory usage (useless) |
6740
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5694 |
" |
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5695 |
|
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5696 |
|sys node rel ver mach dom info arch |
5133 | 5697 |
physicalRam freeRam swapSize freeSwap |
7860 | 5698 |
virtualRam freeVirtual memoryLoad numberOfCPUs| |
5133 | 5699 |
|
5700 |
%{ /* STACK: 4096 */ |
|
5701 |
||
5702 |
char vsnBuffer[32]; |
|
5703 |
char *s; |
|
6740
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5704 |
int winVer, verMinor, verMajor; |
5133 | 5705 |
DWORD vsn; |
5706 |
SYSTEM_INFO sysInfo; |
|
5707 |
MEMORYSTATUS memStatus; |
|
5708 |
||
5709 |
vsn = GetVersion(); |
|
6740
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5710 |
winVer = LOWORD(vsn); |
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5711 |
verMinor = HIBYTE(winVer); |
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5712 |
verMajor = LOBYTE(winVer); |
5133 | 5713 |
|
5714 |
if (HIWORD(vsn) & 0x8000) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5715 |
s = "win95"; |
5133 | 5716 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5717 |
if ((verMajor > 5) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5718 |
|| ((verMajor == 5) && (verMinor >= 1))) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5719 |
s = "xp"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5720 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5721 |
s = "nt"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5722 |
} |
5133 | 5723 |
} |
5724 |
sys = __MKSTRING(s); |
|
6740
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5725 |
sprintf(vsnBuffer, "%d.%d", verMajor, verMinor); |
5133 | 5726 |
rel = __MKSTRING(vsnBuffer); |
5727 |
||
5728 |
GetSystemInfo(&sysInfo); |
|
5729 |
memStatus.dwLength = sizeof(memStatus); |
|
5730 |
GlobalMemoryStatus(&memStatus); |
|
5731 |
||
5732 |
memoryLoad = __MKUINT(memStatus.dwMemoryLoad); |
|
5733 |
physicalRam = __MKUINT(memStatus.dwTotalPhys); |
|
5734 |
freeRam = __MKUINT(memStatus.dwAvailPhys); |
|
5735 |
swapSize = __MKUINT(memStatus.dwTotalPageFile); |
|
5736 |
freeSwap = __MKUINT(memStatus.dwAvailPageFile); |
|
5737 |
virtualRam = __MKUINT(memStatus.dwTotalVirtual); |
|
5738 |
freeVirtual = __MKUINT(memStatus.dwAvailVirtual); |
|
5739 |
||
5740 |
#if defined(__BORLANDC__) && (__BORLANDC__ <= 1339) |
|
5741 |
/* BorlandC3 ... */ |
|
5742 |
switch (sysInfo.u.s.wProcessorArchitecture) |
|
5743 |
#else |
|
5744 |
/* MSC, BorlandC4 ... */ |
|
5745 |
switch (sysInfo.wProcessorArchitecture) |
|
5746 |
#endif |
|
5747 |
{ |
|
5748 |
#ifdef PROCESSOR_ARCHITECTURE_INTEL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5749 |
case PROCESSOR_ARCHITECTURE_INTEL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5750 |
s = "intel"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5751 |
break; |
5133 | 5752 |
#endif |
5753 |
#ifdef PROCESSOR_ARCHITECTURE_MIPS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5754 |
case PROCESSOR_ARCHITECTURE_MIPS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5755 |
s = "mips"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5756 |
break; |
5133 | 5757 |
#endif |
5758 |
#ifdef PROCESSOR_ARCHITECTURE_ALPHA |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5759 |
case PROCESSOR_ARCHITECTURE_ALPHA: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5760 |
s = "alpha"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5761 |
break; |
5133 | 5762 |
#endif |
5763 |
#ifdef PROCESSOR_ARCHITECTURE_PPC |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5764 |
case PROCESSOR_ARCHITECTURE_PPC: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5765 |
s = "ppc"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5766 |
break; |
5133 | 5767 |
#endif |
5768 |
#ifdef PROCESSOR_ARCHITECTURE_ARM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5769 |
case PROCESSOR_ARCHITECTURE_ARM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5770 |
s = "arm"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5771 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5772 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5773 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5774 |
s = "unknown"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5775 |
break; |
5133 | 5776 |
} |
5777 |
arch = __MKSTRING(s); |
|
5778 |
||
5779 |
switch (sysInfo.dwProcessorType) { |
|
5780 |
#ifdef PROCESSOR_INTEL_386 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5781 |
case PROCESSOR_INTEL_386: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5782 |
s = "i386"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5783 |
break; |
5133 | 5784 |
#endif |
5785 |
#ifdef PROCESSOR_INTEL_486 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5786 |
case PROCESSOR_INTEL_486: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5787 |
s = "i486"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5788 |
break; |
5133 | 5789 |
#endif |
5790 |
#ifdef PROCESSOR_INTEL_PENTIUM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5791 |
case PROCESSOR_INTEL_PENTIUM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5792 |
s = "i586"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5793 |
break; |
5133 | 5794 |
#endif |
5795 |
#ifdef PROCESSOR_INTEL_860 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5796 |
case PROCESSOR_INTEL_860: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5797 |
s = "i860"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5798 |
break; |
5133 | 5799 |
#endif |
5800 |
#ifdef PROCESSOR_MIPS_R2000 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5801 |
case PROCESSOR_MIPS_R2000: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5802 |
s = "r2000"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5803 |
break; |
5133 | 5804 |
#endif |
5805 |
#ifdef PROCESSOR_MIPS_R3000 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5806 |
case PROCESSOR_MIPS_R3000: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5807 |
s = "r3000"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5808 |
break; |
5133 | 5809 |
#endif |
5810 |
#ifdef PROCESSOR_MIPS_R4000 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5811 |
case PROCESSOR_MIPS_R4000: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5812 |
s = "r4000"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5813 |
break; |
5133 | 5814 |
#endif |
5815 |
#ifdef PROCESSOR_ALPHA_21064 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5816 |
case PROCESSOR_ALPHA_21064: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5817 |
s = "alpha21064"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5818 |
break; |
5133 | 5819 |
#endif |
5820 |
#ifdef PROCESSOR_ARM_7TDMI |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5821 |
case PROCESSOR_ARM_7TDMI: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5822 |
s = "arm70001"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5823 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5824 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5825 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5826 |
sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5827 |
s = vsnBuffer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5828 |
break; |
5133 | 5829 |
} |
5830 |
mach = __MKSTRING(s); |
|
7860 | 5831 |
|
5832 |
numberOfCPUs = __MKUINT(sysInfo.dwNumberOfProcessors); |
|
5133 | 5833 |
%}. |
5834 |
sys isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5835 |
sys := self getSystemType. |
5133 | 5836 |
]. |
5837 |
node isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5838 |
node := self getHostName. |
5133 | 5839 |
]. |
5840 |
dom isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5841 |
dom := self getDomainName. |
5133 | 5842 |
]. |
5843 |
mach isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5844 |
mach := self getCPUType. |
5133 | 5845 |
]. |
5846 |
arch isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5847 |
arch := 'unknown'. |
5133 | 5848 |
]. |
5849 |
||
5850 |
info := IdentityDictionary new. |
|
5851 |
info at:#system put:sys. |
|
5852 |
info at:#node put:node. |
|
5853 |
rel notNil ifTrue:[info at:#release put:rel]. |
|
5854 |
ver notNil ifTrue:[info at:#version put:ver]. |
|
7860 | 5855 |
mach notNil ifTrue:[info at:#machine put:mach. info at:#cpuType put:mach]. |
5133 | 5856 |
arch notNil ifTrue:[info at:#architecture put:arch]. |
5857 |
dom notNil ifTrue:[info at:#domain put:dom]. |
|
7860 | 5858 |
numberOfCPUs notNil ifTrue:[info at:#numberOfCPUs put:numberOfCPUs]. |
5133 | 5859 |
|
5860 |
info at:#memoryLoad put:memoryLoad. |
|
5861 |
info at:#physicalRam put:physicalRam. |
|
5862 |
info at:#freeRam put:freeRam. |
|
5863 |
info at:#swapSize put:swapSize. |
|
5864 |
info at:#freeSwap put:freeSwap. |
|
5865 |
info at:#virtualRam put:virtualRam. |
|
5866 |
info at:#freeVirtual put:freeVirtual. |
|
5867 |
||
5868 |
info at:#osType put:(self getOSType). |
|
5869 |
^ info |
|
5870 |
||
5871 |
" |
|
5872 |
OperatingSystem getSystemInfo |
|
5873 |
" |
|
5874 |
! |
|
5875 |
||
5876 |
getSystemType |
|
5877 |
"return a string giving the type of system we're running on. |
|
5878 |
This is almost the same as getOSType, but the returned string |
|
5879 |
is slightly different for some systems (i.e. iris vs. irix). |
|
5880 |
Dont depend on this - use getOSType. I dont really see a point |
|
5881 |
here ... |
|
5882 |
(except for slight differences between next/mach and other machs)" |
|
5883 |
||
5884 |
^ 'win32' |
|
5885 |
||
5886 |
" |
|
5887 |
OperatingSystem getSystemType |
|
5888 |
" |
|
5889 |
! |
|
5890 |
||
5891 |
getWindowsDirectory |
|
5892 |
"internal interface - only for Windows based systems. |
|
5893 |
Return the windows directory |
|
5894 |
(which - depending on the system - may be \WINNT, \WINDOWS or whatever) |
|
5895 |
On non-windows systems, nil is returned." |
|
5896 |
||
5897 |
%{ |
|
5898 |
char buffer[MAXPATHLEN]; |
|
5899 |
||
5900 |
if (GetWindowsDirectory(buffer, MAXPATHLEN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5901 |
RETURN (__MKSTRING(buffer)); |
5133 | 5902 |
} |
5903 |
%}. |
|
5904 |
^ nil |
|
5905 |
||
5906 |
" |
|
5907 |
OperatingSystem getWindowsDirectory |
|
5908 |
" |
|
5909 |
! |
|
5910 |
||
5911 |
getWindowsSystemDirectory |
|
5912 |
"internal interface - only for Windows based systems. |
|
5913 |
Return the windows system directory |
|
5914 |
(which - depending on the system - may be \WINNT\SYSTEM32, |
|
5915 |
\WINDOWS\SYSTEM or whatever) |
|
5916 |
On non-windows systems, nil is returned." |
|
5917 |
||
5918 |
%{ |
|
5919 |
char buffer[MAXPATHLEN]; |
|
5920 |
||
5921 |
if (GetSystemDirectory(buffer, MAXPATHLEN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5922 |
RETURN (__MKSTRING(buffer)); |
5133 | 5923 |
} |
5924 |
%}. |
|
5925 |
^ nil |
|
5926 |
||
5927 |
" |
|
5928 |
OperatingSystem getWindowsSystemDirectory |
|
5929 |
" |
|
5930 |
! |
|
5931 |
||
5932 |
hasConsole |
|
5933 |
"return true, if there is some kind of console available |
|
5934 |
(i.e. for proper stdIn, stdOut and stdErr handling). |
|
5935 |
This only returns false when running únder windows, and |
|
5936 |
the system is running as a pure windows application. |
|
5937 |
If false, the miniDebugger is useless and not used." |
|
5938 |
||
5939 |
%{ /* NOCONTEXT */ |
|
5940 |
extern int __getNoConsoleFlag(); |
|
5941 |
||
5942 |
RETURN ( __getNoConsoleFlag() ? false : true); |
|
5943 |
%} |
|
5944 |
! |
|
5945 |
||
5946 |
isMSDOSlike |
|
5947 |
"return true, if the OS we're running on is msdos like |
|
5948 |
(in contrast to unix-like or vms-like). |
|
5949 |
This returns true for any of msdos, win32s, win95, |
|
5950 |
winNT and os/2." |
|
5951 |
||
5952 |
^ true |
|
5953 |
! |
|
5954 |
||
5955 |
isMSWINDOWSNTlike |
|
5956 |
"This returns true if running in a Windows-NT system." |
|
5957 |
||
5958 |
%{ /* NOCONTEXT */ |
|
5959 |
if (__isWinNT) |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5960 |
RETURN(true); |
5133 | 5961 |
%}. |
5962 |
^ false. |
|
5963 |
! |
|
5964 |
||
5965 |
isMSWINDOWSlike |
|
5966 |
"return true, if running on a MS-Windows like system. |
|
5967 |
This returns true for any of win32s, win95 and winNT." |
|
5968 |
||
5969 |
^ true |
|
5970 |
! |
|
5971 |
||
5972 |
maxFileNameLength |
|
5973 |
"return the max number of characters in a filename. |
|
5974 |
CAVEAT: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5975 |
Actually, the following is somewhat wrong - some systems |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5976 |
support different sizes, depending on the volume. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5977 |
We return a somewhat conservative number here. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5978 |
Another entry, to query for volume specific max |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5979 |
will be added in the future." |
5133 | 5980 |
|
5981 |
%{ /* NOCONTEXT */ |
|
5982 |
||
5983 |
/* |
|
5984 |
* TODO: newer systems provide a query function for this ... use it |
|
5985 |
*/ |
|
5986 |
/* |
|
5987 |
* mhmh - depends on the filesystem type |
|
5988 |
*/ |
|
5989 |
RETURN ( __MKSMALLINT(MAXFILELEN) ); |
|
5990 |
%} |
|
5991 |
" |
|
5992 |
OperatingSystem maxFileNameLength |
|
5993 |
" |
|
5994 |
! |
|
5995 |
||
5996 |
maxPathLength |
|
5997 |
"return the max number of characters in a pathName." |
|
5998 |
||
5999 |
%{ /* NOCONTEXT */ |
|
6000 |
RETURN ( __MKSMALLINT(MAXPATHLEN) ); |
|
6001 |
%} |
|
6002 |
" |
|
6003 |
OperatingSystem maxPathLength |
|
6004 |
" |
|
6005 |
! |
|
6006 |
||
6007 |
pathSeparator |
|
6008 |
"return the character which separates items in the PATH variable" |
|
6009 |
||
6010 |
^ $; |
|
6011 |
||
6012 |
"Created: 2.5.1997 / 11:36:47 / cg" |
|
6013 |
! |
|
6014 |
||
6015 |
platformName |
|
6016 |
"return a string describing the OS platform very we're running on. |
|
6017 |
This returns #unix for all unix derivatives, |
|
6018 |
#os2, #win32, #vms or #mac for the others. |
|
6019 |
I.e. it is much less specific than getOSType or getSystemType." |
|
6020 |
||
6021 |
^ #win32 |
|
6022 |
||
6023 |
" |
|
6024 |
OperatingSystem platformName |
|
6025 |
" |
|
6026 |
||
6027 |
"Modified: 20.6.1997 / 17:37:26 / cg" |
|
6028 |
! |
|
6029 |
||
7158 | 6030 |
primGetDomainName |
6031 |
%{ |
|
6032 |
#if 0 /* not needed */ |
|
6033 |
HINSTANCE hNetApi32 = LoadLibrary("netapi32.dll"); |
|
6034 |
DWORD (__stdcall *pfnNetApiBufferFree)(LPVOID Buffer); |
|
6035 |
DWORD (__stdcall *pfnNetWkstaGetInfo)(LPWSTR servername, DWORD level, void *bufptr); |
|
6036 |
||
6037 |
if (hNetApi32) { |
|
6038 |
pfnNetApiBufferFree = (DWORD (__stdcall *)(void *)) GetProcAddress(hNetApi32, "NetApiBufferFree"); |
|
6039 |
pfnNetWkstaGetInfo = (DWORD (__stdcall *)(LPWSTR, DWORD, void *)) GetProcAddress(hNetApi32, "NetWkstaGetInfo"); |
|
6040 |
} |
|
6041 |
||
6042 |
if (hNetApi32 && pfnNetWkstaGetInfo && pfnNetApiBufferFree) { |
|
6043 |
/* this way is more reliable, in case user has a local account. */ |
|
6044 |
char dname[256]; |
|
6045 |
DWORD dnamelen = sizeof(dname); |
|
6046 |
struct { |
|
6047 |
DWORD wki100_platform_id; |
|
6048 |
LPWSTR wki100_computername; |
|
6049 |
LPWSTR wki100_langroup; |
|
6050 |
DWORD wki100_ver_major; |
|
6051 |
DWORD wki100_ver_minor; |
|
6052 |
} *pwi; |
|
6053 |
||
6054 |
/* NERR_Success *is* 0*/ |
|
6055 |
if (0 == pfnNetWkstaGetInfo(NULL, 100, &pwi)) { |
|
6056 |
if (pwi->wki100_langroup && *(pwi->wki100_langroup)) { |
|
6057 |
WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_langroup, |
|
6058 |
-1, (LPSTR)dname, dnamelen, NULL, NULL); |
|
6059 |
} |
|
6060 |
else { |
|
6061 |
WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_computername, |
|
6062 |
-1, (LPSTR)dname, dnamelen, NULL, NULL); |
|
6063 |
} |
|
6064 |
pfnNetApiBufferFree(pwi); |
|
6065 |
FreeLibrary(hNetApi32); |
|
6066 |
RETURN (__MKSTRING(dname)); |
|
6067 |
} |
|
6068 |
FreeLibrary(hNetApi32); |
|
6069 |
} else { |
|
6070 |
/* Win95 doesn't have NetWksta*(), so do it the old way */ |
|
6071 |
char name[256]; |
|
6072 |
DWORD size = sizeof(name); |
|
6073 |
if (hNetApi32) |
|
6074 |
FreeLibrary(hNetApi32); |
|
6075 |
if (GetUserName(name,&size)) { |
|
6076 |
char sid[1024]; |
|
6077 |
DWORD sidlen = sizeof(sid); |
|
6078 |
char dname[256]; |
|
6079 |
DWORD dnamelen = sizeof(dname); |
|
6080 |
SID_NAME_USE snu; |
|
6081 |
if (LookupAccountName(NULL, name, (PSID)&sid, &sidlen, |
|
6082 |
dname, &dnamelen, &snu)) { |
|
6083 |
RETURN (__MKSTRING(dname)); /* all that for this */ |
|
6084 |
} |
|
6085 |
} |
|
6086 |
} |
|
6087 |
#endif /* not needed */ |
|
6088 |
%}. |
|
6089 |
^ nil |
|
6090 |
! |
|
6091 |
||
5133 | 6092 |
setLocaleInfo:anInfoDictionary |
6093 |
"set the locale information; if set, this oerrides the OS's settings. |
|
6094 |
(internal in ST/X only - the OS's settings remain unaffected) |
|
6095 |
See description of fields in #getLocaleInfo. |
|
6096 |
||
6097 |
Notice, that (for now), the system does not use this information; |
|
6098 |
it should be used by applications as required." |
|
6099 |
||
6100 |
LocaleInfo := anInfoDictionary |
|
6101 |
||
6102 |
" |
|
6103 |
|d| |
|
6104 |
||
6105 |
d := IdentityDictionary new. |
|
6106 |
d at:#decimalPoint put:'.' . |
|
6107 |
d at:#thousandsSeparator put:',' . |
|
6108 |
d at:#currencySymbol put:'USD' . |
|
6109 |
d at:#monetaryDecimalPoint put:'.' . |
|
6110 |
d at:#monetaryThousandsSeparator put:'.' . |
|
6111 |
d at:#fractionalDigits put:2 . |
|
6112 |
d at:#positiveSign put:'+' . |
|
6113 |
d at:#negativeSign put:'-' . |
|
6114 |
d at:#positiveSignPrecedesCurrencySymbol put:true . |
|
6115 |
d at:#negativeSignPrecedesCurrencySymbol put:false . |
|
6116 |
OperatingSystem setLocaleInfo:d |
|
6117 |
" |
|
6118 |
! |
|
6119 |
||
6120 |
supportsChildInterrupts |
|
6121 |
"return true, if the OS supports childProcess termination signalling |
|
6122 |
through interrupts (i.e. SIGCHILD)" |
|
6123 |
||
6124 |
%{ /* NOCONTEXT */ |
|
6125 |
#if defined(SIGCHLD) || defined(SIGCLD) |
|
6126 |
RETURN (true); |
|
6127 |
#endif |
|
6128 |
%}. |
|
6129 |
^ false |
|
6130 |
||
6131 |
" |
|
6132 |
OperatingSystem supportsChildInterrupts |
|
6133 |
" |
|
6134 |
! |
|
6135 |
||
6136 |
supportsFileOwnerGroups |
|
6137 |
"return true, if the OS's file system supports file |
|
6138 |
group ownership - all OS's except windows do" |
|
6139 |
||
6140 |
^ false |
|
6141 |
||
6142 |
"Created: / 10.9.1998 / 17:57:03 / cg" |
|
6143 |
! |
|
6144 |
||
6145 |
supportsFileOwners |
|
6146 |
"return true, if the OS's file system supports file |
|
6147 |
ownership - all OS's except windows do" |
|
6148 |
||
6149 |
^ false |
|
6150 |
||
6151 |
"Created: / 10.9.1998 / 17:55:16 / cg" |
|
6152 |
"Modified: / 10.9.1998 / 17:57:11 / cg" |
|
6153 |
! |
|
6154 |
||
6155 |
supportsIOInterrupts |
|
6156 |
"return true, if the OS supports IO availability interrupts |
|
6157 |
(i.e. SIGPOLL/SIGIO). |
|
6158 |
||
6159 |
Currently, this mechanism does not work on all |
|
6160 |
systems ... |
|
6161 |
" |
|
6162 |
||
6163 |
^ false |
|
6164 |
||
6165 |
" |
|
6166 |
OperatingSystem supportsIOInterrupts |
|
6167 |
" |
|
6168 |
! |
|
6169 |
||
6170 |
supportsNonBlockingIO |
|
6171 |
"return true, if the OS supports nonblocking IO." |
|
6172 |
||
6173 |
^ false |
|
6174 |
||
6175 |
" |
|
6176 |
OperatingSystem supportsNonBlockingIO |
|
6177 |
" |
|
6178 |
! |
|
6179 |
||
6180 |
supportsSelect |
|
6181 |
"return true, if the OS supports selecting on multiple |
|
6182 |
filedescriptors via select. |
|
6183 |
If false is returned, ProcessorScheduler will poll in 50ms |
|
6184 |
intervals for I/O becoming ready." |
|
6185 |
||
6186 |
%{ /* NOCONTEXT */ |
|
6187 |
||
6188 |
# if defined(WIN32S) |
|
6189 |
RETURN (false); |
|
6190 |
# endif |
|
6191 |
%}. |
|
6192 |
^ true |
|
6193 |
||
6194 |
" |
|
6195 |
OperatingSystem supportsSelect |
|
6196 |
" |
|
6197 |
! |
|
6198 |
||
6199 |
supportsSelectOnPipes |
|
6200 |
"return true, if the OS supports selecting on pipe |
|
6201 |
filedescriptors via select. |
|
6202 |
If false is returned, ProcessorScheduler will poll in 50ms |
|
6203 |
intervals for I/O becoming ready." |
|
6204 |
||
6205 |
^ false |
|
6206 |
||
6207 |
" |
|
6208 |
OperatingSystem supportsSelectOnPipes |
|
6209 |
" |
|
6210 |
||
6211 |
"Modified: / 14.12.1999 / 19:41:03 / cg" |
|
6212 |
"Created: / 14.12.1999 / 19:43:13 / cg" |
|
6213 |
! |
|
6214 |
||
6215 |
supportsSelectOnSockets |
|
6216 |
"return true, if the OS supports selecting on socket |
|
6217 |
filedescriptors via select. |
|
6218 |
If false is returned, ProcessorScheduler will poll in 50ms |
|
6219 |
intervals for I/O becoming ready." |
|
6220 |
||
6221 |
^ false |
|
6222 |
||
6223 |
" |
|
6224 |
OperatingSystem supportsSelectOnSockets |
|
6225 |
" |
|
6226 |
||
6227 |
"Modified: / 14.12.1999 / 19:41:03 / cg" |
|
6228 |
! |
|
6229 |
||
6230 |
supportsVolumes |
|
6231 |
"return true, if the OS supports disk volumes. |
|
6232 |
False is returned for UNIX, true for MSDOS and VMS" |
|
6233 |
||
6234 |
^ true |
|
6235 |
! ! |
|
6236 |
||
6237 |
!Win32OperatingSystem class methodsFor:'path queries'! |
|
6238 |
||
5144 | 6239 |
defaultPackagePath |
5147 | 6240 |
|pPath pkgDirPath dirs p| |
5144 | 6241 |
|
6242 |
pPath := super defaultPackagePath. |
|
6243 |
pkgDirPath := self stxPackageDirPath. |
|
6244 |
pkgDirPath notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6245 |
"/ and also add the packageDirPath from the registry ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6246 |
dirs := pkgDirPath asCollectionOfSubstringsSeparatedBy:$;. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6247 |
dirs do:[:aDir | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6248 |
(pPath includes:aDir) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6249 |
pPath add:aDir. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6250 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6251 |
] |
5144 | 6252 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6253 |
#( |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6254 |
'\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6255 |
'\programme\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6256 |
'\programme\eXept\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6257 |
'\programs\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6258 |
'\programs\eXept\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6259 |
) do:[:d | |dd| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6260 |
dd := d asFilename constructString:'packages'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6261 |
(pPath includes:dd) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6262 |
pPath add:dd. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6263 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6264 |
dd := (d asFilename construct:Smalltalk versionString) constructString:'packages'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6265 |
(pPath includes:dd) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6266 |
pPath add:dd. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6267 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6268 |
]. |
5144 | 6269 |
]. |
6270 |
||
6271 |
"/ under windows, the commandName includes the path - good. |
|
5922 | 6272 |
p := Smalltalk commandName. |
6273 |
p notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6274 |
p := p asFilename directory constructString:'packages'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6275 |
(pPath includes:p) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6276 |
pPath add:p. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6277 |
] |
5147 | 6278 |
]. |
5144 | 6279 |
pPath := pPath select:[:p | p asFilename exists]. |
6280 |
^ pPath |
|
6281 |
||
6282 |
" |
|
6283 |
self defaultPackagePath |
|
6284 |
" |
|
6285 |
||
6286 |
"Created: / 24.12.1999 / 00:10:41 / cg" |
|
5147 | 6287 |
"Modified: / 24.12.1999 / 00:33:26 / cg" |
5144 | 6288 |
! |
6289 |
||
5133 | 6290 |
defaultSystemPath |
5147 | 6291 |
|sysPath libDirPath p| |
5133 | 6292 |
|
6293 |
sysPath := super defaultSystemPath. |
|
5136 | 6294 |
libDirPath := self stxLibDirPath. |
6295 |
libDirPath notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6296 |
"/ and also add the libDirPath from the registry ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6297 |
(sysPath includes:libDirPath) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6298 |
sysPath add:libDirPath |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6299 |
]. |
5136 | 6300 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6301 |
#( |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6302 |
'\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6303 |
'\programme\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6304 |
'\programme\eXept\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6305 |
'\programs\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6306 |
'\programs\eXept\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6307 |
) do:[:d | |dd| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6308 |
(d asFilename isDirectory) ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6309 |
(sysPath includes:d) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6310 |
sysPath add:d. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6311 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6312 |
dd := d , '\' , Smalltalk versionString. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6313 |
(sysPath includes:dd) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6314 |
sysPath add:dd. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6315 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6316 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6317 |
]. |
5133 | 6318 |
]. |
6319 |
||
6320 |
"/ under windows, the commandName includes the path - good. |
|
5918 | 6321 |
p := Smalltalk commandName. |
6322 |
p notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6323 |
p := p asFilename directoryName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6324 |
(sysPath includes:p) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6325 |
sysPath add:p. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6326 |
] |
5147 | 6327 |
]. |
5133 | 6328 |
^ sysPath |
5136 | 6329 |
|
5147 | 6330 |
"Modified: / 24.12.1999 / 00:29:18 / cg" |
5133 | 6331 |
! |
6332 |
||
6333 |
stxBinDirPath |
|
6334 |
"ask the registry for the binary directory" |
|
6335 |
||
6336 |
|k p| |
|
6337 |
||
6338 |
k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString. |
|
6339 |
k notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6340 |
p := k valueNamed:'BinDir'. |
5133 | 6341 |
]. |
6342 |
^ p |
|
6343 |
||
6344 |
" |
|
6345 |
OperatingSystem stxBinDirPath |
|
6346 |
" |
|
6347 |
! |
|
6348 |
||
6349 |
stxLibDirPath |
|
6350 |
"ask the registry for the lib directory" |
|
6351 |
||
6352 |
|k p| |
|
6353 |
||
6354 |
k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString. |
|
6355 |
k notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6356 |
p := k valueNamed:'LibDir'. |
5133 | 6357 |
]. |
6358 |
^ p |
|
6359 |
||
6360 |
" |
|
6361 |
OperatingSystem stxLibDirPath |
|
6362 |
" |
|
5144 | 6363 |
! |
6364 |
||
6365 |
stxPackageDirPath |
|
6366 |
"ask the registry for the package directory" |
|
6367 |
||
6368 |
|k p| |
|
6369 |
||
6370 |
k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString. |
|
6371 |
k notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6372 |
p := k valueNamed:'PackageDirPath'. |
5144 | 6373 |
]. |
6374 |
^ p |
|
6375 |
||
6376 |
" |
|
6377 |
OperatingSystem stxPackageDirPath |
|
6378 |
" |
|
6379 |
||
6380 |
"Created: / 24.12.1999 / 00:11:12 / cg" |
|
5133 | 6381 |
! ! |
6382 |
||
6383 |
!Win32OperatingSystem class methodsFor:'private'! |
|
6384 |
||
7777 | 6385 |
mapLanguage:aWindowsLanguageString |
6386 |
"map a windows language string to ISO languageCode_languageTerritory |
|
6387 |
format" |
|
6388 |
||
6389 |
|windowsLanguageString| |
|
6390 |
||
6391 |
windowsLanguageString := aWindowsLanguageString asUppercase. |
|
6392 |
||
6393 |
#('DEU' 'de_DE' |
|
6394 |
'DES' 'de_CH' |
|
6395 |
'DEA' 'de_AT' |
|
6396 |
'DAN' 'da_DA' |
|
6397 |
'ENA' 'en_AU' |
|
6398 |
'ENC' 'en_CA' |
|
6399 |
'ENG' 'en_GB' |
|
6400 |
'ENI' 'en_IR' |
|
6401 |
'ENU' 'en_US' |
|
6402 |
'ENZ' 'en_NZ' |
|
6403 |
'FRA' 'fr_FR' |
|
6404 |
'FRB' 'fr_BE' |
|
6405 |
'FRC' 'fr_CA' |
|
6406 |
'FRS' 'fr_CH' |
|
6407 |
'ITA' 'it_IT' |
|
6408 |
'ITS' 'it_CH' |
|
6409 |
'ESM' 'es_MX' |
|
6410 |
'ESN' 'es_ES' |
|
6411 |
'ESP' 'es' "Castillian" |
|
6412 |
'NLB' 'nl_BE' |
|
6413 |
'NLD' 'nl_NL' |
|
6414 |
'CSY' 'cs_CS' |
|
6415 |
'ELL' 'el_EL' |
|
6416 |
'NON' 'no_NO' |
|
6417 |
'NOR' 'no_NO' |
|
6418 |
) pairWiseDo:[:key :mappedValue| |
|
7840 | 6419 |
key = windowsLanguageString ifTrue:[ |
6420 |
^ mappedValue |
|
6421 |
] |
|
7777 | 6422 |
]. |
6423 |
||
6424 |
"no mapping" |
|
6425 |
^ windowsLanguageString. |
|
6426 |
||
6427 |
" |
|
7840 | 6428 |
self mapLanguage:'DEU' |
7777 | 6429 |
" |
6430 |
! |
|
6431 |
||
5133 | 6432 |
osProcessStatusClass |
6433 |
^ OSProcessStatus |
|
6434 |
||
6435 |
"Created: / 12.6.1998 / 16:30:43 / cg" |
|
6436 |
! ! |
|
6437 |
||
6438 |
!Win32OperatingSystem class methodsFor:'system management'! |
|
6439 |
||
6440 |
exitWindows |
|
6441 |
"do not use - may be removed without notice" |
|
6442 |
||
6443 |
self exitWindows:#shutdown confirm:'Do you really want to shutdown the system' |
|
6444 |
! |
|
6445 |
||
6446 |
exitWindows:how confirm:confirmationMessageOrNil |
|
6447 |
"this method is temporary - |
|
6448 |
since my windows system menu crashes so often |
|
7850 | 6449 |
(even CTRL-ALT-DEL does no longer function, but ST/X is still alive), |
5133 | 6450 |
I added this in order to be able to shutdown w95 cleanly" |
6451 |
||
6452 |
confirmationMessageOrNil notNil ifTrue:[ |
|
7852 | 6453 |
(Dialog confirm:confirmationMessageOrNil) ifFalse:[ |
6454 |
^ false |
|
6455 |
]. |
|
5133 | 6456 |
]. |
6457 |
%{ |
|
6458 |
int flag; |
|
6459 |
||
6460 |
if (how == @symbol(shutdown)) { |
|
7852 | 6461 |
flag = EWX_SHUTDOWN; |
5133 | 6462 |
} else if (how == @symbol(reboot)) { |
7852 | 6463 |
flag = EWX_REBOOT; |
5133 | 6464 |
} else if (how == @symbol(logoff)) { |
7852 | 6465 |
flag = EWX_LOGOFF; |
5133 | 6466 |
} else if (how == @symbol(forceShutdown)) { |
7852 | 6467 |
flag = EWX_SHUTDOWN | EWX_FORCE; |
5133 | 6468 |
} else if (how == @symbol(forceReboot)) { |
7852 | 6469 |
flag = EWX_REBOOT | EWX_FORCE; |
5133 | 6470 |
} else if (how == @symbol(forceLogoff)) { |
7852 | 6471 |
flag = EWX_LOGOFF | EWX_FORCE; |
5133 | 6472 |
} else { |
7852 | 6473 |
RETURN (false); |
5133 | 6474 |
} |
6475 |
RETURN ((ExitWindowsEx(flag, 0) == TRUE) ? true : false); |
|
6476 |
%} |
|
6477 |
! ! |
|
6478 |
||
6479 |
!Win32OperatingSystem class methodsFor:'time and date'! |
|
6480 |
||
6481 |
computeDatePartsOf:osTime for:aBlock |
|
6482 |
"compute year, month and day from the OS time, osTime |
|
6483 |
and evaluate the argument, a 3-arg block with these. |
|
6484 |
Conversion is to localtime including any daylight saving adjustments." |
|
6485 |
||
6486 |
|year month day osSeconds| |
|
6487 |
||
6488 |
osSeconds := osTime // 1000. |
|
6489 |
%{ |
|
6490 |
struct tm* tmPtr; |
|
6491 |
INT t; |
|
6492 |
TIME_T tt; |
|
6493 |
||
6494 |
t = __longIntVal(osSeconds); |
|
6495 |
tt = (TIME_T)t; |
|
6496 |
||
6497 |
tmPtr = localtime(&tt); |
|
6498 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
|
6499 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6500 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
6501 |
%}. |
|
6502 |
aBlock value:year value:month value:day |
|
6503 |
||
6504 |
" |
|
6505 |
OperatingSystem computeDatePartsOf:0 for:[:y :m :d | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6506 |
y printCR. m printCR. d printCR |
5133 | 6507 |
] |
6508 |
" |
|
6509 |
! |
|
6510 |
||
6511 |
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis |
|
6512 |
"return the OS-dependent time for the given time and day. |
|
6513 |
The arguments are assumed to be in localtime including |
|
6514 |
any daylight saving adjustings." |
|
6515 |
||
6516 |
|osSeconds| |
|
6517 |
||
6518 |
%{ |
|
6519 |
struct tm tm; |
|
6520 |
TIME_T t; |
|
6521 |
||
6522 |
if (__bothSmallInteger(y, m) |
|
6523 |
&& __bothSmallInteger(d, h) |
|
6524 |
&& __bothSmallInteger(min, s)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6525 |
tm.tm_hour = __intVal(h); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6526 |
tm.tm_min = __intVal(min); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6527 |
tm.tm_sec = __intVal(s); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6528 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6529 |
tm.tm_year = __intVal(y) - 1900; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6530 |
tm.tm_mon = __intVal(m) - 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6531 |
tm.tm_mday = __intVal(d); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6532 |
tm.tm_isdst = -1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6533 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6534 |
t = mktime(&tm); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6535 |
osSeconds = __MKUINT((INT)t); |
5133 | 6536 |
} |
6537 |
%}. |
|
6538 |
osSeconds notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6539 |
^ osSeconds * 1000 + millis |
5133 | 6540 |
]. |
6541 |
^ self primitiveFailed |
|
6542 |
||
6543 |
" |
|
6544 |
OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 |
|
6545 |
" |
|
6546 |
||
6547 |
! |
|
6548 |
||
6549 |
computeTimePartsOf:osTime for:aBlock |
|
6550 |
"compute hours, minutes, seconds and milliseconds from the osTime |
|
6551 |
and evaluate the argument, a 4-arg block with these. |
|
6552 |
Conversion is to localtime including any daylight saving adjustments." |
|
6553 |
||
6554 |
|hours minutes seconds millis osSeconds| |
|
6555 |
||
6556 |
osSeconds := osTime // 1000. |
|
6557 |
millis := osTime \\ 1000. |
|
6558 |
%{ |
|
6559 |
struct tm *tmPtr; |
|
6560 |
INT t; |
|
6561 |
TIME_T tt; |
|
6562 |
||
6563 |
t = __longIntVal(osSeconds); |
|
6564 |
tt = (TIME_T)t; |
|
6565 |
||
6566 |
tmPtr = localtime(&tt); |
|
6567 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
|
6568 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6569 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6570 |
%}. |
|
6571 |
aBlock value:hours value:minutes value:seconds value:millis |
|
6572 |
||
6573 |
" |
|
6574 |
OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6575 |
h printCR. m printCR. s printCR. millis printCR |
5133 | 6576 |
] |
6577 |
" |
|
6578 |
! |
|
6579 |
||
6580 |
computeUTCTimeAndDateFrom:osTime |
|
6581 |
"given an OS-dependent time in osTime, return an Array |
|
6582 |
containing year, month, day, hour, minute and seconds, |
|
6583 |
offset to UTC, daylight savings time flag, milliseconds, |
|
6584 |
dayInYear (1..) and dayInWeek (1..). |
|
6585 |
Conversion is to UTC." |
|
6586 |
||
6587 |
|low hi year month day hours minutes seconds millis utcOffset |
|
6588 |
dst yDay wDay osSeconds ret| |
|
6589 |
||
6590 |
millis := osTime \\ 1000. |
|
6591 |
osSeconds := osTime // 1000. |
|
6592 |
%{ |
|
6593 |
struct tm *tmPtr; |
|
6594 |
struct tm *gmTmPtr; |
|
6595 |
long t; |
|
6596 |
||
6597 |
t = __longIntVal(osSeconds); |
|
6598 |
||
6599 |
tmPtr = gmtime(&t); |
|
6600 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
|
6601 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6602 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6603 |
||
6604 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
|
6605 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6606 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
6607 |
||
6608 |
yDay = __MKSMALLINT(tmPtr->tm_yday + 1); |
|
6609 |
wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday); |
|
6610 |
||
6611 |
if (tmPtr->tm_isdst == 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6612 |
dst = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6613 |
utcOffset = __MKINT(TIMEZONE(tmPtr)); |
5133 | 6614 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6615 |
dst = true; |
5133 | 6616 |
#ifdef HAS_ALTZONE |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6617 |
utcOffset = __MKINT(altzone); |
5133 | 6618 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6619 |
utcOffset = __MKINT(TIMEZONE(tmPtr) + 3600); |
5133 | 6620 |
#endif |
6621 |
} |
|
6622 |
%}. |
|
6623 |
"I would love to have SELF-like inline objects ..." |
|
6624 |
ret := Array new:11. |
|
6625 |
ret at:1 put:year. |
|
6626 |
ret at:2 put:month. |
|
6627 |
ret at:3 put:day. |
|
6628 |
ret at:4 put:hours. |
|
6629 |
ret at:5 put:minutes. |
|
6630 |
ret at:6 put:seconds. |
|
6631 |
ret at:7 put:utcOffset. |
|
6632 |
ret at:8 put:dst. |
|
6633 |
ret at:9 put:millis. |
|
6634 |
ret at:10 put:yDay. |
|
6635 |
ret at:11 put:wDay. |
|
6636 |
^ ret |
|
6637 |
||
6638 |
" |
|
6639 |
OperatingSystem computeUTCTimeAndDateFrom:0 |
|
6640 |
" |
|
6641 |
! |
|
6642 |
||
6643 |
computeUTCTimePartsOf:osTime for:aBlock |
|
6644 |
"compute hours, minutes, seconds and milliseconds from the osTime |
|
6645 |
and evaluate the argument, a 4-arg block with these. |
|
6646 |
Conversion is to UTC." |
|
6647 |
||
6648 |
|hours minutes seconds millis osSeconds| |
|
6649 |
||
6650 |
osSeconds := osTime // 1000. |
|
6651 |
millis := osTime \\ 1000. |
|
6652 |
%{ |
|
6653 |
struct tm *tmPtr; |
|
6654 |
long t; |
|
6655 |
||
6656 |
t = __longIntVal(osSeconds); |
|
6657 |
||
6658 |
tmPtr = gmtime(&t); |
|
6659 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
|
6660 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6661 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6662 |
%}. |
|
6663 |
aBlock value:hours value:minutes value:seconds value:millis |
|
6664 |
||
6665 |
" |
|
6666 |
OperatingSystem computeUTCTimePartsOf:100 for:[:h :m :s :milli | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6667 |
h printCR. m printCR. s printCR. milli printCR |
5133 | 6668 |
] |
6669 |
" |
|
6670 |
! |
|
6671 |
||
6672 |
getMillisecondTime |
|
6673 |
"This returns the millisecond timers value. |
|
6674 |
The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid |
|
6675 |
LargeInteger arithmetic when doing timeouts and delays. |
|
6676 |
Since this value is wrapping around in regular intervals, this can only be used for |
|
6677 |
short relative time deltas. |
|
6678 |
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap. |
|
6679 |
||
6680 |
BAD DESIGN: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6681 |
This should be changed to return some instance of RelativeTime, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6682 |
and these computations moved there. |
5133 | 6683 |
|
6684 |
Dont use this method in application code since it is an internal (private) |
|
6685 |
interface. For compatibility with ST-80, use Time millisecondClockValue. |
|
6686 |
" |
|
6687 |
||
6688 |
%{ /* NOCONTEXT */ |
|
6689 |
||
6690 |
long t = 0; |
|
6691 |
||
6692 |
#if !defined(HAS_GETTIMEOFDAY) |
|
6693 |
# if defined(HAS_FTIME) |
|
6694 |
struct timeb timebuffer; |
|
6695 |
||
6696 |
ftime(&timebuffer); |
|
6697 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
6698 |
# define HAVE_TIME |
|
6699 |
# endif |
|
6700 |
||
6701 |
# ifndef HAVE_TIME |
|
6702 |
# ifdef WIN32 |
|
6703 |
t = GetTickCount(); |
|
6704 |
# define HAVE_TIME |
|
6705 |
# endif |
|
6706 |
# endif |
|
6707 |
||
6708 |
# ifndef HAVE_TIME |
|
6709 |
# ifdef MSDOS_LIKE |
|
6710 |
# ifdef __BORLANDC__ |
|
6711 |
struct timeb timebuffer; |
|
6712 |
ftime(&timebuffer); |
|
6713 |
# else |
|
6714 |
struct _timeb timebuffer; |
|
6715 |
_ftime(&timebuffer); |
|
6716 |
# endif |
|
6717 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
6718 |
# define HAVE_TIME |
|
6719 |
# endif |
|
6720 |
# endif |
|
6721 |
#endif |
|
6722 |
||
6723 |
#ifndef HAVE_TIME |
|
6724 |
/* assume HAS_GETTIMEOFDAY |
|
6725 |
* - will result in a linkage error |
|
6726 |
* if not fixed. |
|
6727 |
*/ |
|
6728 |
||
6729 |
/* |
|
6730 |
* bsd time |
|
6731 |
*/ |
|
6732 |
struct timeval tb; |
|
6733 |
struct timezone tzb; |
|
6734 |
||
6735 |
gettimeofday(&tb, &tzb); |
|
6736 |
t = tb.tv_sec*1000 + tb.tv_usec/1000; |
|
6737 |
#endif |
|
6738 |
||
6739 |
#undef HAVE_TIME |
|
6740 |
||
6741 |
RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) ); |
|
6742 |
%} |
|
6743 |
! |
|
6744 |
||
6745 |
getOSTime |
|
6746 |
"This returns the OS time. |
|
6747 |
The base of the returned value is not consistent across |
|
6748 |
different OS's - some return the number of millis since jan, 1st 1970; |
|
6749 |
others since 1900. The Time classes are prepared for this, and |
|
6750 |
converts as appropriate (by using my fromOSTime: conversion methods). |
|
6751 |
||
6752 |
Dont use this method in application code since it is an internal (private) |
|
6753 |
interface. For compatibility with ST-80, use Time>>millisecondClockValue. |
|
6754 |
or use instances of Time, Date or AbsoluteTime to work with. |
|
6755 |
" |
|
6756 |
||
6757 |
|seconds millis| |
|
6758 |
||
6759 |
%{ |
|
6760 |
||
6761 |
long t; |
|
6762 |
||
6763 |
#if !defined(HAS_GETTIMEOFDAY) |
|
6764 |
# if defined(HAS_FTIME) |
|
6765 |
struct timeb timebuffer; |
|
6766 |
||
6767 |
ftime(&timebuffer); |
|
6768 |
seconds = __MKUINT(timebuffer.time); |
|
6769 |
millis = __MKUINT(timebuffer.millitm); |
|
6770 |
# define HAVE_TIME |
|
6771 |
# endif |
|
6772 |
||
6773 |
# ifndef HAVE_TIME |
|
6774 |
# ifdef MSDOS_LIKE |
|
6775 |
# ifdef __BORLANDC__ |
|
6776 |
struct timeb timebuffer; |
|
6777 |
ftime(&timebuffer); |
|
6778 |
# else |
|
6779 |
struct _timeb timebuffer; |
|
6780 |
_ftime(&timebuffer); |
|
6781 |
# endif |
|
6782 |
seconds = __MKUINT(timebuffer.time); |
|
6783 |
millis = __MKUINT(timebuffer.millitm); |
|
6784 |
# define HAVE_TIME |
|
6785 |
# endif |
|
6786 |
# endif |
|
6787 |
#endif |
|
6788 |
||
6789 |
#ifndef HAVE_TIME |
|
6790 |
/* assume HAS_GETTIMEOFDAY |
|
6791 |
* - will result in a linkage error |
|
6792 |
* if not fixed. |
|
6793 |
*/ |
|
6794 |
/* |
|
6795 |
* bsd time |
|
6796 |
*/ |
|
6797 |
struct timeval tb; |
|
6798 |
struct timezone tzb; |
|
6799 |
||
6800 |
gettimeofday(&tb, &tzb); |
|
6801 |
||
6802 |
seconds = __MKUINT(tb.tv_sec); |
|
6803 |
millis = __MKUINT(tb.tv_usec / 1000); |
|
6804 |
#endif |
|
6805 |
||
6806 |
#undef HAVE_TIME |
|
6807 |
||
6808 |
%}. |
|
6809 |
^ (seconds * 1000) + millis |
|
6810 |
||
6811 |
" |
|
6812 |
OperatingSystem getOSTime printCR. |
|
6813 |
Delay waitForSeconds:0.2. |
|
6814 |
OperatingSystem getOSTime printCR. |
|
6815 |
" |
|
6816 |
! |
|
6817 |
||
6818 |
sleep:numberOfSeconds |
|
6819 |
"{ Pragma: +optSpace }" |
|
6820 |
||
6821 |
"cease ANY action for some time. This suspends the whole smalltalk |
|
6822 |
(unix-) process for some time. |
|
6823 |
Not really useful since not even low-prio processes and interrupt |
|
6824 |
handling will run during the sleep. |
|
6825 |
Use either OperatingSystem>>millisecondDelay: (which makes all |
|
6826 |
threads sleep, but handles interrupts) or use a Delay (which makes |
|
6827 |
only the calling thread sleep)." |
|
6828 |
||
6829 |
%{ /* NOCONTEXT */ |
|
6830 |
||
6831 |
if (__isSmallInteger(numberOfSeconds)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6832 |
sleep(__intVal(numberOfSeconds)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6833 |
RETURN ( self ); |
5133 | 6834 |
} |
6835 |
%}. |
|
6836 |
" |
|
6837 |
argument not integer |
|
6838 |
" |
|
6839 |
^ self primitiveFailed |
|
6840 |
||
6841 |
" |
|
6842 |
OperatingSystem sleep:2 |
|
6843 |
" |
|
7638 | 6844 |
! |
6845 |
||
7749 | 6846 |
timeInfoFromSeconds:osSeconds milliseconds:osMilliSeconds localTime:isLocalTime |
7638 | 6847 |
"return a timeInfo structure containing values for the given |
6848 |
OS-second value. |
|
6849 |
An internal helper" |
|
6850 |
||
6851 |
|low hi year month day hours minutes seconds utcOffset |
|
6852 |
dst yDay wDay info| |
|
6853 |
||
6854 |
%{ |
|
6855 |
struct tm *tmPtr; |
|
6856 |
struct tm *gmTmPtr; |
|
6857 |
INT t; |
|
6858 |
TIME_T tt; |
|
6859 |
||
6860 |
t = __longIntVal(osSeconds); |
|
6861 |
tt = (TIME_T)t; |
|
6862 |
||
6863 |
tmPtr = localtime(&tt); |
|
6864 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
|
6865 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6866 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6867 |
||
6868 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
|
6869 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6870 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
6871 |
||
6872 |
yDay = __MKSMALLINT(tmPtr->tm_yday+1); |
|
6873 |
wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday); |
|
6874 |
||
6875 |
if (tmPtr->tm_isdst == 0) { |
|
7840 | 6876 |
dst = false; |
6877 |
utcOffset = __MKINT(TIMEZONE(tmPtr)); |
|
7638 | 6878 |
} else { |
7840 | 6879 |
dst = true; |
7638 | 6880 |
#ifdef HAS_ALTZONE |
7840 | 6881 |
utcOffset = __MKINT(altzone); |
7638 | 6882 |
#else |
7840 | 6883 |
utcOffset = __MKINT(TIMEZONE(tmPtr) + 3600); |
7638 | 6884 |
#endif |
6885 |
} |
|
6886 |
%}. |
|
6887 |
info := self timeInfoClass new. |
|
6888 |
||
6889 |
info |
|
7840 | 6890 |
year:year |
6891 |
month:month |
|
6892 |
day:day |
|
6893 |
hours:hours |
|
6894 |
minutes:minutes |
|
6895 |
seconds:seconds |
|
6896 |
milliseconds:osMilliSeconds |
|
6897 |
utcOffset:utcOffset |
|
6898 |
dst:dst |
|
6899 |
dayInYear:yDay |
|
6900 |
dayInWeek:wDay. |
|
7638 | 6901 |
^ info |
6902 |
||
6903 |
" |
|
6904 |
OperatingSystem timeInfoFromSeconds:0 localTime:false |
|
6905 |
" |
|
5133 | 6906 |
! ! |
6907 |
||
6908 |
!Win32OperatingSystem class methodsFor:'users & groups'! |
|
6909 |
||
6910 |
getEffectiveGroupID |
|
6911 |
"{ Pragma: +optSpace }" |
|
6912 |
||
6913 |
"return the current users (thats you) effective numeric group id. |
|
6914 |
This is only different from getGroupID, if you have ST/X running |
|
6915 |
as a setuid program (of which you should think about twice)." |
|
6916 |
||
6917 |
^ self getGroupID |
|
6918 |
||
6919 |
" |
|
6920 |
OperatingSystem getEffectiveGroupID |
|
6921 |
" |
|
6922 |
! |
|
6923 |
||
6924 |
getEffectiveUserID |
|
6925 |
"{ Pragma: +optSpace }" |
|
6926 |
||
6927 |
"return the current users (thats you) effective numeric user id. |
|
6928 |
This is only different from getUserID, if you have ST/X running |
|
6929 |
as a setuid program (of which you should think about twice)." |
|
6930 |
||
6931 |
^ self getUserID |
|
6932 |
||
6933 |
" |
|
6934 |
OperatingSystem getEffectiveUserID |
|
6935 |
" |
|
6936 |
! |
|
6937 |
||
6938 |
getFullUserNameFromID:userID |
|
6939 |
"{ Pragma: +optSpace }" |
|
6940 |
||
6941 |
"return a string with the users full name - if available. |
|
6942 |
If not, return the login name as a fallBack." |
|
6943 |
||
6944 |
|info gecos| |
|
6945 |
||
6946 |
info := self userInfoOf:userID. |
|
6947 |
(info notNil |
|
6948 |
and:[info includesKey:#gecos]) ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6949 |
gecos := info at:#gecos. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6950 |
(gecos includes:$,) ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6951 |
^ gecos copyTo:(gecos indexOf:$,) - 1 |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6952 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6953 |
^ gecos |
5133 | 6954 |
]. |
6955 |
^ self getUserNameFromID:userID |
|
6956 |
||
6957 |
" |
|
6958 |
OperatingSystem getFullUserNameFromID:0 |
|
6959 |
OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID) |
|
6960 |
||
6961 |
OperatingSystem getUserNameFromID:(OperatingSystem getUserID) |
|
6962 |
" |
|
6963 |
||
6964 |
"Modified: 15.7.1996 / 12:44:21 / cg" |
|
6965 |
! |
|
6966 |
||
6967 |
getGroupID |
|
6968 |
"{ Pragma: +optSpace }" |
|
6969 |
||
6970 |
"return the current users (thats you) numeric group id" |
|
6971 |
||
6972 |
^ 1 "just a dummy for systems which do not have groupIDs" |
|
6973 |
||
6974 |
" |
|
6975 |
OperatingSystem getGroupID |
|
6976 |
" |
|
6977 |
! |
|
6978 |
||
6979 |
getGroupNameFromID:aNumber |
|
6980 |
"{ Pragma: +optSpace }" |
|
6981 |
||
6982 |
"return the group-name-string for a given numeric group-id" |
|
6983 |
||
6984 |
^ '???' "just a dummy for systems which do not have groupIDs" |
|
6985 |
||
6986 |
" |
|
6987 |
OperatingSystem getGroupNameFromID:0 |
|
6988 |
OperatingSystem getGroupNameFromID:10 |
|
6989 |
" |
|
6990 |
! |
|
6991 |
||
6992 |
getHomeDirectory |
|
6993 |
"{ Pragma: +optSpace }" |
|
6994 |
||
5264
9a90c499e329
return the currentDir as default fallBack for the getHomeDir query.
Claus Gittinger <cg@exept.de>
parents:
5147
diff
changeset
|
6995 |
"return the name of the users home directory (i.e. yours). |
9a90c499e329
return the currentDir as default fallBack for the getHomeDir query.
Claus Gittinger <cg@exept.de>
parents:
5147
diff
changeset
|
6996 |
This uses the value of the HOME environment variable, |
9a90c499e329
return the currentDir as default fallBack for the getHomeDir query.
Claus Gittinger <cg@exept.de>
parents:
5147
diff
changeset
|
6997 |
or HOMEDRIVE:HOMEPATH as a fallBack. |
9a90c499e329
return the currentDir as default fallBack for the getHomeDir query.
Claus Gittinger <cg@exept.de>
parents:
5147
diff
changeset
|
6998 |
If not set, return the current directory." |
5133 | 6999 |
|
7000 |
|dir drv path| |
|
7001 |
||
7002 |
dir := self getEnvironment:'HOME'. |
|
7003 |
dir isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7004 |
"/ for NT users: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7005 |
"/ if HOME is nil, try HOMEDRIVE and HOMEPATH |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7006 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7007 |
((drv := self getEnvironment:'HOMEDRIVE') notNil |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7008 |
and:[(path := self getEnvironment:'HOMEPATH') notNil]) ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7009 |
dir := drv , path |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7010 |
] ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7011 |
dir := '.'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7012 |
]. |
5133 | 7013 |
]. |
7014 |
^ dir |
|
7015 |
||
7016 |
" |
|
7017 |
OperatingSystem getHomeDirectory |
|
7018 |
" |
|
7019 |
||
5264
9a90c499e329
return the currentDir as default fallBack for the getHomeDir query.
Claus Gittinger <cg@exept.de>
parents:
5147
diff
changeset
|
7020 |
"Modified: / 16.2.2000 / 09:17:55 / cg" |
5133 | 7021 |
! |
7022 |
||
7023 |
getLoginName |
|
7024 |
"{ Pragma: +optSpace }" |
|
7025 |
||
7026 |
"return a string with the users login name (thats yours)" |
|
7027 |
||
7028 |
%{ /* NOCONTEXT */ |
|
7029 |
static char cachedName[64]; |
|
7030 |
static firstCall = 1; |
|
7031 |
#ifndef __BORLANDC__ |
|
7032 |
extern char *getenv(); |
|
7033 |
#endif |
|
7034 |
char *name = (char *)0; |
|
7035 |
||
7036 |
if (firstCall) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7037 |
int nameSize = sizeof(cachedName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7038 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7039 |
if (GetUserName(cachedName, &nameSize) == TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7040 |
name = cachedName; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7041 |
firstCall = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7042 |
} |
5133 | 7043 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7044 |
name = cachedName; |
5133 | 7045 |
} |
7046 |
||
7047 |
/* |
|
7048 |
* try a few common environment variables ... |
|
7049 |
*/ |
|
7050 |
if (! name || (name[0] == 0) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7051 |
name = getenv("LOGIN"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7052 |
if (! name || (name[0] == 0) ) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7053 |
name = getenv("LOGNAME"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7054 |
if (! name || (name[0] == 0) ) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7055 |
name = getenv("USER"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7056 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7057 |
} |
5133 | 7058 |
} |
7059 |
/* |
|
7060 |
* nope - I really font know who you are. |
|
7061 |
*/ |
|
7062 |
if (! name || (name[0] == 0) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7063 |
name = "you"; |
5133 | 7064 |
} |
7065 |
||
7066 |
RETURN ( __MKSTRING(name) ); |
|
7067 |
%}. |
|
7068 |
" |
|
7069 |
OperatingSystem getLoginName |
|
7070 |
" |
|
7071 |
! |
|
7072 |
||
7073 |
getUserID |
|
7074 |
"{ Pragma: +optSpace }" |
|
7075 |
||
7076 |
"return the current users (thats you) numeric user id" |
|
7077 |
||
7078 |
^ 1 "just a dummy for systems which do not have userIDs" |
|
7079 |
||
7080 |
" |
|
7081 |
OperatingSystem getUserID |
|
7082 |
" |
|
7083 |
! |
|
7084 |
||
7085 |
getUserNameFromID:aNumber |
|
7086 |
"{ Pragma: +optSpace }" |
|
7087 |
||
7088 |
"return the user-name-string for a given numeric user-id. |
|
7089 |
This is the login name, not the fullName." |
|
7090 |
||
7091 |
aNumber == self getUserID ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7092 |
^ self getLoginName |
5133 | 7093 |
]. |
7094 |
||
7095 |
^ '? (' , aNumber printString , ')' |
|
7096 |
||
7097 |
" |
|
7098 |
OperatingSystem getUserNameFromID:0 |
|
7099 |
OperatingSystem getUserNameFromID:100 |
|
7100 |
OperatingSystem getUserNameFromID:9991 |
|
7101 |
" |
|
7102 |
! |
|
7103 |
||
7104 |
userInfoOf:aNameOrID |
|
7105 |
"{ Pragma: +optSpace }" |
|
7106 |
||
7107 |
"return a dictionary filled with userinfo. The argument can be either |
|
7108 |
a string with the users name or its numeric id. |
|
7109 |
Notice, that DOS systems only provide a very limited set of information. |
|
7110 |
Portable applications may want to check the systemType and NOT depend |
|
7111 |
on all keys to be present in the returned dictionary." |
|
7112 |
||
7113 |
|info name uid gid dir| |
|
7114 |
||
7115 |
info := IdentityDictionary new. |
|
7116 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7117 |
aNameOrID == self getUserID ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7118 |
name := self getLoginName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7119 |
]. |
5133 | 7120 |
]. |
7121 |
name notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7122 |
info at:#name put:name. |
5133 | 7123 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7124 |
info at:#name put:'unknown' |
5133 | 7125 |
]. |
7126 |
dir isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7127 |
aNameOrID == self getUserID ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7128 |
dir := self getHomeDirectory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7129 |
] |
5133 | 7130 |
]. |
7131 |
dir notNil ifTrue:[info at:#dir put:dir]. |
|
7132 |
"/ uid notNil ifTrue:[info at:#uid put:uid]. |
|
7133 |
"/ gid notNil ifTrue:[info at:#gid put:gid]. |
|
7134 |
^ info |
|
7135 |
||
7136 |
" |
|
7137 |
OperatingSystem userInfoOf:'root' |
|
7138 |
OperatingSystem userInfoOf:1 |
|
7139 |
OperatingSystem userInfoOf:'claus' |
|
7140 |
OperatingSystem userInfoOf:'fooBar' |
|
7141 |
OperatingSystem userInfoOf:(OperatingSystem getUserID) |
|
7142 |
" |
|
7143 |
! ! |
|
7144 |
||
7145 |
!Win32OperatingSystem class methodsFor:'waiting for events'! |
|
7146 |
||
7147 |
blockingChildProcessWait |
|
7148 |
"return true, if childProcessWait: blocks, if no children are ready. |
|
7149 |
On those systems, we must be somewhat careful when looking out for |
|
7150 |
a subprocesses status (to avoid blocking)." |
|
7151 |
||
7152 |
^ false |
|
7153 |
! |
|
7154 |
||
7155 |
childProcessWait:blocking pid:pidToWait |
|
7156 |
"{ Pragma: +optSpace }" |
|
7157 |
||
7158 |
"get status changes from child processes. |
|
7159 |
Return an OSProcessStatus or nil, if no process has terminated. |
|
7160 |
If blocking is true, we wait until a process changed state, |
|
7161 |
otherwise we return immediately. |
|
7162 |
Note that win32 needs to know the HANDLE of the process on which |
|
7163 |
it waits. In case of an error, THIS ALWAYS WAITS and then times out." |
|
7164 |
||
7165 |
|pid status code core| |
|
7166 |
%{ |
|
7167 |
DWORD endStatus; |
|
7168 |
||
7662 | 7169 |
if (__isExternalAddressLike(pidToWait) ) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7170 |
HANDLE __pidToWait = _HANDLEVal(pidToWait); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7171 |
int t; |
5133 | 7172 |
|
7173 |
#ifdef PROCESS1DEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7174 |
printf("childProcessWait %x b %d\n",__pidToWait,blocking==true); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7175 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7176 |
t = blocking==true ? INFINITE : 0; |
5133 | 7177 |
|
7178 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7179 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7180 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7181 |
endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, __pidToWait, t); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7182 |
} while ((endStatus < 0) && (__threadErrno == EINTR)); |
5133 | 7183 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7184 |
endStatus = WaitForSingleObject(__pidToWait, t); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7185 |
if (endStatus < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7186 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7187 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7188 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7189 |
if ( endStatus == WAIT_TIMEOUT ) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7190 |
if (blocking==true) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7191 |
status = @symbol(timeout); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7192 |
else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7193 |
status = @symbol(continue); |
5133 | 7194 |
#ifdef PROCESS1DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7195 |
printf("ret nil\n"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7196 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7197 |
RETURN(nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7198 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7199 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7200 |
status = @symbol(exit); |
5133 | 7201 |
#ifdef PROCESS1DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7202 |
printf("exit\n"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7203 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7204 |
if (endStatus == WAIT_OBJECT_0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7205 |
if (GetExitCodeProcess(__pidToWait, &endStatus)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7206 |
if (endStatus == STILL_ACTIVE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7207 |
RETURN(nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7208 |
} |
5133 | 7209 |
#ifdef PROCESS1DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7210 |
printf("exit %d\n",endStatus); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7211 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7212 |
code = __MKSMALLINT(endStatus); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7213 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7214 |
code = __MKSMALLINT(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7215 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7216 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7217 |
code = __MKSMALLINT(-1); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7218 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7219 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7220 |
core = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7221 |
pid = pidToWait; |
5133 | 7222 |
} |
7223 |
%}. |
|
7224 |
||
7225 |
(status isNil or:[pid isNil]) ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7226 |
^ self primitiveFailed |
5133 | 7227 |
]. |
7228 |
||
7229 |
"/ Transcript show:'pid: '; show:pid; show:' status: '; show:status; |
|
7230 |
"/ show:' code: '; show:code; show:' core:'; showCR:core. |
|
7231 |
||
7232 |
^ OSProcessStatus pid:pid status:status code:code core:core |
|
7233 |
||
7234 |
" |
|
7235 |
OperatingSystem childProcessWait:false |
|
7236 |
" |
|
7237 |
||
7238 |
"Created: 5.1.1996 / 16:39:14 / stefan" |
|
7239 |
! |
|
7240 |
||
7241 |
numAvailableForReadOn:fd |
|
7242 |
"return the number of bytes available for reading, without blocking." |
|
7243 |
||
7244 |
^ (self readCheck:fd) ifTrue:[1] ifFalse:[0] |
|
7245 |
! |
|
7246 |
||
7247 |
readCheck:fd |
|
7248 |
"return true, if data is available on a filedescriptor |
|
7249 |
(i.e. read is possible without blocking). |
|
7250 |
This depends on a working select or FIONREAD to be provided by the OS." |
|
7251 |
||
7252 |
^ super readCheck:fd |
|
7253 |
! |
|
7254 |
||
7255 |
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis |
|
7256 |
"wait for any fd in readFdArray (an Array of integers) to become ready for |
|
7257 |
reading, writeFdArray to become ready for writing, or exceptFdArray to |
|
7258 |
arrive exceptional data (i.e. out-of-band data). |
|
7259 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7260 |
Empty fd-sets will always wait. Zero time can be used to poll file- |
|
7261 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7262 |
Return first ready fd if I/O ok, nil if timed-out or interrupted." |
|
7263 |
||
7264 |
%{ |
|
7265 |
#define MAXHANDLE 128 |
|
7266 |
||
7267 |
int i; |
|
7268 |
INT t; |
|
7269 |
OBJ fd, retFd; |
|
7270 |
int ret; |
|
7271 |
int numHandles = 0; |
|
7272 |
DWORD res; |
|
7865 | 7273 |
HANDLE hArray[MAXHANDLE+1]; |
5133 | 7274 |
int retArray[MAXHANDLE]; |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7275 |
int readCount; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7276 |
int writeCount; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7277 |
int exceptCount; |
5133 | 7278 |
|
7279 |
if (__isNonNilObject(readFdArray)) { |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7280 |
if (! __isArray(readFdArray)) goto fail; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7281 |
readCount = __arraySize(readFdArray); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7282 |
} else { |
7840 | 7283 |
readCount = 0; |
5133 | 7284 |
} |
7285 |
||
7286 |
if (__isNonNilObject(writeFdArray)) { |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7287 |
if (! __isArray(writeFdArray)) goto fail; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7288 |
writeCount = __arraySize(writeFdArray); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7289 |
} else { |
7840 | 7290 |
writeCount = 0; |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7291 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7292 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7293 |
if (__isNonNilObject(exceptFdArray)) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7294 |
if (! __isArray(exceptFdArray)) goto fail; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7295 |
exceptCount = __arraySize(exceptFdArray); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7296 |
} else { |
7840 | 7297 |
exceptCount = 0; |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7298 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7299 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7300 |
for (i = 0; (i < readCount) && (numHandles < MAXHANDLE);i++) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7301 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7302 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7303 |
if (fd != nil) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7304 |
if (__isExternalAddressLike(fd)) { |
7840 | 7305 |
hArray [numHandles] = _HANDLEVal(fd); |
7306 |
retArray[numHandles] = i; |
|
7307 |
++numHandles; |
|
7308 |
} else { |
|
7309 |
if (_canReadWithoutBlocking (__intVal(fd) ) ) { |
|
7310 |
RETURN (fd); |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7311 |
} |
7840 | 7312 |
} |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7313 |
} |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7314 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7315 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7316 |
for (i = 0; (i < writeCount) && (numHandles < MAXHANDLE);i++) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7317 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7318 |
|
7840 | 7319 |
if (fd != nil) { |
7320 |
if (__isExternalAddressLike(fd)) { |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7321 |
hArray [numHandles] = _HANDLEVal(fd); |
7840 | 7322 |
retArray[numHandles] = i + 10000; |
7323 |
++numHandles; |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7324 |
} else { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7325 |
if (_canWriteWithoutBlocking (__intVal(fd) ) ) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7326 |
RETURN (fd); |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7327 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7328 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7329 |
} |
5133 | 7330 |
} |
7331 |
||
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7332 |
for (i = 0; (i < exceptCount) && (numHandles < MAXHANDLE);i++) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7333 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7334 |
|
7840 | 7335 |
if (fd != nil) { |
7336 |
if (__isExternalAddressLike(fd)) { |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7337 |
hArray [numHandles] = _HANDLEVal(fd); |
7840 | 7338 |
retArray[numHandles] = i + 20000; |
7339 |
++numHandles; |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7340 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7341 |
} |
5133 | 7342 |
} |
7343 |
||
7344 |
if (__isSmallInteger(millis)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7345 |
t = __intVal(millis); |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7346 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7347 |
if (t <= 0 && numHandles == 0) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7348 |
RETURN (nil); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7349 |
} |
5133 | 7350 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7351 |
t = INFINITE; |
5133 | 7352 |
} |
7353 |
||
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7354 |
#ifdef SELECT3DEBUGWIN32 |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7355 |
printf("wait Handles = %d timeout = %d\n",numHandles, t); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7356 |
#endif |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7357 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7358 |
res = __vmWait (numHandles, hArray, MAXHANDLE, t); |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7359 |
|
5133 | 7360 |
if (numHandles) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7361 |
if (res == WAIT_FAILED) { |
5133 | 7362 |
#ifdef SELECT2DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7363 |
printf("- error %d; ret nil\n",GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7364 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7365 |
if (__threadErrno == EINTR) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7366 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7367 |
@global(LastErrorNumber) = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7368 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7369 |
__threadErrno = EBADF; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7370 |
if (@global(InfoPrinting) == true) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7371 |
fprintf(stderr, "OS [info]: select errno = %d\n", __threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7372 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7373 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7374 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7375 |
RETURN ( nil ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7376 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7377 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7378 |
if (res == WAIT_TIMEOUT) { |
5133 | 7379 |
#ifdef SELECT3DEBUGWIN32 |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7380 |
printf("- timeOut; ret nil\n" ); |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7381 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7382 |
goto polling; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7383 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7384 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7385 |
if ((res < 0) || (res >= numHandles)) { |
5133 | 7386 |
#ifdef SELECTDEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7387 |
printf("- res=%d error1 %d\n", res, GetLastError()); |
5133 | 7388 |
#endif |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7389 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7390 |
@global(LastErrorNumber) = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7391 |
RETURN ( nil ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7392 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7393 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7394 |
ret = res; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7395 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7396 |
if (ret < numHandles) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7397 |
int fd = retArray[ret]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7398 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7399 |
@global(LastErrorNumber) = nil; |
5133 | 7400 |
|
7401 |
#ifdef SELECTDEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7402 |
if (ret) printf("wait Handles %d %d ret\n", ret, fd); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7403 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7404 |
if (fd < 10000) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7405 |
RETURN ( __ArrayInstPtr(readFdArray)->a_element[fd] ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7406 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7407 |
if (fd < 20000) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7408 |
RETURN ( __ArrayInstPtr(writeFdArray)->a_element[fd-10000] ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7409 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7410 |
RETURN ( __ArrayInstPtr(exceptFdArray)->a_element[fd-20000] ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7411 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7412 |
printf("wait Handles ret = %d error2 %d\n", ret, GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7413 |
goto fail; |
5133 | 7414 |
} else { |
7415 |
||
7416 |
polling: |
|
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7417 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7418 |
for (i=0; i < readCount;i++) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7419 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7420 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7421 |
if (fd != nil) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7422 |
if (! __isExternalAddressLike(fd)) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7423 |
if (_canReadWithoutBlocking (__intVal(fd)) ) { |
7840 | 7424 |
RETURN (fd); |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7425 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7426 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7427 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7428 |
} |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7429 |
|
7840 | 7430 |
for (i=0; i < writeCount;i++) { |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7431 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7432 |
|
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7433 |
if (fd != nil) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7434 |
if (! __isExternalAddressLike(fd)) { |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7435 |
if (_canWriteWithoutBlocking (__intVal(fd)) ) { |
7840 | 7436 |
RETURN (fd); |
7825
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7437 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7438 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7439 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7440 |
} |
b58ba4e4dcd6
bugfix in selectOnAnyReadable:writable:exception:withTimeOut:
ca
parents:
7777
diff
changeset
|
7441 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7442 |
@global(LastErrorNumber) = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7443 |
RETURN ( nil ); |
5133 | 7444 |
} |
7445 |
||
7446 |
fail: ; |
|
7447 |
%}. |
|
7448 |
" |
|
7449 |
timeout argument not integer, |
|
7450 |
or any fd-array nonNil and not an array |
|
7451 |
or not supported by OS |
|
7452 |
" |
|
7453 |
^ self primitiveFailed |
|
7454 |
! |
|
7455 |
||
7456 |
setBlocking:aBoolean on:fd |
|
7457 |
"{ Pragma: +optSpace }" |
|
7458 |
||
7459 |
"set/clear the blocking attribute - if set (which is the default) |
|
7460 |
a read on the fileDescriptor will block until data is available. |
|
7461 |
If cleared, a read operation will immediately return with a value of |
|
7462 |
nil." |
|
7463 |
||
7464 |
^ self primitiveFailed |
|
7465 |
! |
|
7466 |
||
7467 |
waitForMultipleObjects:fdOrHandleArray withTimeout:millis |
|
7468 |
"wait for an fd to become ready. |
|
7469 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7470 |
Zero time can be used to poll a file- |
|
7471 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7472 |
Return the fd if I/O ok, nil if timed-out or interrupted." |
|
7473 |
||
7474 |
%{ |
|
7475 |
#ifndef MAXHANDLE |
|
7476 |
# define MAXHANDLE 128 |
|
7477 |
#endif |
|
7478 |
INT t; |
|
7479 |
DWORD res; |
|
7480 |
HANDLE hArray[MAXHANDLE]; |
|
7481 |
INT i, count; |
|
7482 |
||
7483 |
if (! __isArray(fdOrHandleArray)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7484 |
goto fail; |
5133 | 7485 |
} |
7486 |
count = __arraySize(fdOrHandleArray); |
|
7487 |
||
7488 |
for (i=0; i<count; i++) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7489 |
OBJ fdOrHandle = __ArrayInstPtr(fdOrHandleArray)->a_element[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7490 |
HANDLE h; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7491 |
|
7662 | 7492 |
if (__isExternalAddressLike(fdOrHandle)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7493 |
h = _HANDLEVal(fdOrHandle); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7494 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7495 |
if (__isSmallInteger(fdOrHandle)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7496 |
h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7497 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7498 |
goto fail; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7499 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7500 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7501 |
hArray[i] = h; |
5133 | 7502 |
} |
7503 |
||
7504 |
if (__isSmallInteger(millis)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7505 |
t = __intVal(millis); |
5133 | 7506 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7507 |
t = INFINITE; |
5133 | 7508 |
} |
7509 |
||
7510 |
#ifdef DO_WRAP_CALLS |
|
7511 |
do { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7512 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7513 |
res = STX_API_CALL4( "WaitForMultipleObjects", WaitForMultipleObjects, count, hArray, FALSE, t); |
5133 | 7514 |
} while ((res < 0) && (__threadErrno == EINTR)); |
7515 |
#else |
|
7516 |
res = WaitForMultipleObjects(count, hArray, FALSE, t); |
|
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
7517 |
if (res < 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7518 |
__threadErrno = __WIN32_ERR(GetLastError()); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
7519 |
} |
5133 | 7520 |
#endif |
7521 |
if (res == WAIT_FAILED) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7522 |
RETURN (nil); |
5133 | 7523 |
} |
7524 |
if (res == WAIT_TIMEOUT) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7525 |
RETURN (nil); |
5133 | 7526 |
} |
7527 |
if ((res >= WAIT_OBJECT_0) && (res < (WAIT_OBJECT_0+count))) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7528 |
RETURN (__ArrayInstPtr(fdOrHandleArray)->a_element[res-WAIT_OBJECT_0]); |
5133 | 7529 |
} |
7530 |
||
7531 |
RETURN (nil); |
|
7532 |
fail: ; |
|
7533 |
%}. |
|
7534 |
" |
|
7535 |
invalid arg, |
|
7536 |
" |
|
7537 |
^ self primitiveFailed |
|
7538 |
! |
|
7539 |
||
7540 |
waitForSingleObject:fdOrHandle withTimeout:millis |
|
7541 |
"wait for an fd to become ready. |
|
7542 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7543 |
Zero time can be used to poll a file- |
|
7544 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7545 |
Return the fd if I/O ok, nil if timed-out or interrupted." |
|
7546 |
||
7547 |
%{ |
|
7548 |
INT t; |
|
7549 |
DWORD res; |
|
7550 |
HANDLE h = NULL; |
|
7551 |
||
7662 | 7552 |
if (__isExternalAddressLike(fdOrHandle)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7553 |
h = _HANDLEVal(fdOrHandle); |
5133 | 7554 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7555 |
if (__isSmallInteger(fdOrHandle)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7556 |
h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7557 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7558 |
goto fail; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7559 |
} |
5133 | 7560 |
} |
7561 |
||
7562 |
if (__isSmallInteger(millis)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7563 |
t = __intVal(millis); |
5133 | 7564 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7565 |
t = INFINITE; |
5133 | 7566 |
} |
7567 |
||
7568 |
#ifdef DO_WRAP_CALLS |
|
7569 |
do { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7570 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7571 |
res = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, h, t); |
5133 | 7572 |
} while ((res < 0) && (__threadErrno == EINTR)); |
7573 |
#else |
|
7574 |
res = WaitForSingleObject(h, t); |
|
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
7575 |
if (res < 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7576 |
__threadErrno = __WIN32_ERR(GetLastError()); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
7577 |
} |
5133 | 7578 |
#endif |
7579 |
if (res == WAIT_FAILED) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7580 |
RETURN (nil); |
5133 | 7581 |
} |
7582 |
if (res == WAIT_TIMEOUT) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7583 |
RETURN (nil); |
5133 | 7584 |
} |
7585 |
||
7586 |
RETURN (fdOrHandle); |
|
7587 |
fail: ; |
|
7588 |
%}. |
|
7589 |
" |
|
7590 |
invalid arg, |
|
7591 |
" |
|
7592 |
^ self primitiveFailed |
|
7593 |
! ! |
|
7594 |
||
6275 | 7595 |
!Win32OperatingSystem::FileStatusInfo class methodsFor:'instance creation'! |
7596 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7597 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP alternativeName:name2 |
6275 | 7598 |
^ self basicNew |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7599 |
type:t mode:m uid:u gid:g size:s |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7600 |
id:i accessed:aT modified:mT created:cT |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7601 |
path:lP alternativeName:name2 |
7062 | 7602 |
! |
7603 |
||
7604 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP fullName:fullName alternativeName:name2 |
|
7605 |
^ self basicNew |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7606 |
type:t mode:m uid:u gid:g size:s |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7607 |
id:i accessed:aT modified:mT created:cT |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7608 |
path:lP |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7609 |
fullName:fullName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7610 |
alternativeName:name2 |
6275 | 7611 |
! ! |
7612 |
||
7613 |
!Win32OperatingSystem::FileStatusInfo methodsFor:'accessing'! |
|
7614 |
||
6372 | 7615 |
accessTime |
7616 |
"return accessed" |
|
7617 |
||
7618 |
^ accessed |
|
7619 |
||
7620 |
"Created: / 1.2.2002 / 11:05:49 / cg" |
|
7621 |
! |
|
7622 |
||
6275 | 7623 |
alternativeName |
7624 |
"return the files other name (DOS name on windows). |
|
7625 |
Nil if there is no other name" |
|
7626 |
||
7627 |
^ alternativeName |
|
7628 |
! |
|
7629 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7630 |
creationTime |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7631 |
^ created |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7632 |
! |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7633 |
|
6372 | 7634 |
fileSize |
7635 |
"return size" |
|
7636 |
||
7637 |
^ size |
|
7638 |
||
7639 |
"Created: / 1.2.2002 / 11:06:15 / cg" |
|
7640 |
! |
|
7641 |
||
6275 | 7642 |
fixedHeaderSize |
7643 |
"return the fixedHeaderSize (VMS only; nil everywhere else)" |
|
7644 |
||
7645 |
^ nil |
|
7646 |
! |
|
7647 |
||
7062 | 7648 |
fullName |
7649 |
"return the files real name (non-DOS name on windows). |
|
7650 |
Nil if there is no other name" |
|
7651 |
||
7652 |
^ fullName |
|
7653 |
! |
|
7654 |
||
6275 | 7655 |
gid |
7656 |
"return gid" |
|
7657 |
||
7658 |
^ gid |
|
7659 |
! |
|
7660 |
||
7661 |
id |
|
7662 |
"return id" |
|
7663 |
||
7664 |
^ id |
|
7665 |
! |
|
7666 |
||
7667 |
mode |
|
7668 |
"return mode" |
|
7669 |
||
7670 |
^ mode |
|
7671 |
! |
|
7672 |
||
6372 | 7673 |
modificationTime |
7674 |
"return modified" |
|
7675 |
||
7676 |
^ modified |
|
7677 |
||
7678 |
"Created: / 1.2.2002 / 11:06:33 / cg" |
|
7679 |
! |
|
7680 |
||
7681 |
numLinks |
|
7682 |
"DOS has no hardLinks - return 1" |
|
7683 |
||
7684 |
^ 1 |
|
7685 |
||
7686 |
"Created: / 1.2.2002 / 11:07:04 / cg" |
|
7687 |
! |
|
7688 |
||
6275 | 7689 |
path |
7690 |
"for symbolic links only: return the path where the symbolic link points to" |
|
7691 |
||
7692 |
^ path |
|
7693 |
||
7694 |
! |
|
7695 |
||
7696 |
recordAttributes |
|
7697 |
"return the recordAttributes (VMS only; nil everywhere else)" |
|
7698 |
||
7699 |
^ nil |
|
7700 |
! |
|
7701 |
||
7702 |
recordFormat |
|
7703 |
"return the recordFormat (VMS only; nil everywhere else)" |
|
7704 |
||
7705 |
^ nil |
|
7706 |
! |
|
7707 |
||
7708 |
recordFormatNumeric |
|
7709 |
"return the recordFormat as numeric (VMS only; nil everywhere else)" |
|
7710 |
||
7711 |
^ nil |
|
7712 |
! |
|
7713 |
||
7714 |
recordSize |
|
7715 |
"return the recordSize (VMS only; nil everywhere else)" |
|
7716 |
||
7717 |
^ nil |
|
7718 |
! |
|
7719 |
||
7720 |
size |
|
7721 |
"return size" |
|
7722 |
||
7723 |
^ size |
|
7724 |
! |
|
7725 |
||
6372 | 7726 |
statusChangeTime |
7727 |
"return statusChanged" |
|
7728 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7729 |
^ statusChanged ? modified |
6372 | 7730 |
|
7731 |
"Created: / 1.2.2002 / 11:07:27 / cg" |
|
7732 |
! |
|
7733 |
||
6275 | 7734 |
type |
7735 |
"return type" |
|
7736 |
||
7737 |
^ type |
|
7738 |
! |
|
7739 |
||
7740 |
uid |
|
7741 |
"return uid" |
|
7742 |
||
7743 |
^ uid |
|
7744 |
! ! |
|
7745 |
||
7746 |
!Win32OperatingSystem::FileStatusInfo methodsFor:'backward compatibility'! |
|
7747 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7748 |
accessed |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7749 |
"return accessed" |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7750 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7751 |
self obsoleteMethodWarning:'use #accessTime'. |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7752 |
^ accessed |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7753 |
! |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7754 |
|
6275 | 7755 |
at:key |
7756 |
"backward compatibility access: in previous releases, IdentityDictionaries |
|
7757 |
were used to hold my information. Allow access via key messages. |
|
7758 |
This method will vanish - use the proper access protocol." |
|
7759 |
||
7760 |
^ self perform:key |
|
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7761 |
! |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7762 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7763 |
modified |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7764 |
"return modified" |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7765 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7766 |
self obsoleteMethodWarning:'use #modificationTime'. |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7767 |
^ modified |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7768 |
! |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7769 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7770 |
statusChanged |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7771 |
"return statusChanged" |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7772 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7773 |
self obsoleteMethodWarning:'use #statusChangeTime'. |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7774 |
^ statusChanged |
6275 | 7775 |
! ! |
7776 |
||
7777 |
!Win32OperatingSystem::FileStatusInfo methodsFor:'private accessing'! |
|
7778 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7779 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP alternativeName:name2 |
6275 | 7780 |
type := t. |
7781 |
mode := m. |
|
7782 |
uid := u. |
|
7783 |
gid := g. |
|
7784 |
size := s. |
|
7785 |
id := i. |
|
7786 |
accessed := aT. |
|
7787 |
modified := mT. |
|
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7788 |
created := cT. |
6275 | 7789 |
path := lP. |
7790 |
alternativeName := name2. |
|
7062 | 7791 |
! |
7792 |
||
7793 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP fullName:name1 alternativeName:name2 |
|
7794 |
type := t. |
|
7795 |
mode := m. |
|
7796 |
uid := u. |
|
7797 |
gid := g. |
|
7798 |
size := s. |
|
7799 |
id := i. |
|
7800 |
accessed := aT. |
|
7801 |
modified := mT. |
|
7802 |
created := cT. |
|
7803 |
path := lP. |
|
7804 |
fullName := name1. |
|
7805 |
alternativeName := name2. |
|
6275 | 7806 |
! ! |
7807 |
||
6799 | 7808 |
!Win32OperatingSystem::FileStatusInfo methodsFor:'queries'! |
7809 |
||
7810 |
isDirectory |
|
7811 |
^ type == #directory |
|
7812 |
! |
|
7813 |
||
7814 |
isSymbolicLink |
|
7815 |
^ type == #symbolicLink |
|
7816 |
! ! |
|
7817 |
||
6275 | 7818 |
!Win32OperatingSystem::OSProcessStatus class methodsFor:'documentation'! |
7819 |
||
7820 |
documentation |
|
7821 |
" |
|
7822 |
This is an auxillary class, that holds information about status changes of |
|
7823 |
operating system processes (these are no smalltalk processes!!). |
|
7824 |
||
7825 |
[Instance variables:] |
|
7826 |
||
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7827 |
pid <Integer> OS-Process identifier |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7828 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7829 |
status <Symbol> either #exit #signal #stop #continue |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7830 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7831 |
code <Integer> either exitcode or signalnumber |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7832 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7833 |
core <Boolean> true if core has been dumped |
6275 | 7834 |
|
7835 |
||
7836 |
[author:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7837 |
Stefan Vogel |
6275 | 7838 |
|
7839 |
[see also:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7840 |
OperatingSystem |
6275 | 7841 |
" |
7842 |
! ! |
|
7843 |
||
7844 |
!Win32OperatingSystem::OSProcessStatus class methodsFor:'instance creation'! |
|
7845 |
||
7846 |
pid:pid status:status code:code core:core |
|
7847 |
"private interface for Win32OperatingSystem" |
|
7848 |
||
7849 |
^ self new pid:pid status:status code:code core:core |
|
7850 |
||
7851 |
"Created: 28.12.1995 / 14:16:14 / stefan" |
|
7852 |
"Modified: 30.4.1996 / 18:25:00 / cg" |
|
7853 |
! |
|
7854 |
||
7855 |
processCreationFailure |
|
7856 |
"private interface for Win32OperatingSystem" |
|
7857 |
||
7858 |
^ self new pid:-1 status:#failure code:-1 core:false |
|
7859 |
||
7860 |
"Created: 28.12.1995 / 14:35:29 / stefan" |
|
7861 |
"Modified: 30.4.1996 / 18:25:05 / cg" |
|
7862 |
! ! |
|
7863 |
||
7864 |
!Win32OperatingSystem::OSProcessStatus methodsFor:'accessing'! |
|
7865 |
||
7866 |
code |
|
7867 |
"return the exitcode / signalNumber" |
|
7868 |
||
7869 |
^ code |
|
7870 |
||
7871 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7872 |
"Modified: 30.4.1996 / 18:26:23 / cg" |
|
7873 |
! |
|
7874 |
||
7875 |
core |
|
7876 |
"return true if core has been dumped, false otherwise" |
|
7877 |
||
7878 |
^ core == true |
|
7879 |
||
7880 |
"Modified: 28.12.1995 / 14:14:38 / stefan" |
|
7881 |
! |
|
7882 |
||
7883 |
pid |
|
7884 |
"return the pid" |
|
7885 |
||
7886 |
^ pid |
|
7887 |
||
7888 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7889 |
"Modified: 30.4.1996 / 18:26:30 / cg" |
|
7890 |
! |
|
7891 |
||
7892 |
status |
|
7893 |
"return status as a Symbol; |
|
7894 |
one of #exit #signal #stop #continue" |
|
7895 |
||
7896 |
^ status |
|
7897 |
||
7898 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7899 |
"Modified: 30.4.1996 / 18:26:54 / cg" |
|
7900 |
! ! |
|
7901 |
||
7902 |
!Win32OperatingSystem::OSProcessStatus methodsFor:'initialization'! |
|
7903 |
||
7904 |
pid:newPid status:newStatus code:newCode core:newCore |
|
7905 |
pid := newPid. |
|
7906 |
status := newStatus. |
|
7907 |
code := newCode. |
|
7908 |
core := newCore. |
|
7909 |
||
7910 |
"Created: 28.12.1995 / 14:18:22 / stefan" |
|
7911 |
! ! |
|
7912 |
||
7913 |
!Win32OperatingSystem::OSProcessStatus methodsFor:'private-OS interface'! |
|
7914 |
||
7915 |
code:something |
|
7916 |
"set the exitCode" |
|
7917 |
||
7918 |
code := something. |
|
7919 |
||
7920 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7921 |
"Modified: 30.4.1996 / 18:25:18 / cg" |
|
7922 |
! |
|
7923 |
||
7924 |
core:something |
|
7925 |
"set core" |
|
7926 |
||
7927 |
core := something. |
|
7928 |
||
7929 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7930 |
! |
|
7931 |
||
7932 |
pid:something |
|
7933 |
"set pid" |
|
7934 |
||
7935 |
pid := something. |
|
7936 |
||
7937 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7938 |
! |
|
7939 |
||
7940 |
status:something |
|
7941 |
"set status" |
|
7942 |
||
7943 |
status := something. |
|
7944 |
||
7945 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7946 |
! ! |
|
7947 |
||
7948 |
!Win32OperatingSystem::OSProcessStatus methodsFor:'queries'! |
|
7949 |
||
7950 |
couldNotExecute |
|
7951 |
"return true when a command could not be executed" |
|
7952 |
||
7953 |
^ status == #exit and:[code = 127]. |
|
7954 |
||
7955 |
"Created: 28.12.1995 / 15:43:17 / stefan" |
|
7956 |
"Modified: 30.4.1996 / 18:27:03 / cg" |
|
7957 |
! |
|
7958 |
||
7959 |
stillAlive |
|
7960 |
"true if process is still alive" |
|
7961 |
||
7962 |
^ status == #stop or:[status == #continue] |
|
7963 |
||
7964 |
"Created: 28.12.1995 / 14:27:26 / stefan" |
|
7965 |
! |
|
7966 |
||
7967 |
success |
|
7968 |
"true if process terminated successfully" |
|
7969 |
||
7970 |
^ status == #exit and:[code = 0] |
|
7971 |
||
7972 |
"Created: 28.12.1995 / 14:13:05 / stefan" |
|
7973 |
"Modified: 28.12.1995 / 14:13:41 / stefan" |
|
7974 |
! ! |
|
7975 |
||
5133 | 7976 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'defaults'! |
7977 |
||
7978 |
rootKeyNames |
|
7979 |
^ #( |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7980 |
'HKEY_CLASSES_ROOT' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7981 |
'HKEY_CURRENT_USER' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7982 |
'HKEY_LOCAL_MACHINE' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7983 |
'HKEY_USERS' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7984 |
'HKEY_PERFORMANCE_DATA' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7985 |
'HKEY_CURRENT_CONFIG' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7986 |
'HKEY_DYN_DATA' |
5133 | 7987 |
) |
7988 |
! |
|
7989 |
||
7990 |
separator |
|
7991 |
^$\ |
|
7992 |
! ! |
|
7993 |
||
7994 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'documentation'! |
|
7995 |
||
7996 |
documentation |
|
7997 |
" |
|
7998 |
Interface to a WIN32 registry. |
|
7999 |
||
8000 |
[author:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8001 |
Claus Gittinger (initial version & cleanup) |
5133 | 8002 |
" |
8003 |
||
8004 |
||
8005 |
! |
|
8006 |
||
8007 |
examples |
|
8008 |
" |
|
8009 |
create a key (if not already present): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8010 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8011 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8012 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8013 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8014 |
[exEnd] |
5133 | 8015 |
|
8016 |
||
8017 |
ask a keys value: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8018 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8019 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8020 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8021 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8022 |
Transcript show:'Windows serial NR:'; showCR:(k valueNamed:'ProductId'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8023 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8024 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8025 |
Transcript showCR:(k valueNamed:'CurrentVersion'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8026 |
[exEnd] |
5133 | 8027 |
|
8028 |
||
8029 |
create a sub-key (if not already present): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8030 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8031 |
|k subKey| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8032 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8033 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8034 |
subKey := k createSubKeyNamed:'RegistryDemo' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8035 |
[exEnd] |
5133 | 8036 |
|
8037 |
||
8038 |
change a keys value: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8039 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8040 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8041 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8042 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8043 |
k valueNamed:'FooBarBaz' put:'a foo bar baz string'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8044 |
[exEnd] |
5133 | 8045 |
|
8046 |
delete a value: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8047 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8048 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8049 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8050 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\RegistryDemo'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8051 |
k deleteValueNamed:'FooBarBaz'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8052 |
[exEnd] |
5133 | 8053 |
|
8054 |
delete a key: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8055 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8056 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8057 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8058 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8059 |
k deleteSubKeyNamed:'RegistryDemo'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8060 |
[exEnd] |
5133 | 8061 |
|
8062 |
enumerate keys: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8063 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8064 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8065 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8066 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8067 |
k subKeysDo:[:subKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8068 |
Transcript showCR:subKey path |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8069 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8070 |
[exEnd] |
5133 | 8071 |
|
8072 |
enumerate all keys (recursive): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8073 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8074 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8075 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8076 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8077 |
k allSubKeysDo:[:subKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8078 |
Transcript showCR:subKey path |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8079 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8080 |
[exEnd] |
5133 | 8081 |
|
8082 |
fetch value by index: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8083 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8084 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8085 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8086 |
k := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8087 |
Transcript showCR:(k valueNameAtIndex:0) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8088 |
[exEnd] |
5133 | 8089 |
|
8090 |
||
8091 |
enumerate value names: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8092 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8093 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8094 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8095 |
k := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8096 |
k valueNamesDo:[:nm | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8097 |
Transcript showCR:nm. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8098 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8099 |
[exEnd] |
5133 | 8100 |
|
8101 |
enumerate values: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8102 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8103 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8104 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8105 |
k := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8106 |
k valueNamesAndValuesDo:[:nm :val | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8107 |
Transcript showCR:(nm , ' -> ' , val storeString). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8108 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8109 |
[exEnd] |
5133 | 8110 |
|
8111 |
search for a value (where does NT store the domain ?): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8112 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8113 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8114 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8115 |
k := self key:'HKEY_LOCAL_MACHINE\System'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8116 |
k subKeysDo:[:subKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8117 |
subKey subKeysDo:[:subSubKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8118 |
|tcp params| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8119 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8120 |
(subSubKey path asLowercase endsWith:'services') ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8121 |
tcp := subSubKey subKeyNamed:'tcpip'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8122 |
tcp notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8123 |
params := tcp subKeyNamed:'parameters'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8124 |
params notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8125 |
Transcript showCR:'Domain is found in ' , params path , |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8126 |
' value: ' , (params valueNamed:'Domain'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8127 |
params close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8128 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8129 |
tcp close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8130 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8131 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8132 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8133 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8134 |
[exEnd] |
5133 | 8135 |
|
8136 |
||
8137 |
" |
|
8138 |
! ! |
|
8139 |
||
8140 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'initialization'! |
|
8141 |
||
8142 |
initialize |
|
8143 |
Lobby := Registry new. |
|
8144 |
||
8145 |
HKEY_CLASSES_ROOT := %{ __MKEXTERNALADDRESS(HKEY_CLASSES_ROOT) %}. |
|
8146 |
HKEY_CURRENT_USER := %{ __MKEXTERNALADDRESS(HKEY_CURRENT_USER) %}. |
|
8147 |
HKEY_LOCAL_MACHINE := %{ __MKEXTERNALADDRESS(HKEY_LOCAL_MACHINE) %}. |
|
8148 |
HKEY_USERS := %{ __MKEXTERNALADDRESS(HKEY_USERS) %}. |
|
8149 |
HKEY_PERFORMANCE_DATA := %{ __MKEXTERNALADDRESS(HKEY_PERFORMANCE_DATA) %}. |
|
8150 |
HKEY_CURRENT_CONFIG := %{ __MKEXTERNALADDRESS(HKEY_CURRENT_CONFIG) %}. |
|
8151 |
HKEY_DYN_DATA := %{ __MKEXTERNALADDRESS(HKEY_DYN_DATA) %}. |
|
8152 |
||
8153 |
"Created: / 19.5.1999 / 21:39:57 / cg" |
|
8154 |
"Modified: / 19.5.1999 / 22:45:31 / cg" |
|
8155 |
! |
|
8156 |
||
8157 |
rootKeyValueFor:specialKeyStringOrSymbol |
|
5142 | 8158 |
HKEY_CLASSES_ROOT isNil ifTrue:[self initialize]. |
8159 |
||
5133 | 8160 |
specialKeyStringOrSymbol = 'HKEY_CLASSES_ROOT' ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8161 |
^ HKEY_CLASSES_ROOT. |
5133 | 8162 |
]. |
8163 |
specialKeyStringOrSymbol = 'HKEY_CURRENT_USER' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8164 |
^ HKEY_CURRENT_USER. |
5133 | 8165 |
]. |
8166 |
specialKeyStringOrSymbol = 'HKEY_LOCAL_MACHINE' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8167 |
^ HKEY_LOCAL_MACHINE. |
5133 | 8168 |
]. |
8169 |
specialKeyStringOrSymbol = 'HKEY_USERS' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8170 |
^ HKEY_USERS. |
5133 | 8171 |
]. |
8172 |
specialKeyStringOrSymbol = 'HKEY_PERFORMANCE_DATA' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8173 |
^ HKEY_PERFORMANCE_DATA. |
5133 | 8174 |
]. |
8175 |
specialKeyStringOrSymbol = 'HKEY_CURRENT_CONFIG' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8176 |
^ HKEY_CURRENT_CONFIG. |
5133 | 8177 |
]. |
8178 |
specialKeyStringOrSymbol = 'HKEY_DYN_DATA' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8179 |
^ HKEY_DYN_DATA. |
5133 | 8180 |
]. |
8181 |
||
8182 |
^ nil |
|
8183 |
||
8184 |
"Created: / 19.5.1999 / 21:40:30 / cg" |
|
5142 | 8185 |
"Modified: / 24.12.1999 / 00:02:06 / cg" |
5133 | 8186 |
! ! |
8187 |
||
8188 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'instance creation'! |
|
8189 |
||
8190 |
key:aKeyNamePath |
|
8191 |
"retrieve an entry by full path name (starting at a root)" |
|
8192 |
||
8193 |
|idx first rest root| |
|
8194 |
||
5142 | 8195 |
HKEY_CLASSES_ROOT isNil ifTrue:[self initialize]. |
8196 |
||
5133 | 8197 |
idx := aKeyNamePath indexOf:(self separator). |
8198 |
idx == 0 ifTrue:[ |
|
7840 | 8199 |
first := aKeyNamePath. |
8200 |
rest := nil. |
|
5133 | 8201 |
] ifFalse:[ |
7840 | 8202 |
first := aKeyNamePath copyTo:idx-1. |
8203 |
rest := aKeyNamePath copyFrom:idx+1 |
|
5133 | 8204 |
]. |
8205 |
||
8206 |
first := first asUppercase. |
|
8207 |
||
8208 |
"/ the first is a pseudo name |
|
8209 |
root := self rootKey:first. |
|
8210 |
root isNil ifTrue:[ |
|
7840 | 8211 |
^ nil |
5133 | 8212 |
]. |
8213 |
||
8214 |
rest size == 0 ifTrue:[ |
|
7840 | 8215 |
^ root |
5133 | 8216 |
]. |
8217 |
||
8218 |
^ root subKeyNamed:rest. |
|
8219 |
||
8220 |
" |
|
8221 |
self key:'HKEY_LOCAL_MACHINE' |
|
8222 |
self key:'HKEY_LOCAL_MACHINE\Software' |
|
8223 |
self key:'HKEY_LOCAL_MACHINE\Software\Borland\' |
|
8224 |
self key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\3.2.5\Directory' |
|
8225 |
" |
|
5142 | 8226 |
|
8227 |
"Modified: / 24.12.1999 / 00:01:52 / cg" |
|
5133 | 8228 |
! |
8229 |
||
8230 |
rootKey:aRootKeyStringOrSymbol |
|
8231 |
"retrieve one of the root entries by name" |
|
8232 |
||
8233 |
|keyVal| |
|
8234 |
||
8235 |
keyVal := self rootKeyValueFor:aRootKeyStringOrSymbol. |
|
8236 |
keyVal isNil ifTrue:[^ nil]. |
|
8237 |
"/ rootKeys are not registered for RegClose ... |
|
8238 |
^ self basicNew setHandle:keyVal path:aRootKeyStringOrSymbol. |
|
8239 |
||
8240 |
" |
|
8241 |
RegistryEntry rootKey:#'HKEY_LOCAL_MACHINE' |
|
8242 |
" |
|
8243 |
! ! |
|
8244 |
||
8245 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'registry access'! |
|
8246 |
||
8247 |
stringValueFor:valueName atKey:keyPath |
|
8248 |
"convenient accessing method; |
|
8249 |
Looks for a string value under keyPath; |
|
8250 |
returns nil if either not found, or no string value" |
|
8251 |
||
8252 |
|k v| |
|
8253 |
||
8254 |
k := self key:keyPath. |
|
8255 |
k isNil ifTrue:[^ nil]. |
|
8256 |
v := k valueNamed:valueName. |
|
8257 |
k close. |
|
8258 |
v isString ifFalse:[^ nil]. |
|
8259 |
^ v |
|
8260 |
||
8261 |
" |
|
8262 |
self |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8263 |
stringValueFor:'Content Type' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8264 |
atKey:'HKEY_CLASSES_ROOT\.au' |
5133 | 8265 |
" |
8266 |
! ! |
|
8267 |
||
8268 |
!Win32OperatingSystem::RegistryEntry methodsFor:'accessing'! |
|
8269 |
||
8270 |
name |
|
8271 |
"return the keys name component (subKey name within my |
|
8272 |
parent key)" |
|
8273 |
||
8274 |
|idx| |
|
8275 |
||
8276 |
idx := path lastIndexOf:(self class separator). |
|
8277 |
idx == 0 ifTrue:[^ path]. |
|
8278 |
^ path copyFrom:idx+1 |
|
8279 |
! |
|
8280 |
||
8281 |
path |
|
8282 |
"return the keys full key path name" |
|
8283 |
||
8284 |
^ path. |
|
8285 |
! ! |
|
8286 |
||
8287 |
!Win32OperatingSystem::RegistryEntry methodsFor:'accessing subkeys'! |
|
8288 |
||
8289 |
createSubKeyNamed:subKeyString |
|
8290 |
"create a new key below mySelf and return a new registry entry for it. |
|
8291 |
If it already exists, return it. |
|
8292 |
Return nil if the new key cannot be created." |
|
8293 |
||
8294 |
|newEntry subHandle| |
|
8295 |
||
8296 |
%{ |
|
8297 |
HKEY myKey, subKey = 0; |
|
8298 |
||
7662 | 8299 |
if (__isExternalAddressLike(__INST(handle)) |
5133 | 8300 |
&& (__isString(subKeyString) || __isSymbol(subKeyString))) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8301 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8302 |
if (RegCreateKey(myKey, __stringVal(subKeyString), &subKey) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8303 |
subHandle = __MKEXTERNALADDRESS(subKey); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8304 |
} |
5133 | 8305 |
} |
8306 |
%}. |
|
8307 |
subHandle notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8308 |
newEntry := self class basicNew |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8309 |
setHandle:subHandle |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8310 |
path:(path , self class separator asString , subKeyString). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8311 |
Lobby register:newEntry. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8312 |
^ newEntry. |
5133 | 8313 |
]. |
8314 |
^ nil |
|
8315 |
||
8316 |
" |
|
8317 |
|top sub| |
|
8318 |
||
8319 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8320 |
sub := top createSubKeyNamed:'FooBarBaz'. |
|
8321 |
" |
|
8322 |
! |
|
8323 |
||
8324 |
deleteSubKeyNamed:subKeyString |
|
8325 |
"delete a key below mySelf. |
|
8326 |
Return true on success." |
|
8327 |
||
8328 |
%{ |
|
8329 |
HKEY myKey; |
|
8330 |
||
7662 | 8331 |
if (__isExternalAddressLike(__INST(handle)) |
5133 | 8332 |
&& (__isString(subKeyString) || __isSymbol(subKeyString))) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8333 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8334 |
if (RegDeleteKey(myKey, __stringVal(subKeyString)) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8335 |
RETURN (true); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8336 |
} |
5133 | 8337 |
} |
8338 |
%}. |
|
8339 |
^ false |
|
8340 |
||
8341 |
" |
|
8342 |
|top sub| |
|
8343 |
||
8344 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8345 |
sub := top createSubKeyNamed:'FooBarBaz'. |
|
8346 |
top deleteSubKeyNamed:'FooBarBaz'. |
|
8347 |
" |
|
8348 |
! |
|
8349 |
||
8350 |
remoteKeyOnHost:hostName |
|
8351 |
"return the corresponding registry entry from |
|
8352 |
a remote computers registry." |
|
8353 |
||
8354 |
|newEntry remoteHandle| |
|
8355 |
||
8356 |
%{ |
|
8357 |
HKEY myKey, remoteKey = 0; |
|
8358 |
||
7662 | 8359 |
if (__isExternalAddressLike(__INST(handle)) && __isString(hostName)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8360 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8361 |
if (RegConnectRegistry(__stringVal(hostName), myKey, &remoteKey) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8362 |
remoteHandle = __MKEXTERNALADDRESS(remoteKey); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8363 |
} |
5133 | 8364 |
} |
8365 |
%}. |
|
8366 |
remoteHandle notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8367 |
newEntry := self class basicNew setHandle:remoteHandle path:path. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8368 |
Lobby register:newEntry. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8369 |
^ newEntry. |
5133 | 8370 |
]. |
8371 |
^ nil |
|
8372 |
||
8373 |
" |
|
8374 |
|top remote| |
|
8375 |
||
8376 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8377 |
remote := top remoteKeyOnHost:'BETTI' |
|
8378 |
" |
|
8379 |
" |
|
8380 |
|top remote| |
|
8381 |
||
8382 |
top := self key:'HKEY_USERS'. |
|
8383 |
remote := top remoteKeyOnHost:'BETTI' |
|
8384 |
" |
|
8385 |
" |
|
8386 |
|top remote| |
|
8387 |
||
8388 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8389 |
remote := top remoteKeyOnHost:'JOSHUA' |
|
8390 |
" |
|
8391 |
" |
|
8392 |
|top remote| |
|
8393 |
||
8394 |
top := self key:'HKEY_USERS'. |
|
8395 |
remote := top remoteKeyOnHost:'JOSHUA' |
|
8396 |
" |
|
8397 |
||
8398 |
! |
|
8399 |
||
8400 |
subKeyAtIndex:subKeyIndex |
|
8401 |
"return a new registry entry below mySelf for the given subKey index. |
|
8402 |
Return nil if no such key exists" |
|
8403 |
||
8404 |
|subKeyName subKeyClassName| |
|
8405 |
||
8406 |
%{ |
|
8407 |
HKEY myKey, subKey = 0; |
|
8408 |
char nameBuffer[256]; |
|
8409 |
DWORD nameSize = sizeof(nameBuffer) - 1; |
|
8410 |
char classNameBuffer[256]; |
|
8411 |
DWORD classNameSize = sizeof(classNameBuffer) - 1; |
|
8412 |
FILETIME modificationTime; |
|
8413 |
||
7662 | 8414 |
if (__isExternalAddressLike(__INST(handle)) |
5133 | 8415 |
&& __isSmallInteger(subKeyIndex)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8416 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8417 |
if (RegEnumKeyEx(myKey, __intVal(subKeyIndex), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8418 |
nameBuffer, &nameSize, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8419 |
NULL, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8420 |
classNameBuffer, &classNameSize, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8421 |
&modificationTime) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8422 |
nameBuffer[nameSize] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8423 |
classNameBuffer[classNameSize] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8424 |
subKeyName = __MKSTRING(nameBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8425 |
subKeyClassName = __MKSTRING(classNameBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8426 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8427 |
} |
5133 | 8428 |
} |
8429 |
%}. |
|
8430 |
subKeyName isNil ifTrue:[^ nil]. |
|
8431 |
^ self subKeyNamed:subKeyName. |
|
8432 |
||
8433 |
" |
|
8434 |
|top sub| |
|
8435 |
||
8436 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8437 |
sub := top subKeyAtIndex:0 |
|
8438 |
" |
|
8439 |
! |
|
8440 |
||
8441 |
subKeyNamed:subKeyString |
|
8442 |
"return a new registry entry below mySelf with the given subKey. |
|
8443 |
Return nil if no such key exists" |
|
8444 |
||
8445 |
|newEntry subHandle| |
|
8446 |
||
8447 |
%{ |
|
8448 |
HKEY myKey, subKey = 0; |
|
8449 |
||
7662 | 8450 |
if (__isExternalAddressLike(__INST(handle)) |
5133 | 8451 |
&& (__isString(subKeyString) || __isSymbol(subKeyString))) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8452 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8453 |
if (RegOpenKey(myKey, __stringVal(subKeyString), &subKey) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8454 |
subHandle = __MKEXTERNALADDRESS(subKey); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8455 |
} |
5133 | 8456 |
} |
8457 |
%}. |
|
8458 |
subHandle notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8459 |
newEntry := self class basicNew |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8460 |
setHandle:subHandle |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8461 |
path:(path , self class separator asString , subKeyString). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8462 |
Lobby register:newEntry. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8463 |
^ newEntry. |
5133 | 8464 |
]. |
8465 |
^ nil |
|
8466 |
||
8467 |
" |
|
8468 |
|top sub| |
|
8469 |
||
8470 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8471 |
sub := top subKeyNamed:'Software' |
|
8472 |
" |
|
8473 |
! ! |
|
8474 |
||
8475 |
!Win32OperatingSystem::RegistryEntry methodsFor:'accessing values'! |
|
8476 |
||
8477 |
deleteValueNamed:aValueName |
|
8478 |
"delete a value. |
|
8479 |
Return true on success." |
|
8480 |
||
8481 |
%{ |
|
8482 |
HKEY myKey; |
|
8483 |
||
7662 | 8484 |
if (__isExternalAddressLike(__INST(handle)) |
5133 | 8485 |
&& (__isString(aValueName) || __isSymbol(aValueName))) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8486 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8487 |
if (RegDeleteValue(myKey, __stringVal(aValueName)) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8488 |
RETURN (true); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8489 |
} |
5133 | 8490 |
} |
8491 |
%}. |
|
8492 |
^ false |
|
8493 |
! |
|
8494 |
||
8495 |
valueNameAtIndex:valueIndex |
|
8496 |
"return a values name for the given value index. |
|
8497 |
Return nil if no such value exists" |
|
8498 |
||
8499 |
|valueName| |
|
8500 |
||
8501 |
%{ |
|
8502 |
HKEY myKey; |
|
8503 |
char nameBuffer[256]; |
|
8504 |
DWORD nameSize = sizeof(nameBuffer) - 1; |
|
8505 |
DWORD valueType; |
|
8506 |
||
7662 | 8507 |
if (__isExternalAddressLike(__INST(handle)) |
5133 | 8508 |
&& __isSmallInteger(valueIndex)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8509 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8510 |
if (RegEnumValue(myKey, __intVal(valueIndex), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8511 |
nameBuffer, &nameSize, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8512 |
NULL, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8513 |
&valueType, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8514 |
NULL, NULL) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8515 |
nameBuffer[nameSize] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8516 |
valueName = __MKSTRING(nameBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8517 |
} |
5133 | 8518 |
} |
8519 |
%}. |
|
8520 |
^ valueName |
|
8521 |
||
8522 |
" |
|
8523 |
|top sub| |
|
8524 |
||
8525 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8526 |
sub := top subKeyAtIndex:0 |
|
8527 |
" |
|
8528 |
! |
|
8529 |
||
8530 |
valueNamed:aValueName |
|
8531 |
"retrieve a value; the returned object depends upon the type: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8532 |
REG_BINARY -> ByteArray |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8533 |
REG_SZ -> String |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8534 |
REG_MULTI_SZ -> Array of strings |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8535 |
REG_DWORD -> Integer |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8536 |
REG_NONE -> nil |
5133 | 8537 |
" |
8538 |
||
8539 |
|data stringArray| |
|
8540 |
%{ |
|
8541 |
HKEY myKey; |
|
8542 |
DWORD valueType; |
|
8543 |
union { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8544 |
DWORD dWord; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8545 |
unsigned char dWordBytes[4]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8546 |
unsigned char smallDataBuffer[256]; |
5133 | 8547 |
} quickData; |
8548 |
int val; |
|
8549 |
DWORD dataSize = sizeof(quickData); |
|
8550 |
unsigned char *dataBuffer = NULL; |
|
8551 |
||
7662 | 8552 |
if (__isExternalAddressLike(__INST(handle)) |
5133 | 8553 |
&& (__isString(aValueName) || __isSymbol(aValueName))) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8554 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8555 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8556 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8557 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8558 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8559 |
* try to get it with one call ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8560 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8561 |
ret = RegQueryValueEx(myKey, __stringVal(aValueName), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8562 |
NULL, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8563 |
&valueType, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8564 |
&quickData, &dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8565 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8566 |
if (ret == ERROR_MORE_DATA) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8567 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8568 |
* nope - need another one ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8569 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8570 |
switch (valueType) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8571 |
case REG_BINARY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8572 |
case REG_MULTI_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8573 |
data = __BYTEARRAY_UNINITIALIZED_NEW_INT(dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8574 |
dataBuffer = __ByteArrayInstPtr(data)->ba_element; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8575 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8576 |
case REG_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8577 |
data = __MKEMPTYSTRING(dataSize-1); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8578 |
dataBuffer = __stringVal(data); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8579 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8580 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8581 |
if (dataBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8582 |
ret = RegQueryValueEx(myKey, __stringVal(aValueName), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8583 |
NULL, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8584 |
&valueType, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8585 |
dataBuffer, &dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8586 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8587 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8588 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8589 |
if (ret == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8590 |
switch (valueType) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8591 |
case REG_NONE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8592 |
/* RETURN (@symbol(none)); */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8593 |
RETURN (nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8594 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8595 |
case REG_BINARY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8596 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8597 |
* did we get it with the first call ? |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8598 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8599 |
if (! dataBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8600 |
data = __MKBYTEARRAY(quickData.smallDataBuffer, dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8601 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8602 |
RETURN (data); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8603 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8604 |
case REG_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8605 |
case REG_EXPAND_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8606 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8607 |
* did we get it with the first call ? |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8608 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8609 |
if (! dataBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8610 |
data = __MKSTRING_L(quickData.smallDataBuffer, dataSize-1); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8611 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8612 |
RETURN (data); |
5133 | 8613 |
|
8614 |
#if 0 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8615 |
case REG_DWORD: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8616 |
/* int in native format */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8617 |
RETURN (__MKUINT(quickData.dWord)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8618 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8619 |
case REG_DWORD_LITTLE_ENDIAN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8620 |
val = quickData.dWordBytes[3]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8621 |
val = (val << 8) | quickData.dWordBytes[2]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8622 |
val = (val << 8) | quickData.dWordBytes[1]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8623 |
val = (val << 8) | quickData.dWordBytes[0]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8624 |
RETURN (__MKUINT(val)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8625 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8626 |
case REG_DWORD_BIG_ENDIAN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8627 |
val = quickData.dWordBytes[0]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8628 |
val = (val << 8) | quickData.dWordBytes[1]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8629 |
val = (val << 8) | quickData.dWordBytes[2]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8630 |
val = (val << 8) | quickData.dWordBytes[3]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8631 |
RETURN (__MKUINT(val)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8632 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8633 |
case REG_MULTI_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8634 |
{ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8635 |
char *cp, *cp0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8636 |
int ns = 0, i; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8637 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8638 |
cp0 = dataBuffer ? dataBuffer : quickData.smallDataBuffer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8639 |
cp = cp0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8640 |
while (*cp) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8641 |
while (*cp++) ;; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8642 |
ns++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8643 |
cp++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8644 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8645 |
stringArray = __ARRAY_NEW_INT(ns); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8646 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8647 |
i = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8648 |
while (*cp0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8649 |
OBJ s; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8650 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8651 |
cp = cp0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8652 |
while (*cp++) ;; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8653 |
s = __MKSTRING(cp0); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8654 |
__ArrayInstPtr(stringArray)->a_element[i] = s; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8655 |
__STORE(stringArray, s); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8656 |
cp++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8657 |
cp0 = cp; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8658 |
i++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8659 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8660 |
RETURN (stringArray); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8661 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8662 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8663 |
} |
5133 | 8664 |
} |
8665 |
%}. |
|
8666 |
^ nil |
|
8667 |
||
8668 |
" |
|
8669 |
|key| |
|
8670 |
||
8671 |
key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'. |
|
8672 |
key valueNamed:'CurrentVersion' |
|
8673 |
" |
|
8674 |
! |
|
8675 |
||
8676 |
valueNamed:aValueName put:datum |
|
8677 |
"store a value; the value type depends upon the stored value: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8678 |
ByteArray -> REG_BINARY |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8679 |
String -> REG_SZ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8680 |
Array of string -> REG_MULTI_SZ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8681 |
Integer -> REG_DWORD |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8682 |
nil -> REG_NONE |
5133 | 8683 |
" |
8684 |
||
8685 |
|data stringArray| |
|
8686 |
%{ |
|
8687 |
HKEY myKey; |
|
8688 |
DWORD valueType = -1; |
|
8689 |
int val; |
|
8690 |
DWORD dataSize = -1; |
|
8691 |
unsigned char *dataPointer = NULL; |
|
8692 |
int datumOk = 1, mustFreeData = 0; |
|
8693 |
||
7662 | 8694 |
if (__isExternalAddressLike(__INST(handle)) |
5133 | 8695 |
&& (__isString(aValueName) || __isSymbol(aValueName))) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8696 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8697 |
OBJ cls; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8698 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8699 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8700 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8701 |
if (datum == nil) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8702 |
valueType = REG_NONE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8703 |
dataSize = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8704 |
} else if (__isSmallInteger(datum)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8705 |
valueType = REG_DWORD; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8706 |
val = __intVal(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8707 |
dataPointer = (unsigned char *)(&val); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8708 |
dataSize = sizeof(val); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8709 |
} else if (__isString(datum) || __isSymbol(datum)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8710 |
valueType = REG_SZ; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8711 |
dataPointer = __stringVal(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8712 |
dataSize = __stringSize(datum) + 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8713 |
} else if (__Class(datum) == ByteArray) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8714 |
valueType = REG_BINARY; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8715 |
dataPointer = __ByteArrayInstPtr(datum)->ba_element; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8716 |
dataSize = __byteArraySize(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8717 |
} else if (__Class(datum) == LargeInteger) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8718 |
valueType = REG_DWORD; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8719 |
val = __longIntVal(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8720 |
if (val) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8721 |
dataPointer = (unsigned char *)(&val); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8722 |
dataSize = sizeof(val); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8723 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8724 |
datumOk = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8725 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8726 |
} else if (__Class(datum) == Array) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8727 |
int i = 0, ns = 0, totalSize = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8728 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8729 |
valueType = REG_MULTI_SZ; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8730 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8731 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8732 |
* must allocate a local buffer |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8733 |
* find size ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8734 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8735 |
for (i=0; i<__arraySize(datum); i++) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8736 |
OBJ s = __ArrayInstPtr(datum)->a_element[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8737 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8738 |
if (__isString(datum) || __isSymbol(datum)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8739 |
totalSize += __stringSize(datum) + 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8740 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8741 |
datumOk = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8742 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8743 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8744 |
ns++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8745 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8746 |
if (datumOk) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8747 |
char *cp; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8748 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8749 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8750 |
* allocate and fill... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8751 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8752 |
totalSize ++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8753 |
dataPointer = (char *)(malloc(totalSize)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8754 |
mustFreeData = 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8755 |
cp = dataPointer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8756 |
for (i=0; i<__arraySize(datum); i++) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8757 |
OBJ s = __ArrayInstPtr(datum)->a_element[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8758 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8759 |
strcpy(cp, __stringVal(s)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8760 |
cp += __stringSize(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8761 |
*cp++ = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8762 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8763 |
*cp++ = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8764 |
dataSize = totalSize; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8765 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8766 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8767 |
datumOk = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8768 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8769 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8770 |
if (datumOk) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8771 |
ret = RegSetValueEx(myKey, __stringVal(aValueName), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8772 |
0, valueType, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8773 |
dataPointer, dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8774 |
if (mustFreeData) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8775 |
free(dataPointer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8776 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8777 |
RETURN ((ret == ERROR_SUCCESS) ? true : false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8778 |
} |
5133 | 8779 |
} |
8780 |
%}. |
|
8781 |
^ false |
|
8782 |
||
8783 |
" |
|
8784 |
|key| |
|
8785 |
||
8786 |
key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'. |
|
8787 |
key valueNamed:'CurrentVersion' put:'3.5.2' |
|
8788 |
" |
|
8789 |
! ! |
|
8790 |
||
8791 |
!Win32OperatingSystem::RegistryEntry methodsFor:'enumeration'! |
|
8792 |
||
8793 |
allSubKeysDo:aBlock |
|
8794 |
"recursively evaluate aBlock for all subKeys below the receiver" |
|
8795 |
||
8796 |
|idx subEntry| |
|
8797 |
||
8798 |
idx := 0. |
|
8799 |
[true] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8800 |
subEntry := self subKeyAtIndex:idx. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8801 |
subEntry isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8802 |
^self |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8803 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8804 |
aBlock value:subEntry. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8805 |
subEntry allSubKeysDo:aBlock. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8806 |
subEntry close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8807 |
idx := idx + 1. |
5133 | 8808 |
] |
8809 |
||
8810 |
" |
|
8811 |
|top sub| |
|
8812 |
||
8813 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8814 |
top allSubKeysDo:[:subEntry | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8815 |
Transcript showCR:subEntry path |
5133 | 8816 |
] |
8817 |
" |
|
8818 |
! |
|
8819 |
||
5135 | 8820 |
subKeys |
8821 |
"return a collection of subKeys below the receiver" |
|
8822 |
||
8823 |
|idx subEntry subKeys| |
|
8824 |
||
8825 |
subKeys := OrderedCollection new. |
|
8826 |
self subKeysDo:[:k | subKeys add:k]. |
|
8827 |
^ subKeys |
|
8828 |
||
8829 |
" |
|
8830 |
|top sub| |
|
8831 |
||
8832 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8833 |
top subKeys |
|
8834 |
" |
|
8835 |
||
8836 |
"Created: / 23.12.1999 / 22:15:22 / cg" |
|
8837 |
"Modified: / 23.12.1999 / 22:15:44 / cg" |
|
8838 |
! |
|
8839 |
||
5133 | 8840 |
subKeysDo:aBlock |
8841 |
"evaluate aBlock for all subKeys below the receiver" |
|
8842 |
||
8843 |
|idx subEntry| |
|
8844 |
||
8845 |
idx := 0. |
|
8846 |
[true] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8847 |
subEntry := self subKeyAtIndex:idx. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8848 |
subEntry isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8849 |
^self |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8850 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8851 |
aBlock value:subEntry. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8852 |
subEntry close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8853 |
idx := idx + 1. |
5133 | 8854 |
] |
8855 |
||
8856 |
" |
|
8857 |
|top sub| |
|
8858 |
||
8859 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8860 |
top subKeysDo:[:subEntry | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8861 |
Transcript showCR:subEntry path |
5133 | 8862 |
] |
8863 |
" |
|
8864 |
! |
|
8865 |
||
8866 |
valueNamesAndValuesDo:aBlock |
|
8867 |
"evaluate aBlock for all value names" |
|
8868 |
||
8869 |
self valueNamesDo:[:nm | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8870 |
aBlock value:nm value:(self valueNamed:nm) |
5133 | 8871 |
] |
8872 |
||
8873 |
" |
|
8874 |
|key| |
|
8875 |
||
8876 |
key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'. |
|
8877 |
key valueNamesAndValuesDo:[:nm :val | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8878 |
Transcript showCR:(nm , ' -> ' , val storeString). |
5133 | 8879 |
] |
8880 |
" |
|
8881 |
! |
|
8882 |
||
8883 |
valueNamesDo:aBlock |
|
8884 |
"evaluate aBlock for all value names" |
|
8885 |
||
8886 |
|idx valueName| |
|
8887 |
||
8888 |
idx := 0. |
|
8889 |
[true] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8890 |
valueName := self valueNameAtIndex:idx. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8891 |
valueName isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8892 |
^self |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8893 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8894 |
aBlock value:valueName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8895 |
idx := idx + 1. |
5133 | 8896 |
] |
8897 |
! ! |
|
8898 |
||
8899 |
!Win32OperatingSystem::RegistryEntry methodsFor:'instance release'! |
|
8900 |
||
8901 |
close |
|
8902 |
"close mySelf" |
|
8903 |
||
8904 |
self closeKey. |
|
8905 |
Lobby unregister:self. |
|
8906 |
||
8907 |
"Modified: / 19.5.1999 / 22:44:44 / cg" |
|
8908 |
! |
|
8909 |
||
8910 |
closeKey |
|
8911 |
"close mySelf" |
|
8912 |
||
8913 |
%{ |
|
8914 |
HKEY myKey; |
|
8915 |
||
7662 | 8916 |
if (__isExternalAddressLike(__INST(handle))) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8917 |
myKey = (HKEY)(__externalAddressVal(__INST(handle))); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8918 |
__INST(handle) = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8919 |
RegCloseKey(myKey); |
5133 | 8920 |
} |
8921 |
%} |
|
8922 |
! |
|
8923 |
||
8924 |
disposed |
|
8925 |
"some entry has been collected - close it" |
|
8926 |
||
8927 |
handle notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8928 |
self closeKey. |
5133 | 8929 |
] |
8930 |
||
8931 |
"Created: / 19.5.1999 / 22:39:52 / cg" |
|
8932 |
"Modified: / 19.5.1999 / 22:44:50 / cg" |
|
8933 |
! ! |
|
8934 |
||
8935 |
!Win32OperatingSystem::RegistryEntry methodsFor:'private'! |
|
8936 |
||
8937 |
setHandle:aHandle path:aPathString |
|
8938 |
handle := aHandle. |
|
8939 |
path := aPathString. |
|
8940 |
||
8941 |
"Created: / 19.5.1999 / 22:27:05 / cg" |
|
8942 |
! |
|
8943 |
||
8944 |
setupForHandleValue:integerHandleValue |
|
8945 |
"not normally used - given an integer address, |
|
8946 |
return a registry entry. This is provided to |
|
8947 |
allow for future root keys to be added at the smalltalk level" |
|
8948 |
||
8949 |
%{ |
|
8950 |
HKEY key; |
|
8951 |
OBJ t; |
|
8952 |
||
8953 |
key = __longIntVal(integerHandleValue); |
|
8954 |
if (! key) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8955 |
RETURN (nil); |
5133 | 8956 |
} |
8957 |
||
8958 |
__INST(handle) = t = __MKEXTERNALADDRESS(key); __STORE(self, t); |
|
8959 |
%}. |
|
8960 |
||
8961 |
"Created: / 19.5.1999 / 21:45:05 / cg" |
|
8962 |
! ! |
|
8963 |
||
6293 | 8964 |
!Win32OperatingSystem::Win32FILEHandle class methodsFor:'documentation'! |
8965 |
||
8966 |
documentation |
|
8967 |
" |
|
8968 |
I represent a FILE*, as used in the stdio library. |
|
8969 |
Since most stdio libs are inherently buggy, thread-unsave |
|
8970 |
and hard to use in a multithreading environment, |
|
8971 |
these will no longer be used in future ST/X versions. |
|
8972 |
However, they may be useful when interfacing to external |
|
8973 |
libraries... |
|
8974 |
" |
|
8975 |
! |
|
8976 |
||
8977 |
version |
|
7865 | 8978 |
^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.147 2004-02-02 16:24:45 cg Exp $' |
6293 | 8979 |
! ! |
8980 |
||
8981 |
!Win32OperatingSystem::Win32FILEHandle methodsFor:'release'! |
|
8982 |
||
8983 |
closeFile |
|
8984 |
"close the file" |
|
8985 |
||
8986 |
%{ |
|
8987 |
FILE *f = (FILE *)(__externalAddressVal(self)); |
|
8988 |
||
8989 |
if (f) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8990 |
__externalAddressVal(self) = NULL; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8991 |
fclose(f); |
6293 | 8992 |
} |
8993 |
%}. |
|
8994 |
! ! |
|
8995 |
||
8996 |
!Win32OperatingSystem::Win32Handle class methodsFor:'documentation'! |
|
8997 |
||
8998 |
documentation |
|
8999 |
" |
|
9000 |
I represent a generic HANDLE, which can be closed via CloseHandle. |
|
9001 |
" |
|
9002 |
! |
|
9003 |
||
9004 |
version |
|
7865 | 9005 |
^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.147 2004-02-02 16:24:45 cg Exp $' |
6293 | 9006 |
! ! |
9007 |
||
9008 |
!Win32OperatingSystem::Win32Handle methodsFor:'io'! |
|
9009 |
||
9010 |
readBytes:count into:aByteBuffer startingAt:firstIndex |
|
9011 |
"read count bytes into a byte-buffer; |
|
9012 |
Return the number of bytes read (negative on error)" |
|
9013 |
||
6304 | 9014 |
|errSym errorNumber| |
9015 |
||
6293 | 9016 |
%{ |
9017 |
unsigned char *extPtr; |
|
6336 | 9018 |
int bufferIsExternalBytes; |
9019 |
int mustFreeBuffer = 0; |
|
6293 | 9020 |
int nRead = -1; |
6304 | 9021 |
HANDLE hFile = (HANDLE)(__externalAddressVal(self)); |
9022 |
DWORD cntWanted, offs, cntRead; |
|
9023 |
int bufferSize; |
|
6336 | 9024 |
char miniBuffer[32]; |
9025 |
BOOL ok; |
|
6304 | 9026 |
|
9027 |
if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9028 |
errSym = @symbol(errorNotOpen); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9029 |
goto bad; |
6293 | 9030 |
} |
6304 | 9031 |
if (! __bothSmallInteger(count, firstIndex)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9032 |
errSym = @symbol(badArgument); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9033 |
goto bad; |
6304 | 9034 |
} |
9035 |
cntWanted = __smallIntegerVal(count); |
|
6336 | 9036 |
if (cntWanted <= 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9037 |
errSym = @symbol(badCount); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9038 |
goto bad; |
6293 | 9039 |
} |
6336 | 9040 |
offs = __smallIntegerVal(firstIndex) - 1; |
9041 |
if (offs < 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9042 |
errSym = @symbol(badOffset); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9043 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9044 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9045 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9046 |
bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer); |
6336 | 9047 |
if (! bufferIsExternalBytes) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9048 |
if (__isByteArray(aByteBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9049 |
bufferSize = __byteArraySize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9050 |
} else if (__isString(aByteBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9051 |
bufferSize = __stringSize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9052 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9053 |
errSym = @symbol(badBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9054 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9055 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9056 |
if (bufferSize < (cntWanted + offs)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9057 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9058 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9059 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9060 |
if (cntWanted <= sizeof(miniBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9061 |
extPtr = miniBuffer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9062 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9063 |
extPtr = malloc(cntWanted); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9064 |
mustFreeBuffer = 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9065 |
} |
6336 | 9066 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9067 |
OBJ sz; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9068 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9069 |
extPtr = (char *)(__externalBytesAddress(aByteBuffer)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9070 |
sz = __externalBytesSize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9071 |
if (! __isSmallInteger(sz)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9072 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9073 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9074 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9075 |
bufferSize = __smallIntegerVal(sz); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9076 |
if (bufferSize < (cntWanted + offs)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9077 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9078 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9079 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9080 |
extPtr = extPtr + offs; |
6336 | 9081 |
} |
9082 |
||
6337 | 9083 |
do { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9084 |
__threadErrno = 0; |
7852 | 9085 |
ok = STX_API_CALL5( "ReadFile", ReadFile, hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */); |
6337 | 9086 |
} while(__threadErrno == EINTR); |
9087 |
||
6336 | 9088 |
if (ok == TRUE) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9089 |
if (! bufferIsExternalBytes) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9090 |
/* copy over */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9091 |
memcpy(__byteArrayVal(aByteBuffer)+offs, extPtr, cntRead); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9092 |
if (mustFreeBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9093 |
free(extPtr); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9094 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9095 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9096 |
RETURN (__mkSmallInteger(cntRead)); |
6336 | 9097 |
} |
9098 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
|
9099 |
||
6293 | 9100 |
bad: ; |
6336 | 9101 |
if (mustFreeBuffer) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9102 |
free(extPtr); |
6336 | 9103 |
} |
6293 | 9104 |
%}. |
6304 | 9105 |
|
9106 |
errorNumber isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9107 |
self error:'invalid argument(s): ', errSym. |
6304 | 9108 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9109 |
(OperatingSystem errorHolderForNumber:errorNumber) reportError |
6304 | 9110 |
]. |
6293 | 9111 |
|
9112 |
" |
|
9113 |
|h buff n| |
|
9114 |
||
9115 |
h := self basicNew. |
|
6304 | 9116 |
buff := ByteArray new:10. |
6293 | 9117 |
n := h readBytes:10 into:buff startingAt:1. |
9118 |
Transcript show:n; space; showCR:buff. |
|
9119 |
" |
|
9120 |
! |
|
9121 |
||
6337 | 9122 |
readWaitWithTimeoutMs:millis |
9123 |
"return true if a timeout occurred" |
|
9124 |
||
9125 |
|errSym errorNumber| |
|
9126 |
||
9127 |
%{ |
|
9128 |
HANDLE hFile = (HANDLE)(__externalAddressVal(self)); |
|
9129 |
DWORD res; |
|
9130 |
INT t; |
|
9131 |
||
9132 |
if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9133 |
errSym = @symbol(errorNotOpen); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9134 |
goto bad; |
6337 | 9135 |
} |
9136 |
||
9137 |
#if 0 |
|
9138 |
if (ioctlsocket((SOCKET)hFile, FIONREAD, &res)==0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9139 |
/* its a socket */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9140 |
if (res > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9141 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9142 |
} |
6337 | 9143 |
} |
9144 |
if (PeekNamedPipe(hFile, 0, 0, 0, &res, 0)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9145 |
/* its a namedPipe */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9146 |
if (res > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9147 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9148 |
} |
6337 | 9149 |
} |
9150 |
#endif |
|
9151 |
if (__isSmallInteger(millis)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9152 |
t = __intVal(millis); |
6337 | 9153 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9154 |
t = INFINITE; |
6337 | 9155 |
} |
9156 |
||
9157 |
do { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9158 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9159 |
res = WaitForSingleObject(hFile, t); |
6337 | 9160 |
} while (__threadErrno == EINTR); |
9161 |
||
9162 |
switch (res) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9163 |
case WAIT_OBJECT_0: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9164 |
/* signalled */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9165 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9166 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9167 |
case WAIT_TIMEOUT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9168 |
/* signalled */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9169 |
RETURN ( true ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9170 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9171 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9172 |
case WAIT_ABANDONED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9173 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9174 |
goto bad; |
6337 | 9175 |
} |
9176 |
||
9177 |
bad: ; |
|
9178 |
%}. |
|
9179 |
" |
|
9180 |
timeout argument not integer, |
|
9181 |
or any fd-array nonNil and not an array |
|
9182 |
or not supported by OS |
|
9183 |
" |
|
9184 |
^ self primitiveFailed |
|
9185 |
! |
|
9186 |
||
6336 | 9187 |
seekTo:newPosition from:whence |
9188 |
"whence is one of: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9189 |
#begin |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9190 |
#current |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9191 |
#end |
6336 | 9192 |
" |
9193 |
||
9194 |
|errSym errorNumber| |
|
9195 |
||
9196 |
%{ |
|
9197 |
HANDLE hFile = (HANDLE)(__externalAddressVal(self)); |
|
9198 |
DWORD moveHow; |
|
9199 |
LONG posLo, posHi = 0; |
|
9200 |
__uint64__ pos64, newPos64; |
|
9201 |
||
9202 |
if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9203 |
errSym = @symbol(errorNotOpen); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9204 |
goto bad; |
6336 | 9205 |
} |
9206 |
||
9207 |
if (whence == @symbol(begin)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9208 |
moveHow = FILE_BEGIN; |
6336 | 9209 |
} else if (whence == @symbol(current)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9210 |
moveHow = FILE_CURRENT; |
6336 | 9211 |
} else if (whence == @symbol(end)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9212 |
moveHow = FILE_END; |
6336 | 9213 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9214 |
errSym = @symbol(badArgument2); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9215 |
goto bad; |
6336 | 9216 |
} |
9217 |
||
9218 |
if (__signedLong64IntVal(newPosition, &pos64) == 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9219 |
errSym = @symbol(badArgument); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9220 |
goto bad; |
6336 | 9221 |
} |
9222 |
posLo = pos64.lo; |
|
9223 |
posHi = pos64.hi; |
|
9224 |
||
9225 |
posLo = SetFilePointer(hFile, posLo, &posHi, moveHow); |
|
9226 |
if (posLo == 0xFFFFFFFF) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9227 |
int lastError; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9228 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9229 |
/* can be either an error, or a valid low-word */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9230 |
lastError = GetLastError(); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9231 |
if (lastError != NO_ERROR) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9232 |
errorNumber = __mkSmallInteger( __WIN32_ERR(lastError) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9233 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9234 |
} |
6336 | 9235 |
} |
9236 |
||
9237 |
if (posHi == 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9238 |
RETURN (__MKUINT( posLo )); |
6336 | 9239 |
} |
9240 |
newPos64.lo = posLo; |
|
9241 |
newPos64.hi = posHi; |
|
9242 |
||
9243 |
RETURN ( __MKUINT64(&newPos64) ); |
|
9244 |
||
9245 |
bad: ; |
|
9246 |
%}. |
|
9247 |
||
9248 |
errorNumber isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9249 |
self error:'invalid argument(s): ', errSym. |
6336 | 9250 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9251 |
(OperatingSystem errorHolderForNumber:errorNumber) reportError |
6336 | 9252 |
]. |
9253 |
! |
|
9254 |
||
6293 | 9255 |
writeBytes:count from:aByteBuffer startingAt:firstIndex |
9256 |
"write count bytes from a byte-buffer; |
|
9257 |
Return the number of bytes written (negative on error)" |
|
9258 |
||
6304 | 9259 |
|errSym errorNumber| |
6293 | 9260 |
%{ |
9261 |
unsigned char *extPtr; |
|
6338 | 9262 |
int bufferIsExternalBytes; |
9263 |
int mustFreeBuffer = 0; |
|
6293 | 9264 |
int nWritten = -1; |
6304 | 9265 |
HANDLE hFile = (HANDLE)(__externalAddressVal(self)); |
9266 |
DWORD cntWanted, offs, cntWritten; |
|
9267 |
int bufferSize; |
|
6338 | 9268 |
char miniBuffer[32]; |
9269 |
BOOL ok; |
|
6304 | 9270 |
|
9271 |
if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9272 |
errSym = @symbol(errorNotOpen); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9273 |
goto bad; |
6293 | 9274 |
} |
6304 | 9275 |
if (! __bothSmallInteger(count, firstIndex)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9276 |
errSym = @symbol(badArgument); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9277 |
goto bad; |
6304 | 9278 |
} |
9279 |
cntWanted = __smallIntegerVal(count); |
|
6338 | 9280 |
if (cntWanted <= 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9281 |
errSym = @symbol(badCount); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9282 |
goto bad; |
6293 | 9283 |
} |
6338 | 9284 |
offs = __smallIntegerVal(firstIndex) - 1; |
9285 |
if (offs < 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9286 |
errSym = @symbol(badOffset); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9287 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9288 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9289 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9290 |
bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer); |
6338 | 9291 |
if (! bufferIsExternalBytes) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9292 |
if (__isByteArray(aByteBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9293 |
bufferSize = __byteArraySize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9294 |
} else if (__isString(aByteBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9295 |
bufferSize = __stringSize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9296 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9297 |
errSym = @symbol(badBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9298 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9299 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9300 |
if (bufferSize < (cntWanted + offs)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9301 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9302 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9303 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9304 |
if (cntWanted <= sizeof(miniBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9305 |
extPtr = miniBuffer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9306 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9307 |
extPtr = malloc(cntWanted); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9308 |
mustFreeBuffer = 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9309 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9310 |
memcpy(extPtr, __byteArrayVal(aByteBuffer)+offs, cntWanted); |
6338 | 9311 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9312 |
extPtr = (char *)(__externalBytesAddress(aByteBuffer)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9313 |
bufferSize = __externalBytesSize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9314 |
if (! __isSmallInteger(bufferSize)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9315 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9316 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9317 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9318 |
bufferSize = __smallIntegerVal(bufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9319 |
if (bufferSize < (cntWanted + offs)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9320 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9321 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9322 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9323 |
extPtr = extPtr + offs; |
6338 | 9324 |
} |
9325 |
||
9326 |
do { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9327 |
__threadErrno = 0; |
7852 | 9328 |
ok = STX_API_CALL5( "WriteFile", WriteFile, hFile, extPtr, cntWanted, &cntWritten, 0 /* lpOverlapped */); |
6338 | 9329 |
} while(__threadErrno == EINTR); |
9330 |
||
9331 |
if (ok == TRUE) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9332 |
if (mustFreeBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9333 |
free(extPtr); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9334 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9335 |
RETURN (__mkSmallInteger(cntWritten)); |
6338 | 9336 |
} |
9337 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
|
9338 |
||
6293 | 9339 |
bad: ; |
6338 | 9340 |
if (mustFreeBuffer) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9341 |
free(extPtr); |
6338 | 9342 |
} |
6293 | 9343 |
%}. |
6304 | 9344 |
errorNumber isNil ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9345 |
self error:'invalid argument(s): ', errSym. |
6304 | 9346 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9347 |
(OperatingSystem errorHolderForNumber:errorNumber) reportError |
6304 | 9348 |
]. |
6293 | 9349 |
|
9350 |
" |
|
9351 |
|h buff n| |
|
9352 |
||
9353 |
h := self basicNew. |
|
9354 |
h setFileDescriptor:1. |
|
9355 |
buff := '12345678901234567890'. |
|
9356 |
n := h writeBytes:10 from:buff startingAt:1. |
|
9357 |
" |
|
9358 |
! ! |
|
9359 |
||
6297 | 9360 |
!Win32OperatingSystem::Win32Handle methodsFor:'queries'! |
9361 |
||
9362 |
isValid |
|
9363 |
^ self address ~~0 |
|
9364 |
! ! |
|
9365 |
||
6293 | 9366 |
!Win32OperatingSystem::Win32Handle methodsFor:'release'! |
9367 |
||
9368 |
closeFile |
|
9369 |
"close the handle" |
|
9370 |
||
9371 |
%{ |
|
9372 |
HANDLE h = (HANDLE)(__externalAddressVal(self)); |
|
9373 |
||
9374 |
if (h) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9375 |
__externalAddressVal(self) = (HANDLE)0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9376 |
CloseHandle(h); |
6293 | 9377 |
} |
9378 |
%}. |
|
9379 |
! ! |
|
9380 |
||
5133 | 9381 |
!Win32OperatingSystem class methodsFor:'documentation'! |
9382 |
||
9383 |
version |
|
7865 | 9384 |
^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.147 2004-02-02 16:24:45 cg Exp $' |
5133 | 9385 |
! ! |
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
9386 |
|
5135 | 9387 |
Win32OperatingSystem initialize! |
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
9388 |
Win32OperatingSystem::RegistryEntry initialize! |