author | Claus Gittinger <cg@exept.de> |
Fri, 25 Jul 2003 22:19:01 +0200 | |
changeset 7535 | 9bcb9a436394 |
parent 7534 | 9cc58f3d3469 |
child 7638 | a211d1f10797 |
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 |
||
5133 | 61 |
!Win32OperatingSystem primitiveDefinitions! |
62 |
%{ |
|
63 |
||
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
64 |
# ifndef DO_WRAP_CALLS |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
65 |
# define STX_C_CALL0(__nm__, __f__) __f__((__a1__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
66 |
# define STX_C_CALL1(__nm__, __f__, __a1__) __f__((__a1__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
67 |
# define STX_C_CALL2(__nm__, __f__, __a1__, __a2__) __f__((__a1__), (__a2__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
68 |
# define STX_C_CALL3(__nm__, __f__, __a1__, __a2__, __a3__) __f__((__a1__), (__a2__), (__a3__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
69 |
# define STX_API_CALL0(__nm__, __f__) __f__((__a1__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
70 |
# define STX_API_CALL1(__nm__, __f__, __a1__) __f__((__a1__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
71 |
# define STX_API_CALL2(__nm__, __f__, __a1__, __a2__) __f__((__a1__), (__a2__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
72 |
# define STX_API_CALL3(__nm__, __f__, __a1__, __a2__, __a3__) __f__((__a1__), (__a2__), (__a3__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
73 |
# define STX_API_CALL4(__nm__, __f__, __a1__, __a2__, __a3__, __a4__) __f__((__a1__), (__a2__), (__a3__), (__a4__)) |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
74 |
# else |
6267
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
75 |
# define STX_C_CALL0(__nm__, __f__) __STX_C_CALL0(__nm__, (void*)__f__) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
76 |
# define STX_C_CALL1(__nm__, __f__, __a1__) __STX_C_CALL1(__nm__, (void*)__f__, (void*)(__a1__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
77 |
# define STX_C_CALL2(__nm__, __f__, __a1__, __a2__) __STX_C_CALL2(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
78 |
# define STX_C_CALL3(__nm__, __f__, __a1__, __a2__, __a3__) __STX_C_CALL3(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__), (void*)(__a3__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
79 |
# define STX_API_CALL0(__nm__, __f__) __STX_API_CALL0(__nm__, (void*)__f__) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
80 |
# define STX_API_CALL1(__nm__, __f__, __a1__) __STX_API_CALL1(__nm__, (void*)__f__, (void*)(__a1__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
81 |
# define STX_API_CALL2(__nm__, __f__, __a1__, __a2__) __STX_API_CALL2(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
82 |
# define STX_API_CALL3(__nm__, __f__, __a1__, __a2__, __a3__) __STX_API_CALL3(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__), (void*)(__a3__)) |
10016cc16511
pass name of API/C wrap function
Claus Gittinger <cg@exept.de>
parents:
6259
diff
changeset
|
83 |
# define STX_API_CALL4(__nm__, __f__, __a1__, __a2__, __a3__, __a4__) __STX_API_CALL4(__nm__, (void*)__f__, (void*)(__a1__), (void*)(__a2__), (void*)(__a3__), (void*)(__a4__)) |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
84 |
# endif |
5133 | 85 |
|
86 |
# ifndef MSDOS_LIKE |
|
87 |
# define MSDOS_LIKE |
|
88 |
# endif |
|
89 |
# undef UNIX_LIKE /* oops - we were too optimistic - no OS */ |
|
6095 | 90 |
|
5133 | 91 |
# ifdef i386 |
92 |
# ifndef _X86_ |
|
93 |
# define _X86_ |
|
94 |
# endif |
|
95 |
# endif |
|
96 |
||
97 |
/* |
|
98 |
* notice: although many systems' include files |
|
99 |
* already block against multiple inclusion, some |
|
100 |
* do not. Therefore, this is done here again. |
|
101 |
* (it does not hurt) |
|
102 |
*/ |
|
103 |
||
104 |
# ifndef _SIGNAL_H_INCLUDED_ |
|
105 |
# include <signal.h> |
|
106 |
# define _SIGNAL_H_INCLUDED_ |
|
107 |
# endif |
|
108 |
||
109 |
# ifndef _SYS_TYPES_H_INCLUDED_ |
|
110 |
# include <sys/types.h> |
|
111 |
# define _SYS_TYPES_H_INCLUDED_ |
|
112 |
# endif |
|
113 |
||
114 |
# ifndef _TIME_H_INCLUDED_ |
|
115 |
# include <time.h> |
|
116 |
# define _TIME_H_INCLUDED_ |
|
117 |
# endif |
|
118 |
||
119 |
# ifndef _SYS_TIMEB_H_INCLUDED_ |
|
120 |
# include <sys/timeb.h> |
|
121 |
# define _SYS_TIMEB_H_INCLUDED_ |
|
122 |
# endif |
|
123 |
||
124 |
# ifndef _SYS_STAT_H_INCLUDED_ |
|
125 |
# include <sys/stat.h> |
|
126 |
# define _SYS_STAT_H_INCLUDED_ |
|
127 |
# endif |
|
128 |
||
129 |
# ifndef _ERRNO_H_INCLUDED_ |
|
130 |
# include <errno.h> |
|
131 |
# define _ERRNO_H_INCLUDED_ |
|
132 |
# endif |
|
133 |
||
134 |
# ifndef _STDIO_H_INCLUDED_ |
|
135 |
# include <stdio.h> |
|
136 |
# define _STDIO_H_INCLUDED_ |
|
137 |
# endif |
|
138 |
||
139 |
# ifndef _FCNTL_H_INCLUDED_ |
|
140 |
# include <fcntl.h> |
|
141 |
# define _FCNTL_H_INCLUDED_ |
|
142 |
# endif |
|
143 |
||
144 |
/*# define PROCESSDEBUGWIN32 /* */ |
|
145 |
/*# define PROCESS1DEBUGWIN32 /* */ |
|
146 |
/*# define PROCESS2DEBUGWIN32 /* */ |
|
147 |
/* # define SELECTDEBUGWIN32 /* */ |
|
148 |
/* # define SELECT1DEBUGWIN32 /* */ |
|
149 |
/* # define SELECT2DEBUGWIN32 /* */ |
|
150 |
/* # define WAITDEBUGWIN32 /* */ |
|
151 |
/* # define SIGNALDEBUGWIN32 /* */ |
|
152 |
# undef INT |
|
153 |
# undef Array |
|
154 |
# undef Number |
|
155 |
# undef Method |
|
156 |
# undef Point |
|
157 |
# undef Rectangle |
|
158 |
# undef Block |
|
159 |
# undef String |
|
160 |
# undef Message |
|
161 |
# undef Object |
|
162 |
# undef Context |
|
163 |
# undef Time |
|
164 |
# undef Date |
|
165 |
# undef Set |
|
166 |
# undef Signal |
|
167 |
# undef Delay |
|
168 |
||
6543 | 169 |
# define NO_GETADAPTERSINFO |
170 |
||
5133 | 171 |
# include <stdarg.h> /* */ |
7531 | 172 |
# ifndef WINDOWS_H_INCLUDED |
173 |
# define WINDOWS_H_INCLUDED |
|
174 |
# include <windows.h> |
|
175 |
# endif |
|
6543 | 176 |
# ifndef NO_GETADAPTERSINFO |
177 |
# include <iphlpapi.h> /* req'd for GetAdaptersInfo */ |
|
178 |
# endif |
|
5133 | 179 |
|
180 |
# if !defined(__BORLANDC__) |
|
181 |
# undef stat |
|
182 |
# define stat _stat |
|
183 |
# undef chmod |
|
184 |
# define chmod _chmod |
|
185 |
# undef access |
|
186 |
# define access _access |
|
187 |
# define MAXFILELEN 256 |
|
188 |
# endif |
|
189 |
||
190 |
# ifdef __DEF_Array |
|
191 |
# define Array __DEF_Array |
|
192 |
# endif |
|
193 |
# ifdef __DEF_Number |
|
194 |
# define Number __DEF_Number |
|
195 |
# endif |
|
196 |
# ifdef __DEF_Method |
|
197 |
# define Method __DEF_Method |
|
198 |
# endif |
|
199 |
# ifdef __DEF_Point |
|
200 |
# define Point __DEF_Point |
|
201 |
# endif |
|
202 |
# ifdef __DEF_Block |
|
203 |
# define Block __DEF_Block |
|
204 |
# endif |
|
205 |
# ifdef __DEF_String |
|
206 |
# define String __DEF_String |
|
207 |
# endif |
|
208 |
# ifdef __DEF_Message |
|
209 |
# define Message __DEF_Message |
|
210 |
# endif |
|
211 |
# ifdef __DEF_Object |
|
212 |
# define Object __DEF_Object |
|
213 |
# endif |
|
214 |
# ifdef __DEF_Context |
|
215 |
# define Context __DEF_Context |
|
216 |
# endif |
|
217 |
# ifdef __DEF_Date |
|
218 |
# define Date __DEF_Date |
|
219 |
# endif |
|
220 |
# ifdef __DEF_Time |
|
221 |
# define Time __DEF_Time |
|
222 |
# endif |
|
223 |
# ifdef __DEF_Set |
|
224 |
# define Set __DEF_Set |
|
225 |
# endif |
|
226 |
# ifdef __DEF_Signal |
|
227 |
# define Signal __DEF_Signal |
|
228 |
# endif |
|
229 |
# ifdef __DEF_Delay |
|
230 |
# define Delay __DEF_Delay |
|
231 |
# endif |
|
232 |
||
233 |
# define INT int |
|
234 |
||
235 |
typedef int (*intf)(int); |
|
236 |
BOOL __signalUserInterruptWIN32(DWORD sig); |
|
237 |
||
238 |
# if defined (HAS_LOCALECONV) |
|
239 |
# ifndef _LOCALE_H_INCLUDED_ |
|
240 |
# include <locale.h> |
|
241 |
# define _LOCALE_H_INCLUDED_ |
|
242 |
# endif |
|
243 |
# endif |
|
244 |
||
245 |
/* |
|
246 |
* posix systems should define these ... |
|
247 |
* but on some (older) systems, they are not. |
|
248 |
*/ |
|
249 |
# ifndef S_IXUSR |
|
250 |
# ifdef S_IEXEC |
|
251 |
# define S_IXUSR S_IEXEC |
|
252 |
# define S_IXGRP (S_IEXEC>>3) |
|
253 |
# define S_IXOTH (S_IEXEC>>6) |
|
254 |
# endif |
|
255 |
# endif |
|
256 |
||
257 |
# ifndef S_IXUSR |
|
258 |
# define S_IXUSR 0100 |
|
259 |
# define S_IXGRP 0010 |
|
260 |
# define S_IXOTH 0001 |
|
261 |
# endif |
|
262 |
||
263 |
# ifndef S_IRUSR |
|
264 |
# define S_IRUSR 0400 |
|
265 |
# define S_IRGRP 0040 |
|
266 |
# define S_IROTH 0004 |
|
267 |
# endif |
|
268 |
||
269 |
# ifndef S_IWUSR |
|
270 |
# define S_IWUSR 0200 |
|
271 |
# define S_IWGRP 0020 |
|
272 |
# define S_IWOTH 0002 |
|
273 |
# endif |
|
274 |
||
275 |
# ifdef __BORLANDC__ |
|
276 |
# include <dir.h> |
|
277 |
# define MAXPATHLEN MAXPATH |
|
278 |
# define MAXFILELEN MAXFILE |
|
279 |
# endif |
|
280 |
||
281 |
# ifndef MAXPATHLEN |
|
282 |
# ifndef MSDOS_LIKE |
|
283 |
# ifndef NO_SYS_PARAM_H |
|
284 |
# include <sys/param.h> |
|
285 |
# endif |
|
286 |
# endif |
|
287 |
# ifndef MAXPATHLEN |
|
288 |
# ifdef FILENAME_MAX /* i.e. MSDOS_LIKE */ |
|
289 |
# define MAXPATHLEN FILENAME_MAX |
|
290 |
# else |
|
291 |
# ifdef MAX_PATH |
|
292 |
# define MAXPATHLEN MAX_PATH |
|
293 |
# else |
|
294 |
# define MAXPATHLEN 1024 |
|
295 |
# endif |
|
296 |
# endif |
|
297 |
# endif |
|
298 |
# endif |
|
299 |
||
300 |
/* |
|
301 |
* sigaction dummies (you won't believe these call themself ``POSIX'' systems ...) |
|
302 |
*/ |
|
303 |
# ifndef SA_RESTART |
|
304 |
# define SA_RESTART 0 |
|
305 |
# endif |
|
306 |
# ifndef SA_SIGINFO |
|
307 |
# define SA_SIGINFO 0 |
|
308 |
# endif |
|
309 |
||
310 |
# if defined(HAS_WAITPID) || defined(HAS_WAIT3) |
|
311 |
# include <sys/wait.h> |
|
312 |
# endif |
|
313 |
||
314 |
# if defined(HAS_SYSINFO) |
|
315 |
# include <sys/systeminfo.h> |
|
316 |
# endif |
|
317 |
||
318 |
/* |
|
319 |
* some (old ?) systems do not define this ... |
|
320 |
*/ |
|
321 |
#if !defined(R_OK) && !defined(_AIX) |
|
322 |
# define R_OK 4 /* Test for Read permission */ |
|
323 |
# define W_OK 2 /* Test for Write permission */ |
|
324 |
# define X_OK 1 /* Test for eXecute permission */ |
|
325 |
# define F_OK 0 /* Test for existence of File */ |
|
326 |
#endif |
|
327 |
||
328 |
#define SIGHANDLER_ARG int |
|
329 |
||
330 |
#define _HANDLEVal(o) (HANDLE)(__externalAddressVal(o)) |
|
331 |
||
332 |
/* |
|
333 |
* not all systems have time_t and off_t |
|
334 |
* explicit add of those we know to have ... |
|
335 |
*/ |
|
336 |
||
337 |
#ifndef TIME_T |
|
338 |
# define TIME_T long |
|
339 |
#endif |
|
340 |
#ifndef OFF_T |
|
341 |
# define OFF_T long |
|
342 |
#endif |
|
343 |
||
344 |
/* |
|
345 |
* where is the timezone info ? |
|
346 |
*/ |
|
347 |
#if defined(HAS_NO_TIMEZONE) |
|
348 |
# if defined(HAS_NO_TM_GMTOFF) |
|
349 |
# define TIMEZONE(tmPtr) 0 |
|
350 |
# else |
|
351 |
# define TIMEZONE(tmPtr) ((tmPtr)->tm_gmtoff) |
|
352 |
# endif |
|
353 |
#else |
|
354 |
# ifdef MSDOS_LIKE |
|
355 |
# define TIMEZONE(tmPtr) 0 |
|
356 |
# else |
|
357 |
# define TIMEZONE(tmPtr) timezone |
|
358 |
# endif |
|
359 |
#endif |
|
360 |
||
361 |
%} |
|
362 |
! ! |
|
363 |
||
364 |
!Win32OperatingSystem primitiveFunctions! |
|
365 |
%{ |
|
366 |
||
367 |
static int __isWinNT = 0; |
|
368 |
||
369 |
#define __wait wait |
|
370 |
||
371 |
%} |
|
372 |
! ! |
|
373 |
||
374 |
!Win32OperatingSystem class methodsFor:'documentation'! |
|
375 |
||
376 |
copyright |
|
377 |
" |
|
378 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
379 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
380 |
All Rights Reserved |
5133 | 381 |
|
382 |
This software is furnished under a license and may be used |
|
383 |
only in accordance with the terms of that license and with the |
|
384 |
inclusion of the above copyright notice. This software may not |
|
385 |
be provided or otherwise made available to, or used by, any |
|
386 |
other person. No title to or ownership of the software is |
|
387 |
hereby transferred. |
|
388 |
" |
|
389 |
! |
|
390 |
||
391 |
documentation |
|
392 |
" |
|
393 |
NOTICE: this is being developed; |
|
394 |
this class resulted from extracting WIN32 specifics of the old |
|
395 |
OperatingSystemClass into this sub-class. |
|
396 |
You may find some leftover unix stuff, which will go away sooner |
|
397 |
or later. |
|
398 |
||
399 |
this class realizes access to most (all ?) required operating system services; |
|
400 |
some of it is very specific for unix, so do not depend on |
|
401 |
things available here in your applications |
|
402 |
- some may not be found in other OS's or be slightly different ... |
|
403 |
||
404 |
(On the other hand: I do not want to hide all features |
|
405 |
from you - in some situations it MAY be interesting to be |
|
406 |
able to get down to a select or fork system call easily (at least on Unix systems). |
|
407 |
You decide - portability vs. functionality) |
|
408 |
||
409 |
[Class variables:] |
|
410 |
||
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
411 |
HostName <String> remembered hostname |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
412 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
413 |
DomainName <String> remembered domainname |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
414 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
415 |
CurrentDirectory <String> remembered currentDirectories path |
5133 | 416 |
|
417 |
[author:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
418 |
Claus Gittinger (initial version & cleanup) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
419 |
Manfred Dierolf (many features) |
5133 | 420 |
|
421 |
[see also:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
422 |
OSProcessStatus |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
423 |
Filename Date Time |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
424 |
ExternalStream FileStream PipeStream Socket |
5133 | 425 |
" |
426 |
! |
|
427 |
||
428 |
examples |
|
429 |
" |
|
430 |
various queries |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
431 |
[exBegin] |
5133 | 432 |
Transcript |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
433 |
showCR:'hello ' , (OperatingSystem getLoginName) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
434 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
435 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
436 |
[exBegin] |
5133 | 437 |
OperatingSystem isUNIXlike ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
438 |
Transcript showCR:'this is some UNIX-like OS' |
5133 | 439 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
440 |
Transcript showCR:'this OS is not UNIX-like' |
5133 | 441 |
] |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
442 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
443 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
444 |
[exBegin] |
5133 | 445 |
Transcript |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
446 |
showCR:'this machine is called ' , OperatingSystem getHostName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
447 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
448 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
449 |
[exBegin] |
5133 | 450 |
Transcript |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
451 |
showCR:('this machine is in the ' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
452 |
, OperatingSystem getDomainName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
453 |
, ' domain') |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
454 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
455 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
456 |
[exBegin] |
5133 | 457 |
Transcript |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
458 |
showCR:('this machine''s CPU is a ' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
459 |
, OperatingSystem getCPUType |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
460 |
) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
461 |
[exEnd] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
462 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
463 |
[exBegin] |
5133 | 464 |
Transcript showCR:'executing ls command ...'. |
465 |
OperatingSystem executeCommand:'ls'. |
|
466 |
Transcript showCR:'... done.'. |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
467 |
[exEnd] |
5133 | 468 |
|
469 |
locking a file |
|
470 |
(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
|
471 |
[exBegin] |
5133 | 472 |
|f| |
473 |
||
474 |
f := 'testFile' asFilename readWriteStream. |
|
475 |
||
476 |
10 timesRepeat:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
477 |
'about to lock ...' printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
478 |
[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
479 |
OperatingSystem |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
480 |
lockFD:(f fileDescriptor) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
481 |
shared:false |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
482 |
blocking:false |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
483 |
] whileFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
484 |
'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
485 |
Delay waitForSeconds:1 |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
486 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
487 |
'LOCKED ...' printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
488 |
Delay waitForSeconds:10. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
489 |
'unlock ...' printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
490 |
(OperatingSystem |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
491 |
unlockFD:(f fileDescriptor)) printCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
492 |
Delay waitForSeconds:3. |
5133 | 493 |
] |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
494 |
[exBegin] |
5133 | 495 |
" |
496 |
! ! |
|
497 |
||
498 |
!Win32OperatingSystem class methodsFor:'initialization'! |
|
499 |
||
500 |
initOSType |
|
501 |
"internal - see if running under win-NT |
|
502 |
(as opposed to win-95)" |
|
503 |
||
504 |
%{ /* NOCONTEXT */ |
|
505 |
OSVERSIONINFO osvi; |
|
506 |
||
507 |
memset(&osvi, 0, sizeof(OSVERSIONINFO)); |
|
508 |
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); |
|
509 |
GetVersionEx (&osvi); |
|
510 |
||
511 |
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
512 |
__isWinNT = 1; |
5133 | 513 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
514 |
__isWinNT = 0; |
5133 | 515 |
} |
516 |
%}. |
|
517 |
! |
|
518 |
||
519 |
initialize |
|
520 |
"initialize the class" |
|
521 |
||
522 |
ObjectMemory addDependent:self. |
|
523 |
HostName := nil. |
|
524 |
DomainName := nil. |
|
525 |
LastErrorNumber := nil. |
|
526 |
PipeFailed := false. |
|
527 |
self initOSType |
|
528 |
||
529 |
"Modified: 13.9.1997 / 10:47:32 / cg" |
|
530 |
! |
|
531 |
||
532 |
update:something with:aParameter from:changedObject |
|
533 |
"catch image restart and flush some cached data" |
|
534 |
||
535 |
something == #earlyRestart ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
536 |
" |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
537 |
flush cached data |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
538 |
" |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
539 |
HostName := nil. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
540 |
DomainName := nil. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
541 |
LastErrorNumber := nil. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
542 |
PipeFailed := false. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
543 |
self initOSType |
5133 | 544 |
] |
545 |
||
546 |
"Modified: 22.4.1996 / 13:10:43 / cg" |
|
547 |
"Created: 15.6.1996 / 15:22:37 / cg" |
|
548 |
"Modified: 7.1.1997 / 19:36:11 / stefan" |
|
549 |
! ! |
|
550 |
||
551 |
!Win32OperatingSystem class methodsFor:'OS signal constants'! |
|
552 |
||
553 |
sigABRT |
|
554 |
"return the signal number for SIGABRT - 0 if not supported by OS |
|
555 |
(the numeric value is not the same across unix-systems)" |
|
556 |
||
557 |
%{ /* NOCONTEXT */ |
|
558 |
#ifdef SIGABRT |
|
559 |
RETURN ( __MKSMALLINT(SIGABRT) ); |
|
560 |
#else |
|
561 |
RETURN ( __MKSMALLINT(0) ); |
|
562 |
#endif |
|
563 |
%} |
|
564 |
! |
|
565 |
||
566 |
sigALRM |
|
567 |
"return the signal number for SIGALRM - 0 if not supported |
|
568 |
(the numeric value is not the same across unix-systems)" |
|
569 |
||
570 |
%{ /* NOCONTEXT */ |
|
571 |
#ifdef SIGALRM |
|
572 |
RETURN ( __MKSMALLINT(SIGALRM) ); |
|
573 |
#else |
|
574 |
RETURN ( __MKSMALLINT(0) ); |
|
575 |
#endif |
|
576 |
%} |
|
577 |
! |
|
578 |
||
579 |
sigBREAK |
|
580 |
"return the signal number for SIGBREAK - 0 if not supported. |
|
581 |
This is an MSDOS specific signal" |
|
582 |
||
583 |
%{ /* NOCONTEXT */ |
|
584 |
#ifdef SIGBREAK |
|
585 |
RETURN ( __MKSMALLINT(SIGBREAK) ); |
|
586 |
#else |
|
587 |
RETURN ( __MKSMALLINT(0) ); |
|
588 |
#endif |
|
589 |
%} |
|
590 |
! |
|
591 |
||
592 |
sigBUS |
|
593 |
"return the signal number for SIGBUS - 0 if not supported |
|
594 |
(the numeric value is not the same across unix-systems)" |
|
595 |
||
596 |
%{ /* NOCONTEXT */ |
|
597 |
#ifdef SIGBUS |
|
598 |
RETURN ( __MKSMALLINT(SIGBUS) ); |
|
599 |
#else |
|
600 |
RETURN ( __MKSMALLINT(0) ); |
|
601 |
#endif |
|
602 |
%} |
|
603 |
! |
|
604 |
||
605 |
sigCHLD |
|
606 |
"return the signal number for SIGCHLD - 0 if not supported |
|
607 |
(the numeric value is not the same across unix-systems)" |
|
608 |
||
609 |
%{ /* NOCONTEXT */ |
|
610 |
#if defined(SIGCHLD) |
|
611 |
RETURN ( __MKSMALLINT(SIGCHLD) ); |
|
612 |
#else |
|
613 |
# if defined(SIGCLD) |
|
614 |
RETURN ( __MKSMALLINT(SIGCLD) ); |
|
615 |
# else |
|
616 |
RETURN ( __MKSMALLINT(0) ); |
|
617 |
# endif |
|
618 |
#endif |
|
619 |
%} |
|
620 |
! |
|
621 |
||
622 |
sigCONT |
|
623 |
"return the signal number for SIGCONT - 0 if not supported |
|
624 |
(the numeric value is not the same across unix-systems)" |
|
625 |
||
626 |
%{ /* NOCONTEXT */ |
|
627 |
#if defined(SIGCONT) |
|
628 |
RETURN ( __MKSMALLINT(SIGCONT) ); |
|
629 |
#else |
|
630 |
RETURN ( __MKSMALLINT(0) ); |
|
631 |
#endif |
|
632 |
%} |
|
633 |
! |
|
634 |
||
635 |
sigDANGER |
|
636 |
"return the signal number for SIGDANGER - 0 if not supported |
|
637 |
(seems to be an AIX special)" |
|
638 |
||
639 |
%{ /* NOCONTEXT */ |
|
640 |
#if defined(SIGDANGER) |
|
641 |
RETURN ( __MKSMALLINT(SIGDANGER) ); |
|
642 |
#else |
|
643 |
RETURN ( __MKSMALLINT(0) ); |
|
644 |
#endif |
|
645 |
%} |
|
646 |
! |
|
647 |
||
648 |
sigEMT |
|
649 |
"return the signal number for SIGEMT - 0 if not supported by OS |
|
650 |
(the numeric value is not the same across unix-systems)" |
|
651 |
||
652 |
%{ /* NOCONTEXT */ |
|
653 |
#ifdef SIGEMT |
|
654 |
RETURN ( __MKSMALLINT(SIGEMT) ); |
|
655 |
#else |
|
656 |
RETURN ( __MKSMALLINT(0) ); |
|
657 |
#endif |
|
658 |
%} |
|
659 |
! |
|
660 |
||
661 |
sigFP |
|
662 |
"return the signal number for SIGFP - 0 if not supported by OS |
|
663 |
(the numeric value is not the same across unix-systems)" |
|
664 |
||
665 |
%{ /* NOCONTEXT */ |
|
666 |
#ifdef SIGFPE |
|
667 |
RETURN ( __MKSMALLINT(SIGFPE) ); |
|
668 |
#else |
|
669 |
RETURN ( __MKSMALLINT(0) ); |
|
670 |
#endif |
|
671 |
%} |
|
672 |
! |
|
673 |
||
674 |
sigGRANT |
|
675 |
"return the signal number for SIGGRANT - 0 if not supported |
|
676 |
(seems to be an AIX special)" |
|
677 |
||
678 |
%{ /* NOCONTEXT */ |
|
679 |
#if defined(SIGGRANT) |
|
680 |
RETURN ( __MKSMALLINT(SIGGRANT) ); |
|
681 |
#else |
|
682 |
RETURN ( __MKSMALLINT(0) ); |
|
683 |
#endif |
|
684 |
%} |
|
685 |
! |
|
686 |
||
687 |
sigHUP |
|
688 |
"return the signal number for SIGHUP |
|
689 |
(the numeric value is not the same across unix-systems)" |
|
690 |
||
691 |
%{ /* NOCONTEXT */ |
|
692 |
#ifdef SIGHUP |
|
693 |
RETURN ( __MKSMALLINT(SIGHUP) ); |
|
694 |
#else |
|
695 |
RETURN ( __MKSMALLINT(0) ); |
|
696 |
#endif |
|
697 |
%} |
|
698 |
! |
|
699 |
||
700 |
sigILL |
|
701 |
"return the signal number for SIGILL - 0 if not supported by OS |
|
702 |
(the numeric value is not the same across unix-systems)" |
|
703 |
||
704 |
%{ /* NOCONTEXT */ |
|
705 |
#ifdef SIGILL |
|
706 |
RETURN ( __MKSMALLINT(SIGILL) ); |
|
707 |
#else |
|
708 |
RETURN ( __MKSMALLINT(0) ); |
|
709 |
#endif |
|
710 |
%} |
|
711 |
! |
|
712 |
||
713 |
sigINT |
|
714 |
"return the signal number for SIGINT |
|
715 |
(the numeric value is not the same across unix-systems)" |
|
716 |
||
717 |
%{ /* NOCONTEXT */ |
|
718 |
#ifdef SIGINT |
|
719 |
RETURN ( __MKSMALLINT(SIGINT) ); |
|
720 |
#else |
|
721 |
RETURN ( __MKSMALLINT(0) ); |
|
722 |
#endif |
|
723 |
%} |
|
724 |
! |
|
725 |
||
726 |
sigIO |
|
727 |
"return the signal number for SIGIO - 0 if not supported |
|
728 |
(the numeric value is not the same across unix-systems)" |
|
729 |
||
730 |
%{ /* NOCONTEXT */ |
|
731 |
#if defined(SIGIO) |
|
732 |
RETURN ( __MKSMALLINT(SIGIO) ); |
|
733 |
#else |
|
734 |
RETURN ( __MKSMALLINT(0) ); |
|
735 |
#endif |
|
736 |
%} |
|
737 |
! |
|
738 |
||
739 |
sigIOT |
|
740 |
"return the signal number for SIGIOT - 0 if not supported by OS |
|
741 |
(the numeric value is not the same across unix-systems)" |
|
742 |
||
743 |
%{ /* NOCONTEXT */ |
|
744 |
#ifdef SIGIOT |
|
745 |
RETURN ( __MKSMALLINT(SIGIOT) ); |
|
746 |
#else |
|
747 |
RETURN ( __MKSMALLINT(0) ); |
|
748 |
#endif |
|
749 |
%} |
|
750 |
! |
|
751 |
||
752 |
sigKILL |
|
753 |
"return the signal number for SIGKILL |
|
754 |
(the numeric value is not the same across unix-systems)" |
|
755 |
||
756 |
%{ /* NOCONTEXT */ |
|
757 |
#ifdef SIGKILL |
|
758 |
RETURN ( __MKSMALLINT(SIGKILL) ); |
|
759 |
#else |
|
760 |
RETURN ( __MKSMALLINT(0) ); |
|
761 |
#endif |
|
762 |
%} |
|
763 |
! |
|
764 |
||
765 |
sigLOST |
|
766 |
"return the signal number for SIGLOST - 0 if not supported |
|
767 |
(the numeric value is not the same across unix-systems)" |
|
768 |
||
769 |
%{ /* NOCONTEXT */ |
|
770 |
#if defined(SIGLOST) |
|
771 |
RETURN ( __MKSMALLINT(SIGLOST) ); |
|
772 |
#else |
|
773 |
RETURN ( __MKSMALLINT(0) ); |
|
774 |
#endif |
|
775 |
%} |
|
776 |
! |
|
777 |
||
778 |
sigMIGRATE |
|
779 |
"return the signal number for SIGMIGRATE - 0 if not supported |
|
780 |
(seems to be an AIX special)" |
|
781 |
||
782 |
%{ /* NOCONTEXT */ |
|
783 |
#if defined(SIGMIGRATE) |
|
784 |
RETURN ( __MKSMALLINT(SIGMIGRATE) ); |
|
785 |
#else |
|
786 |
RETURN ( __MKSMALLINT(0) ); |
|
787 |
#endif |
|
788 |
%} |
|
789 |
! |
|
790 |
||
791 |
sigMSG |
|
792 |
"return the signal number for SIGMSG - 0 if not supported |
|
793 |
(seems to be an AIX special)" |
|
794 |
||
795 |
%{ /* NOCONTEXT */ |
|
796 |
#if defined(SIGMSG) |
|
797 |
RETURN ( __MKSMALLINT(SIGMSG) ); |
|
798 |
#else |
|
799 |
RETURN ( __MKSMALLINT(0) ); |
|
800 |
#endif |
|
801 |
%} |
|
802 |
! |
|
803 |
||
804 |
sigPIPE |
|
805 |
"return the signal number for SIGPIPE - 0 if not supported |
|
806 |
(the numeric value is not the same across unix-systems)" |
|
807 |
||
808 |
%{ /* NOCONTEXT */ |
|
809 |
#ifdef SIGPIPE |
|
810 |
RETURN ( __MKSMALLINT(SIGPIPE) ); |
|
811 |
#else |
|
812 |
RETURN ( __MKSMALLINT(0) ); |
|
813 |
#endif |
|
814 |
%} |
|
815 |
! |
|
816 |
||
817 |
sigPOLL |
|
818 |
"return the signal number for SIGPOLL - 0 if not supported |
|
819 |
(the numeric value is not the same across unix-systems)" |
|
820 |
||
821 |
%{ /* NOCONTEXT */ |
|
822 |
#if defined(SIGPOLL) |
|
823 |
RETURN ( __MKSMALLINT(SIGPOLL) ); |
|
824 |
#else |
|
825 |
RETURN ( __MKSMALLINT(0) ); |
|
826 |
#endif |
|
827 |
%} |
|
828 |
! |
|
829 |
||
830 |
sigPRE |
|
831 |
"return the signal number for SIGPRE - 0 if not supported |
|
832 |
(seems to be an AIX special)" |
|
833 |
||
834 |
%{ /* NOCONTEXT */ |
|
835 |
#if defined(SIGPRE) |
|
836 |
RETURN ( __MKSMALLINT(SIGPRE) ); |
|
837 |
#else |
|
838 |
RETURN ( __MKSMALLINT(0) ); |
|
839 |
#endif |
|
840 |
%} |
|
841 |
! |
|
842 |
||
843 |
sigPROF |
|
844 |
"return the signal number for SIGPROF - 0 if not supported |
|
845 |
(the numeric value is not the same across unix-systems)" |
|
846 |
||
847 |
%{ /* NOCONTEXT */ |
|
848 |
#if defined(SIGPROF) |
|
849 |
RETURN ( __MKSMALLINT(SIGPROF) ); |
|
850 |
#else |
|
851 |
RETURN ( __MKSMALLINT(0) ); |
|
852 |
#endif |
|
853 |
%} |
|
854 |
! |
|
855 |
||
856 |
sigPWR |
|
857 |
"return the signal number for SIGPWR - 0 if not supported |
|
858 |
(not available on all systems)" |
|
859 |
||
860 |
%{ /* NOCONTEXT */ |
|
861 |
#if defined(SIGPWR) |
|
862 |
RETURN ( __MKSMALLINT(SIGPWR) ); |
|
863 |
#else |
|
864 |
RETURN ( __MKSMALLINT(0) ); |
|
865 |
#endif |
|
866 |
%} |
|
867 |
! |
|
868 |
||
869 |
sigQUIT |
|
870 |
"return the signal number for SIGQUIT |
|
871 |
(the numeric value is not the same across unix-systems)" |
|
872 |
||
873 |
%{ /* NOCONTEXT */ |
|
874 |
#ifdef SIGQUIT |
|
875 |
RETURN ( __MKSMALLINT(SIGQUIT) ); |
|
876 |
#else |
|
877 |
RETURN ( __MKSMALLINT(0) ); |
|
878 |
#endif |
|
879 |
%} |
|
880 |
! |
|
881 |
||
882 |
sigRETRACT |
|
883 |
"return the signal number for SIGRETRACT - 0 if not supported |
|
884 |
(seems to be an AIX special)" |
|
885 |
||
886 |
%{ /* NOCONTEXT */ |
|
887 |
#if defined(SIGRETRACT) |
|
888 |
RETURN ( __MKSMALLINT(SIGRETRACT) ); |
|
889 |
#else |
|
890 |
RETURN ( __MKSMALLINT(0) ); |
|
891 |
#endif |
|
892 |
%} |
|
893 |
! |
|
894 |
||
895 |
sigSAK |
|
896 |
"return the signal number for SIGSAK - 0 if not supported |
|
897 |
(seems to be an AIX special)" |
|
898 |
||
899 |
%{ /* NOCONTEXT */ |
|
900 |
#if defined(SIGSAK) |
|
901 |
RETURN ( __MKSMALLINT(SIGSAK) ); |
|
902 |
#else |
|
903 |
RETURN ( __MKSMALLINT(0) ); |
|
904 |
#endif |
|
905 |
%} |
|
906 |
! |
|
907 |
||
908 |
sigSEGV |
|
909 |
"return the signal number for SIGSEGV - 0 if not supported |
|
910 |
(the numeric value is not the same across unix-systems)" |
|
911 |
||
912 |
%{ /* NOCONTEXT */ |
|
913 |
#ifdef SIGSEGV |
|
914 |
RETURN ( __MKSMALLINT(SIGSEGV) ); |
|
915 |
#else |
|
916 |
RETURN ( __MKSMALLINT(0) ); |
|
917 |
#endif |
|
918 |
%} |
|
919 |
! |
|
920 |
||
921 |
sigSOUND |
|
922 |
"return the signal number for SIGSOUND - 0 if not supported |
|
923 |
(seems to be an AIX special)" |
|
924 |
||
925 |
%{ /* NOCONTEXT */ |
|
926 |
#if defined(SIGSOUND) |
|
927 |
RETURN ( __MKSMALLINT(SIGSOUND) ); |
|
928 |
#else |
|
929 |
RETURN ( __MKSMALLINT(0) ); |
|
930 |
#endif |
|
931 |
%} |
|
932 |
! |
|
933 |
||
934 |
sigSTOP |
|
935 |
"return the signal number for SIGSTOP - 0 if not supported |
|
936 |
(the numeric value is not the same across unix-systems)" |
|
937 |
||
938 |
%{ /* NOCONTEXT */ |
|
939 |
#if defined(SIGSTOP) |
|
940 |
RETURN ( __MKSMALLINT(SIGSTOP) ); |
|
941 |
#else |
|
942 |
RETURN ( __MKSMALLINT(0) ); |
|
943 |
#endif |
|
944 |
%} |
|
945 |
! |
|
946 |
||
947 |
sigSYS |
|
948 |
"return the signal number for SIGSYS - 0 if not supported |
|
949 |
(the numeric value is not the same across unix-systems)" |
|
950 |
||
951 |
%{ /* NOCONTEXT */ |
|
952 |
#ifdef SIGSYS |
|
953 |
RETURN ( __MKSMALLINT(SIGSYS) ); |
|
954 |
#else |
|
955 |
RETURN ( __MKSMALLINT(0) ); |
|
956 |
#endif |
|
957 |
%} |
|
958 |
! |
|
959 |
||
960 |
sigTERM |
|
961 |
"return the signal number for SIGTERM - 0 if not supported |
|
962 |
(the numeric value is not the same across unix-systems)" |
|
963 |
||
964 |
%{ /* NOCONTEXT */ |
|
965 |
#ifdef SIGTERM |
|
966 |
RETURN ( __MKSMALLINT(SIGTERM) ); |
|
967 |
#else |
|
968 |
RETURN ( __MKSMALLINT(0) ); |
|
969 |
#endif |
|
970 |
%} |
|
971 |
! |
|
972 |
||
973 |
sigTRAP |
|
974 |
"return the signal number for SIGTRAP - 0 if not supported by OS |
|
975 |
(the numeric value is not the same across unix-systems)" |
|
976 |
||
977 |
%{ /* NOCONTEXT */ |
|
978 |
#ifdef SIGTRAP |
|
979 |
RETURN ( __MKSMALLINT(SIGTRAP) ); |
|
980 |
#else |
|
981 |
RETURN ( __MKSMALLINT(0) ); |
|
982 |
#endif |
|
983 |
%} |
|
984 |
! |
|
985 |
||
986 |
sigTSTP |
|
987 |
"return the signal number for SIGTSTP - 0 if not supported |
|
988 |
(the numeric value is not the same across unix-systems)" |
|
989 |
||
990 |
%{ /* NOCONTEXT */ |
|
991 |
#if defined(SIGTSTP) |
|
992 |
RETURN ( __MKSMALLINT(SIGTSTP) ); |
|
993 |
#else |
|
994 |
RETURN ( __MKSMALLINT(0) ); |
|
995 |
#endif |
|
996 |
%} |
|
997 |
! |
|
998 |
||
999 |
sigTTIN |
|
1000 |
"return the signal number for SIGTTIN - 0 if not supported |
|
1001 |
(the numeric value is not the same across unix-systems)" |
|
1002 |
||
1003 |
%{ /* NOCONTEXT */ |
|
1004 |
#if defined(SIGTTIN) |
|
1005 |
RETURN ( __MKSMALLINT(SIGTTIN) ); |
|
1006 |
#else |
|
1007 |
RETURN ( __MKSMALLINT(0) ); |
|
1008 |
#endif |
|
1009 |
%} |
|
1010 |
! |
|
1011 |
||
1012 |
sigTTOU |
|
1013 |
"return the signal number for SIGTTOU - 0 if not supported |
|
1014 |
(the numeric value is not the same across unix-systems)" |
|
1015 |
||
1016 |
%{ /* NOCONTEXT */ |
|
1017 |
#if defined(SIGTTOU) |
|
1018 |
RETURN ( __MKSMALLINT(SIGTTOU) ); |
|
1019 |
#else |
|
1020 |
RETURN ( __MKSMALLINT(0) ); |
|
1021 |
#endif |
|
1022 |
%} |
|
1023 |
! |
|
1024 |
||
1025 |
sigURG |
|
1026 |
"return the signal number for SIGURG - 0 if not supported |
|
1027 |
(the numeric value is not the same across unix-systems)" |
|
1028 |
||
1029 |
%{ /* NOCONTEXT */ |
|
1030 |
#if defined(SIGURG) |
|
1031 |
RETURN ( __MKSMALLINT(SIGURG) ); |
|
1032 |
#else |
|
1033 |
RETURN ( __MKSMALLINT(0) ); |
|
1034 |
#endif |
|
1035 |
%} |
|
1036 |
! |
|
1037 |
||
1038 |
sigUSR1 |
|
1039 |
"return the signal number for SIGUSR1 - 0 if not supported |
|
1040 |
(the numeric value is not the same across unix-systems)" |
|
1041 |
||
1042 |
%{ /* NOCONTEXT */ |
|
1043 |
#if defined(SIGUSR1) |
|
1044 |
RETURN ( __MKSMALLINT(SIGUSR1) ); |
|
1045 |
#else |
|
1046 |
RETURN ( __MKSMALLINT(0) ); |
|
1047 |
#endif |
|
1048 |
%} |
|
1049 |
! |
|
1050 |
||
1051 |
sigUSR2 |
|
1052 |
"return the signal number for SIGUSR2 - 0 if not supported |
|
1053 |
(the numeric value is not the same across unix-systems)" |
|
1054 |
||
1055 |
%{ /* NOCONTEXT */ |
|
1056 |
#if defined(SIGUSR2) |
|
1057 |
RETURN ( __MKSMALLINT(SIGUSR2) ); |
|
1058 |
#else |
|
1059 |
RETURN ( __MKSMALLINT(0) ); |
|
1060 |
#endif |
|
1061 |
%} |
|
1062 |
! |
|
1063 |
||
1064 |
sigVTALRM |
|
1065 |
"return the signal number for SIGVTALRM - 0 if not supported |
|
1066 |
(the numeric value is not the same across unix-systems)" |
|
1067 |
||
1068 |
%{ /* NOCONTEXT */ |
|
1069 |
#if defined(SIGVTALRM) |
|
1070 |
RETURN ( __MKSMALLINT(SIGVTALRM) ); |
|
1071 |
#else |
|
1072 |
RETURN ( __MKSMALLINT(0) ); |
|
1073 |
#endif |
|
1074 |
%} |
|
1075 |
! |
|
1076 |
||
1077 |
sigWINCH |
|
1078 |
"return the signal number for SIGWINCH - 0 if not supported |
|
1079 |
(the numeric value is not the same across unix-systems)" |
|
1080 |
||
1081 |
%{ /* NOCONTEXT */ |
|
1082 |
#if defined(SIGWINCH) |
|
1083 |
RETURN ( __MKSMALLINT(SIGWINCH) ); |
|
1084 |
#else |
|
1085 |
RETURN ( __MKSMALLINT(0) ); |
|
1086 |
#endif |
|
1087 |
%} |
|
1088 |
! |
|
1089 |
||
1090 |
sigXCPU |
|
1091 |
"return the signal number for SIGXCPU - 0 if not supported |
|
1092 |
(the numeric value is not the same across unix-systems)" |
|
1093 |
||
1094 |
%{ /* NOCONTEXT */ |
|
1095 |
#if defined(SIGXCPU) |
|
1096 |
RETURN ( __MKSMALLINT(SIGXCPU) ); |
|
1097 |
#else |
|
1098 |
RETURN ( __MKSMALLINT(0) ); |
|
1099 |
#endif |
|
1100 |
%} |
|
1101 |
! |
|
1102 |
||
1103 |
sigXFSZ |
|
1104 |
"return the signal number for SIGXFSZ - 0 if not supported |
|
1105 |
(the numeric value is not the same across unix-systems)" |
|
1106 |
||
1107 |
%{ /* NOCONTEXT */ |
|
1108 |
#if defined(SIGXFSZ) |
|
1109 |
RETURN ( __MKSMALLINT(SIGXFSZ) ); |
|
1110 |
#else |
|
1111 |
RETURN ( __MKSMALLINT(0) ); |
|
1112 |
#endif |
|
1113 |
%} |
|
1114 |
! ! |
|
1115 |
||
1116 |
!Win32OperatingSystem class methodsFor:'error messages'! |
|
1117 |
||
1118 |
currentErrorNumber |
|
1119 |
"returns the OS's last error nr (i.e. the value of errno). |
|
1120 |
Notice, that the value of this flag is only valid immediately |
|
1121 |
after the error occurred - it gets updated with every other |
|
1122 |
request to the OS. |
|
1123 |
Use lastErrorNumber - currentErrorNumber is invalidated by |
|
1124 |
many, many internal calls." |
|
1125 |
||
1126 |
%{ /* NOCONTEXT */ |
|
1127 |
||
1128 |
RETURN ( __MKSMALLINT(__threadErrno) ); |
|
1129 |
%} |
|
1130 |
" |
|
1131 |
OperatingSystem currentErrorNumber |
|
1132 |
" |
|
1133 |
! |
|
1134 |
||
6275 | 1135 |
errorHolderForNumber:errNr |
1136 |
"return an osErrorHolder for the given error number (as returned by a system call)." |
|
1137 |
||
6277 | 1138 |
|sym typ holder| |
6275 | 1139 |
|
1140 |
%{ |
|
1141 |
/* claus: |
|
1142 |
* I made this primitive code, since errnos are not |
|
1143 |
* standard across unixes |
|
1144 |
*/ |
|
1145 |
||
1146 |
typ = @symbol(defaultOsErrorSignal); |
|
6277 | 1147 |
sym = @symbol(ERROR_OTHER); |
1148 |
||
6288 | 1149 |
if (__isSmallInteger(errNr)) { |
1150 |
int __eno = __intVal(errNr); |
|
6275 | 1151 |
|
1152 |
if (__isWIN32Error(__eno)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1153 |
switch (__eno & 0xFFFF) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1154 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1155 |
* WIN32 GetLastError returns |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1156 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1157 |
case ERROR_INVALID_FUNCTION: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1158 |
sym = @symbol(ERROR_INVALID_FUNCTION); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1159 |
typ = @symbol(illegalOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1160 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1161 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1162 |
case ERROR_BAD_FORMAT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1163 |
sym = @symbol(ERROR_BAD_FORMAT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1164 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1165 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1166 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1167 |
case ERROR_FILE_NOT_FOUND: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1168 |
sym = @symbol(ERROR_FILE_NOT_FOUND); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1169 |
typ = @symbol(nonexistentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1170 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1171 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1172 |
case ERROR_PATH_NOT_FOUND: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1173 |
sym = @symbol(ERROR_PATH_NOT_FOUND); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1174 |
typ = @symbol(nonexistentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1175 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1176 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1177 |
case ERROR_TOO_MANY_OPEN_FILES: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1178 |
sym = @symbol(ERROR_TOO_MANY_OPEN_FILES); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1179 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1180 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1181 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1182 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1183 |
* 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
|
1184 |
* encountered ... (... those stupid micro-softies ...) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1185 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1186 |
case ERROR_OPEN_FAILED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1187 |
sym = @symbol(ERROR_OPEN_FAILED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1188 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1189 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1190 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1191 |
case ERROR_ACCESS_DENIED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1192 |
sym = @symbol(ERROR_ACCESS_DENIED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1193 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1194 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1195 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1196 |
case ERROR_INVALID_HANDLE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1197 |
sym = @symbol(ERROR_INVALID_HANDLE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1198 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1199 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1200 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1201 |
case ERROR_NOT_ENOUGH_MEMORY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1202 |
sym = @symbol(ERROR_NOT_ENOUGH_MEMORY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1203 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1204 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1205 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1206 |
case ERROR_INVALID_ACCESS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1207 |
sym = @symbol(ERROR_INVALID_ACCESS); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1208 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1209 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1210 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1211 |
case ERROR_INVALID_DATA: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1212 |
sym = @symbol(ERROR_INVALID_DATA); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1213 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1214 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1215 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1216 |
case ERROR_INVALID_NAME: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1217 |
sym = @symbol(ERROR_INVALID_NAME); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1218 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1219 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1220 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1221 |
case ERROR_ARENA_TRASHED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1222 |
sym = @symbol(ERROR_ARENA_TRASHED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1223 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1224 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1225 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1226 |
case ERROR_OUTOFMEMORY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1227 |
sym = @symbol(ERROR_OUTOFMEMORY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1228 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1229 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1230 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1231 |
case ERROR_BROKEN_PIPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1232 |
sym = @symbol(ERROR_BROKEN_PIPE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1233 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1234 |
break; |
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_GEN_FAILURE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1237 |
sym = @symbol(ERROR_GEN_FAILURE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1238 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1239 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1240 |
case ERROR_WRITE_PROTECT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1241 |
sym = @symbol(ERROR_WRITE_PROTECT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1242 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1243 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1244 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1245 |
case ERROR_WRITE_FAULT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1246 |
sym = @symbol(ERROR_WRITE_FAULT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1247 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1248 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1249 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1250 |
case ERROR_READ_FAULT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1251 |
sym = @symbol(ERROR_READ_FAULT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1252 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1253 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1254 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1255 |
case ERROR_HANDLE_DISK_FULL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1256 |
sym = @symbol(ERROR_HANDLE_DISK_FULL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1257 |
typ = @symbol(volumeFullSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1258 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1259 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1260 |
case ERROR_DISK_FULL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1261 |
sym = @symbol(ERROR_DISK_FULL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1262 |
typ = @symbol(volumeFullSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1263 |
break; |
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_SHARING_VIOLATION: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1266 |
sym = @symbol(ERROR_SHARING_VIOLATION); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1267 |
typ = @symbol(noPermissionsSignal); |
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_LOCK_VIOLATION: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1271 |
sym = @symbol(ERROR_LOCK_VIOLATION); |
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_PARAMETER: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1276 |
sym = @symbol(ERROR_INVALID_PARAMETER); |
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_NET_WRITE_FAULT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1281 |
sym = @symbol(ERROR_NET_WRITE_FAULT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1282 |
typ = @symbol(transferFaultSignal); |
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_NOT_SUPPORTED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1286 |
sym = @symbol(ERROR_NOT_SUPPORTED); |
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_REM_NOT_LIST: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1291 |
sym = @symbol(ERROR_REM_NOT_LIST); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1292 |
typ = @symbol(noResourcesSignal); |
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_NETWORK_ACCESS_DENIED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1296 |
sym = @symbol(ERROR_NETWORK_ACCESS_DENIED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1297 |
typ = @symbol(noPermissionsSignal); |
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_DUP_NAME: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1301 |
sym = @symbol(ERROR_DUP_NAME); |
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_BAD_NETPATH: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1306 |
sym = @symbol(ERROR_BAD_NETPATH); |
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_NETWORK_BUSY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1311 |
sym = @symbol(ERROR_NETWORK_BUSY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1312 |
typ = @symbol(noResourcesSignal); |
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_DRIVE_LOCKED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1316 |
sym = @symbol(ERROR_DRIVE_LOCKED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1317 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1318 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1319 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1320 |
case ERROR_INVALID_DRIVE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1321 |
sym = @symbol(ERROR_INVALID_DRIVE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1322 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1323 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1324 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1325 |
case ERROR_WRONG_DISK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1326 |
sym = @symbol(ERROR_WRONG_DISK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1327 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1328 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1329 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1330 |
case ERROR_CURRENT_DIRECTORY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1331 |
sym = @symbol(ERROR_CURRENT_DIRECTORY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1332 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1333 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1334 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1335 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1336 |
* 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
|
1337 |
* encountered ... (... those stupid micro-softies ...) |
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_CANNOT_MAKE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1340 |
sym = @symbol(ERROR_CANNOT_MAKE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1341 |
typ = @symbol(inappropriateOperationSignal); |
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_NO_MORE_FILES: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1345 |
sym = @symbol(ERROR_NO_MORE_FILES); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1346 |
typ = @symbol(noResourcesSignal); |
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_NOT_READY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1350 |
sym = @symbol(ERROR_NOT_READY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1351 |
typ = @symbol(noResourcesSignal); |
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_NOT_DOS_DISK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1355 |
sym = @symbol(ERROR_NOT_DOS_DISK); |
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_OUT_OF_PAPER: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1360 |
sym = @symbol(ERROR_OUT_OF_PAPER); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1361 |
typ = @symbol(noResourcesSignal); |
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_PRINTQ_FULL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1365 |
sym = @symbol(ERROR_PRINTQ_FULL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1366 |
typ = @symbol(noResourcesSignal); |
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 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1370 |
sym = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1371 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1372 |
} |
6275 | 1373 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1374 |
switch (__eno) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1375 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1376 |
* POSIX errnos - these should be defined |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1377 |
*/ |
6275 | 1378 |
#ifdef EPERM |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1379 |
case EPERM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1380 |
sym = @symbol(EPERM); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1381 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1382 |
break; |
6275 | 1383 |
#endif |
1384 |
#ifdef ENOENT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1385 |
case ENOENT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1386 |
sym = @symbol(ENOENT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1387 |
typ = @symbol(nonexistentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1388 |
break; |
6275 | 1389 |
#endif |
1390 |
#ifdef ESRCH |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1391 |
case ESRCH: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1392 |
sym = @symbol(ESRCH); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1393 |
typ = @symbol(unavailableReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1394 |
break; |
6275 | 1395 |
#endif |
1396 |
#ifdef EINTR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1397 |
case EINTR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1398 |
sym = @symbol(EINTR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1399 |
typ = @symbol(transientErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1400 |
break; |
6275 | 1401 |
#endif |
1402 |
#ifdef EIO |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1403 |
case EIO: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1404 |
sym = @symbol(EIO); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1405 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1406 |
break; |
6275 | 1407 |
#endif |
1408 |
#ifdef ENXIO |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1409 |
case ENXIO: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1410 |
sym = @symbol(ENXIO); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1411 |
typ = @symbol(unavailableReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1412 |
break; |
6275 | 1413 |
#endif |
1414 |
#ifdef E2BIG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1415 |
case E2BIG: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1416 |
sym = @symbol(E2BIG); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1417 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1418 |
break; |
6275 | 1419 |
#endif |
1420 |
#ifdef ENOEXEC |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1421 |
case ENOEXEC: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1422 |
sym = @symbol(ENOEXEC); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1423 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1424 |
break; |
6275 | 1425 |
#endif |
1426 |
#ifdef EBADF |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1427 |
case EBADF: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1428 |
sym = @symbol(EBADF); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1429 |
typ = @symbol(badAccessorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1430 |
break; |
6275 | 1431 |
#endif |
1432 |
#ifdef ECHILD |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1433 |
case ECHILD: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1434 |
sym = @symbol(ECHILD); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1435 |
typ = @symbol(informationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1436 |
break; |
6275 | 1437 |
#endif |
1438 |
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN) |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1439 |
case EAGAIN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1440 |
sym = @symbol(EAGAIN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1441 |
typ = @symbol(notReadySignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1442 |
break; |
6275 | 1443 |
#endif |
1444 |
#ifdef ENOMEM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1445 |
case ENOMEM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1446 |
sym = @symbol(ENOMEM); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1447 |
typ = @symbol(noMemorySignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1448 |
break; |
6275 | 1449 |
#endif |
1450 |
#ifdef EACCES |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1451 |
case EACCES: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1452 |
sym = @symbol(EACCES); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1453 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1454 |
break; |
6275 | 1455 |
#endif |
1456 |
#ifdef EFAULT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1457 |
case EFAULT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1458 |
sym = @symbol(EFAULT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1459 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1460 |
break; |
6275 | 1461 |
#endif |
1462 |
#ifdef EBUSY |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1463 |
case EBUSY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1464 |
sym = @symbol(EBUSY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1465 |
typ = @symbol(unavailableReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1466 |
break; |
6275 | 1467 |
#endif |
1468 |
#ifdef EEXIST |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1469 |
case EEXIST: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1470 |
sym = @symbol(EEXIST); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1471 |
typ = @symbol(existingReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1472 |
break; |
6275 | 1473 |
#endif |
1474 |
#ifdef EXDEV |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1475 |
case EXDEV: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1476 |
sym = @symbol(EXDEV); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1477 |
typ = @symbol(inappropriateReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1478 |
break; |
6275 | 1479 |
#endif |
1480 |
#ifdef ENODEV |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1481 |
case ENODEV: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1482 |
sym = @symbol(ENODEV); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1483 |
typ = @symbol(inaccessibleSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1484 |
break; |
6275 | 1485 |
#endif |
1486 |
#ifdef ENOTDIR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1487 |
case ENOTDIR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1488 |
sym = @symbol(ENOTDIR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1489 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1490 |
break; |
6275 | 1491 |
#endif |
1492 |
#ifdef EISDIR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1493 |
case EISDIR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1494 |
sym = @symbol(EISDIR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1495 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1496 |
break; |
6275 | 1497 |
#endif |
1498 |
#ifdef EINVAL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1499 |
case EINVAL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1500 |
sym = @symbol(EINVAL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1501 |
typ = @symbol(invalidArgumentsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1502 |
break; |
6275 | 1503 |
#endif |
1504 |
#ifdef ENFILE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1505 |
case ENFILE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1506 |
sym = @symbol(ENFILE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1507 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1508 |
break; |
6275 | 1509 |
#endif |
1510 |
#ifdef EMFILE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1511 |
case EMFILE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1512 |
sym = @symbol(EMFILE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1513 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1514 |
break; |
6275 | 1515 |
#endif |
1516 |
#ifdef ENOTTY |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1517 |
case ENOTTY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1518 |
sym = @symbol(ENOTTY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1519 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1520 |
break; |
6275 | 1521 |
#endif |
1522 |
#ifdef EFBIG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1523 |
case EFBIG: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1524 |
sym = @symbol(EFBIG); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1525 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1526 |
break; |
6275 | 1527 |
#endif |
1528 |
#ifdef ENOSPC |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1529 |
case ENOSPC: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1530 |
sym = @symbol(ENOSPC); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1531 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1532 |
break; |
6275 | 1533 |
#endif |
1534 |
#ifdef ESPIPE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1535 |
case ESPIPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1536 |
sym = @symbol(ESPIPE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1537 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1538 |
break; |
6275 | 1539 |
#endif |
1540 |
#ifdef EROFS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1541 |
case EROFS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1542 |
sym = @symbol(EROFS); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1543 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1544 |
break; |
6275 | 1545 |
#endif |
1546 |
#ifdef EMLINK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1547 |
case EMLINK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1548 |
sym = @symbol(EMLINK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1549 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1550 |
break; |
6275 | 1551 |
#endif |
1552 |
#ifdef EPIPE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1553 |
case EPIPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1554 |
sym = @symbol(EPIPE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1555 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1556 |
break; |
6275 | 1557 |
#endif |
1558 |
#ifdef EDOM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1559 |
case EDOM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1560 |
sym = @symbol(EDOM); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1561 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1562 |
break; |
6275 | 1563 |
#endif |
1564 |
#ifdef ERANGE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1565 |
case ERANGE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1566 |
sym = @symbol(ERANGE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1567 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1568 |
break; |
6275 | 1569 |
#endif |
1570 |
#ifdef EDEADLK |
|
1571 |
# if EDEADLK != EWOULDBLOCK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1572 |
case EDEADLK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1573 |
sym = @symbol(EDEADLK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1574 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1575 |
break; |
6275 | 1576 |
# endif |
1577 |
#endif |
|
1578 |
#ifdef ENAMETOOLONG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1579 |
case ENAMETOOLONG: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1580 |
sym = @symbol(ENAMETOOLONG); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1581 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1582 |
break; |
6275 | 1583 |
#endif |
1584 |
#ifdef ENOLCK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1585 |
case ENOLCK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1586 |
sym = @symbol(ENOLCK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1587 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1588 |
break; |
6275 | 1589 |
#endif |
1590 |
#ifdef ENOSYS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1591 |
case ENOSYS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1592 |
sym = @symbol(ENOSYS); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1593 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1594 |
break; |
6275 | 1595 |
#endif |
1596 |
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1597 |
case ENOTEMPTY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1598 |
sym = @symbol(ENOTEMPTY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1599 |
typ = @symbol(inappropriateReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1600 |
break; |
6275 | 1601 |
#endif |
1602 |
#ifdef EILSEQ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1603 |
case EILSEQ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1604 |
sym = @symbol(EILSEQ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1605 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1606 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1607 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1608 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1609 |
* XPG3 errnos - defined on most systems |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1610 |
*/ |
6275 | 1611 |
#ifdef ENOTBLK |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1612 |
case ENOTBLK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1613 |
sym = @symbol(ENOTBLK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1614 |
typ = @symbol(inappropriateReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1615 |
break; |
6275 | 1616 |
#endif |
1617 |
#ifdef ETXTBSY |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1618 |
case ETXTBSY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1619 |
sym = @symbol(ETXTBSY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1620 |
typ = @symbol(inaccessibleSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1621 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1622 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1623 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1624 |
* some others |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1625 |
*/ |
6275 | 1626 |
#ifdef EWOULDBLOCK |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1627 |
case EWOULDBLOCK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1628 |
sym = @symbol(EWOULDBLOCK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1629 |
typ = @symbol(notReadySignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1630 |
break; |
6275 | 1631 |
#endif |
1632 |
#ifdef ENOMSG |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1633 |
case ENOMSG: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1634 |
sym = @symbol(ENOMSG); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1635 |
typ = @symbol(noDataSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1636 |
break; |
6275 | 1637 |
#endif |
1638 |
#ifdef ELOOP |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1639 |
case ELOOP: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1640 |
sym = @symbol(ELOOP); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1641 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1642 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1643 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1644 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1645 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1646 |
* some stream errors |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1647 |
*/ |
6275 | 1648 |
#ifdef ETIME |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1649 |
case ETIME: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1650 |
sym = @symbol(ETIME); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1651 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1652 |
break; |
6275 | 1653 |
#endif |
1654 |
#ifdef ENOSR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1655 |
case ENOSR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1656 |
sym = @symbol(ENOSR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1657 |
typ = @symbol(noResourcesSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1658 |
break; |
6275 | 1659 |
#endif |
1660 |
#ifdef ENOSTR |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1661 |
case ENOSTR: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1662 |
sym = @symbol(ENOSTR); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1663 |
typ = @symbol(inappropriateReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1664 |
break; |
6275 | 1665 |
#endif |
1666 |
#ifdef ECOMM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1667 |
case ECOMM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1668 |
sym = @symbol(ECOMM); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1669 |
typ = @symbol(transferFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1670 |
break; |
6275 | 1671 |
#endif |
1672 |
#ifdef EPROTO |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1673 |
case EPROTO: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1674 |
sym = @symbol(EPROTO); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1675 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1676 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1677 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1678 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1679 |
* nfs errors |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1680 |
*/ |
6275 | 1681 |
#ifdef ESTALE |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1682 |
case ESTALE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1683 |
sym = @symbol(ESTALE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1684 |
typ = @symbol(unavailableReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1685 |
break; |
6275 | 1686 |
#endif |
1687 |
#ifdef EREMOTE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1688 |
case EREMOTE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1689 |
sym = @symbol(EREMOTE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1690 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1691 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1692 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1693 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1694 |
* some networking errors |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1695 |
*/ |
6275 | 1696 |
#ifdef EINPROGRESS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1697 |
case EINPROGRESS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1698 |
sym = @symbol(EINPROGRESS); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1699 |
typ = @symbol(operationStartedSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1700 |
break; |
6275 | 1701 |
#endif |
1702 |
#ifdef EALREADY |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1703 |
case EALREADY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1704 |
sym = @symbol(EALREADY); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1705 |
typ = @symbol(operationStartedSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1706 |
break; |
6275 | 1707 |
#endif |
1708 |
#ifdef ENOTSOCK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1709 |
case ENOTSOCK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1710 |
sym = @symbol(ENOTSOCK); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1711 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1712 |
break; |
6275 | 1713 |
#endif |
1714 |
#ifdef EDESTADDRREQ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1715 |
case EDESTADDRREQ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1716 |
sym = @symbol(EDESTADDRREQ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1717 |
typ = @symbol(underspecifiedSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1718 |
break; |
6275 | 1719 |
#endif |
1720 |
#ifdef EMSGSIZE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1721 |
case EMSGSIZE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1722 |
sym = @symbol(EMSGSIZE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1723 |
typ = @symbol(rangeErrorSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1724 |
break; |
6275 | 1725 |
#endif |
1726 |
#ifdef EPROTOTYPE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1727 |
case EPROTOTYPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1728 |
sym = @symbol(EPROTOTYPE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1729 |
typ = @symbol(wrongSubtypeForOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1730 |
break; |
6275 | 1731 |
#endif |
1732 |
#ifdef ENOPROTOOPT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1733 |
case ENOPROTOOPT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1734 |
sym = @symbol(ENOPROTOOPT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1735 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1736 |
break; |
6275 | 1737 |
#endif |
1738 |
#ifdef EPROTONOSUPPORT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1739 |
case EPROTONOSUPPORT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1740 |
sym = @symbol(EPROTONOSUPPORT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1741 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1742 |
break; |
6275 | 1743 |
#endif |
1744 |
#ifdef ESOCKTNOSUPPORT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1745 |
case ESOCKTNOSUPPORT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1746 |
sym = @symbol(ESOCKTNOSUPPORT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1747 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1748 |
break; |
6275 | 1749 |
#endif |
1750 |
#ifdef EOPNOTSUPP |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1751 |
case EOPNOTSUPP: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1752 |
sym = @symbol(EOPNOTSUPP); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1753 |
typ = @symbol(inappropriateOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1754 |
break; |
6275 | 1755 |
#endif |
1756 |
#ifdef EPFNOSUPPORT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1757 |
case EPFNOSUPPORT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1758 |
sym = @symbol(EPFNOSUPPORT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1759 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1760 |
break; |
6275 | 1761 |
#endif |
1762 |
#ifdef EAFNOSUPPORT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1763 |
case EAFNOSUPPORT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1764 |
sym = @symbol(EAFNOSUPPORT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1765 |
typ = @symbol(unsupportedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1766 |
break; |
6275 | 1767 |
#endif |
1768 |
#ifdef EADDRINUSE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1769 |
case EADDRINUSE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1770 |
sym = @symbol(EADDRINUSE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1771 |
typ = @symbol(existingReferentSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1772 |
break; |
6275 | 1773 |
#endif |
1774 |
#ifdef EADDRNOTAVAIL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1775 |
case EADDRNOTAVAIL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1776 |
sym = @symbol(EADDRNOTAVAIL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1777 |
typ = @symbol(noPermissionsSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1778 |
break; |
6275 | 1779 |
#endif |
1780 |
#ifdef ETIMEDOUT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1781 |
case ETIMEDOUT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1782 |
sym = @symbol(ETIMEDOUT); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1783 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1784 |
break; |
6275 | 1785 |
#endif |
1786 |
#ifdef ECONNREFUSED |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1787 |
case ECONNREFUSED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1788 |
sym = @symbol(ECONNREFUSED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1789 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1790 |
break; |
6275 | 1791 |
#endif |
1792 |
#ifdef ENETDOWN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1793 |
case ENETDOWN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1794 |
sym = @symbol(ENETDOWN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1795 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1796 |
break; |
6275 | 1797 |
#endif |
1798 |
#ifdef ENETUNREACH |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1799 |
case ENETUNREACH: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1800 |
sym = @symbol(ENETUNREACH); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1801 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1802 |
break; |
6275 | 1803 |
#endif |
1804 |
#ifdef ENETRESET |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1805 |
case ENETRESET: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1806 |
sym = @symbol(ENETRESET); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1807 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1808 |
break; |
6275 | 1809 |
#endif |
1810 |
#ifdef ECONNABORTED |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1811 |
case ECONNABORTED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1812 |
sym = @symbol(ECONNABORTED); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1813 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1814 |
break; |
6275 | 1815 |
#endif |
1816 |
#ifdef ECONNRESET |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1817 |
case ECONNRESET: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1818 |
sym = @symbol(ECONNRESET); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1819 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1820 |
break; |
6275 | 1821 |
#endif |
1822 |
#ifdef EISCONN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1823 |
case EISCONN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1824 |
sym = @symbol(EISCONN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1825 |
typ = @symbol(unpreparedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1826 |
break; |
6275 | 1827 |
#endif |
1828 |
#ifdef ENOTCONN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1829 |
case ENOTCONN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1830 |
sym = @symbol(ENOTCONN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1831 |
typ = @symbol(unpreparedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1832 |
break; |
6275 | 1833 |
#endif |
1834 |
#ifdef ESHUTDOWN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1835 |
case ESHUTDOWN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1836 |
sym = @symbol(ESHUTDOWN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1837 |
typ = @symbol(unpreparedOperationSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1838 |
break; |
6275 | 1839 |
#endif |
1840 |
#ifdef EHOSTDOWN |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1841 |
case EHOSTDOWN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1842 |
sym = @symbol(EHOSTDOWN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1843 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1844 |
break; |
6275 | 1845 |
#endif |
1846 |
#ifdef EHOSTUNREACH |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1847 |
case EHOSTUNREACH: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1848 |
sym = @symbol(EHOSTUNREACH); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1849 |
typ = @symbol(peerFaultSignal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1850 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1851 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1852 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1853 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1854 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1855 |
} |
6275 | 1856 |
} |
1857 |
} |
|
1858 |
%}. |
|
1859 |
holder := OSErrorHolder new. |
|
6277 | 1860 |
holder errorSymbol:sym errorCategory:typ. |
6275 | 1861 |
^ holder |
1862 |
||
1863 |
" |
|
1864 |
OperatingSystem errorHolderForNumber:4 |
|
1865 |
self errorHolderForNumber:(self errorNumberFor:#EPERM) |
|
1866 |
self errorHolderForNumber:(self errorNumberFor:#EIO) |
|
1867 |
self errorHolderForNumber:(self errorNumberFor:#ENXIO) |
|
1868 |
" |
|
1869 |
! |
|
1870 |
||
5133 | 1871 |
errorNumberFor:aSymbol |
1872 |
"given a symbolic error, return the numeric; |
|
1873 |
(i.e. errorNumberFor:#EBADF returns EBADF's value). |
|
1874 |
Use this, since error numbers are really not standard across unix systems." |
|
1875 |
||
1876 |
%{ /* NOCONTEXT */ |
|
1877 |
OBJ sym = aSymbol; |
|
1878 |
||
1879 |
/* |
|
6277 | 1880 |
* WIN32 GetLastError returns |
1881 |
*/ |
|
1882 |
#ifdef ERROR_INVALID_FUNCTION |
|
1883 |
if (sym == @symbol(ERROR_INVALID_FUNCTION)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1884 |
RETURN ( __MKSMALLINT(ERROR_INVALID_FUNCTION) ); |
6277 | 1885 |
} |
1886 |
#endif |
|
1887 |
#ifdef ERROR_BAD_FORMAT |
|
1888 |
if (sym == @symbol(ERROR_BAD_FORMAT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1889 |
RETURN ( __MKSMALLINT(ERROR_BAD_FORMAT) ); |
6277 | 1890 |
} |
1891 |
#endif |
|
1892 |
#ifdef ERROR_FILE_NOT_FOUND |
|
1893 |
if (sym == @symbol(ERROR_FILE_NOT_FOUND)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1894 |
RETURN ( __MKSMALLINT(ERROR_FILE_NOT_FOUND) ); |
6277 | 1895 |
} |
1896 |
#endif |
|
1897 |
#ifdef ERROR_PATH_NOT_FOUND |
|
1898 |
if (sym == @symbol(ERROR_PATH_NOT_FOUND)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1899 |
RETURN ( __MKSMALLINT(ERROR_PATH_NOT_FOUND) ); |
6277 | 1900 |
} |
1901 |
#endif |
|
1902 |
#ifdef ERROR_TOO_MANY_OPEN_FILES |
|
1903 |
if (sym == @symbol(ERROR_TOO_MANY_OPEN_FILES)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1904 |
RETURN ( __MKSMALLINT(ERROR_TOO_MANY_OPEN_FILES) ); |
6277 | 1905 |
} |
1906 |
#endif |
|
1907 |
#ifdef ERROR_OPEN_FAILED |
|
1908 |
if (sym == @symbol(ERROR_OPEN_FAILED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1909 |
RETURN ( __MKSMALLINT(ERROR_OPEN_FAILED) ); |
6277 | 1910 |
} |
1911 |
#endif |
|
1912 |
#ifdef ERROR_ACCESS_DENIED |
|
1913 |
if (sym == @symbol(ERROR_ACCESS_DENIED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1914 |
RETURN ( __MKSMALLINT(ERROR_ACCESS_DENIED) ); |
6277 | 1915 |
} |
1916 |
#endif |
|
1917 |
#ifdef ERROR_INVALID_HANDLE |
|
1918 |
if (sym == @symbol(ERROR_INVALID_HANDLE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1919 |
RETURN ( __MKSMALLINT(ERROR_INVALID_HANDLE) ); |
6277 | 1920 |
} |
1921 |
#endif |
|
1922 |
#ifdef ERROR_NOT_ENOUGH_MEMORY |
|
1923 |
if (sym == @symbol(ERROR_NOT_ENOUGH_MEMORY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1924 |
RETURN ( __MKSMALLINT(ERROR_NOT_ENOUGH_MEMORY) ); |
6277 | 1925 |
} |
1926 |
#endif |
|
1927 |
#ifdef ERROR_INVALID_ACCESS |
|
1928 |
if (sym == @symbol(ERROR_INVALID_ACCESS)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1929 |
RETURN ( __MKSMALLINT(ERROR_INVALID_ACCESS) ); |
6277 | 1930 |
} |
1931 |
#endif |
|
1932 |
#ifdef ERROR_INVALID_DATA |
|
1933 |
if (sym == @symbol(ERROR_INVALID_DATA)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1934 |
RETURN ( __MKSMALLINT(ERROR_INVALID_DATA) ); |
6277 | 1935 |
} |
1936 |
#endif |
|
1937 |
#ifdef ERROR_INVALID_NAME |
|
1938 |
if (sym == @symbol(ERROR_INVALID_NAME)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1939 |
RETURN ( __MKSMALLINT(ERROR_INVALID_NAME) ); |
6277 | 1940 |
} |
1941 |
#endif |
|
1942 |
#ifdef ERROR_ARENA_TRASHED |
|
1943 |
if (sym == @symbol(ERROR_ARENA_TRASHED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1944 |
RETURN ( __MKSMALLINT(ERROR_ARENA_TRASHED) ); |
6277 | 1945 |
} |
1946 |
#endif |
|
1947 |
#ifdef ERROR_OUTOFMEMORY |
|
1948 |
if (sym == @symbol(ERROR_OUTOFMEMORY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1949 |
RETURN ( __MKSMALLINT(ERROR_OUTOFMEMORY) ); |
6277 | 1950 |
} |
1951 |
#endif |
|
1952 |
#ifdef ERROR_BROKEN_PIPE |
|
1953 |
if (sym == @symbol(ERROR_BROKEN_PIPE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1954 |
RETURN ( __MKSMALLINT(ERROR_BROKEN_PIPE) ); |
6277 | 1955 |
} |
1956 |
#endif |
|
1957 |
#ifdef ERROR_GEN_FAILURE |
|
1958 |
if (sym == @symbol(ERROR_GEN_FAILURE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1959 |
RETURN ( __MKSMALLINT(ERROR_GEN_FAILURE) ); |
6277 | 1960 |
} |
1961 |
#endif |
|
1962 |
#ifdef ERROR_WRITE_PROTECT |
|
1963 |
if (sym == @symbol(ERROR_WRITE_PROTECT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1964 |
RETURN ( __MKSMALLINT(ERROR_WRITE_PROTECT) ); |
6277 | 1965 |
} |
1966 |
#endif |
|
1967 |
#ifdef ERROR_WRITE_FAULT |
|
1968 |
if (sym == @symbol(ERROR_WRITE_FAULT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1969 |
RETURN ( __MKSMALLINT(ERROR_WRITE_FAULT) ); |
6277 | 1970 |
} |
1971 |
#endif |
|
1972 |
#ifdef ERROR_READ_FAULT |
|
1973 |
if (sym == @symbol(ERROR_READ_FAULT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1974 |
RETURN ( __MKSMALLINT(ERROR_READ_FAULT) ); |
6277 | 1975 |
} |
1976 |
#endif |
|
1977 |
#ifdef ERROR_HANDLE_DISK_FULL |
|
1978 |
if (sym == @symbol(ERROR_HANDLE_DISK_FULL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1979 |
RETURN ( __MKSMALLINT(ERROR_HANDLE_DISK_FULL) ); |
6277 | 1980 |
} |
1981 |
#endif |
|
1982 |
#ifdef ERROR_DISK_FULL |
|
1983 |
if (sym == @symbol(ERROR_DISK_FULL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1984 |
RETURN ( __MKSMALLINT(ERROR_DISK_FULL) ); |
6277 | 1985 |
} |
1986 |
#endif |
|
1987 |
#ifdef ERROR_ERROR_SHARING_VIOLATION |
|
1988 |
if (sym == @symbol(ERROR_ERROR_SHARING_VIOLATION)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1989 |
RETURN ( __MKSMALLINT(ERROR_ERROR_SHARING_VIOLATION) ); |
6277 | 1990 |
} |
1991 |
#endif |
|
1992 |
#ifdef ERROR_LOCK_VIOLATION |
|
1993 |
if (sym == @symbol(ERROR_LOCK_VIOLATION)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1994 |
RETURN ( __MKSMALLINT(ERROR_LOCK_VIOLATION) ); |
6277 | 1995 |
} |
1996 |
#endif |
|
1997 |
#ifdef ERROR_INVALID_PARAMETER |
|
1998 |
if (sym == @symbol(ERROR_INVALID_PARAMETER)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
1999 |
RETURN ( __MKSMALLINT(ERROR_INVALID_PARAMETER) ); |
6277 | 2000 |
} |
2001 |
#endif |
|
2002 |
#ifdef ERROR_NET_WRITE_FAULT |
|
2003 |
if (sym == @symbol(ERROR_NET_WRITE_FAULT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2004 |
RETURN ( __MKSMALLINT(ERROR_NET_WRITE_FAULT) ); |
6277 | 2005 |
} |
2006 |
#endif |
|
2007 |
#ifdef ERROR_NOT_SUPPORTED |
|
2008 |
if (sym == @symbol(ERROR_NOT_SUPPORTED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2009 |
RETURN ( __MKSMALLINT(ERROR_NOT_SUPPORTED) ); |
6277 | 2010 |
} |
2011 |
#endif |
|
2012 |
#ifdef ERROR_REM_NOT_LIST |
|
2013 |
if (sym == @symbol(ERROR_REM_NOT_LIST)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2014 |
RETURN ( __MKSMALLINT(ERROR_REM_NOT_LIST) ); |
6277 | 2015 |
} |
2016 |
#endif |
|
2017 |
#ifdef ERROR_NETWORK_ACCESS_DENIED |
|
2018 |
if (sym == @symbol(ERROR_NETWORK_ACCESS_DENIED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2019 |
RETURN ( __MKSMALLINT(ERROR_NETWORK_ACCESS_DENIED) ); |
6277 | 2020 |
} |
2021 |
#endif |
|
2022 |
#ifdef ERROR_DUP_NAME |
|
2023 |
if (sym == @symbol(ERROR_DUP_NAME)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2024 |
RETURN ( __MKSMALLINT(ERROR_DUP_NAME) ); |
6277 | 2025 |
} |
2026 |
#endif |
|
2027 |
#ifdef ERROR_BAD_NETPATH |
|
2028 |
if (sym == @symbol(ERROR_BAD_NETPATH)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2029 |
RETURN ( __MKSMALLINT(ERROR_BAD_NETPATH) ); |
6277 | 2030 |
} |
2031 |
#endif |
|
2032 |
#ifdef ERROR_NETWORK_BUSY |
|
2033 |
if (sym == @symbol(ERROR_NETWORK_BUSY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2034 |
RETURN ( __MKSMALLINT(ERROR_NETWORK_BUSY) ); |
6277 | 2035 |
} |
2036 |
#endif |
|
2037 |
#ifdef ERROR_DRIVE_LOCKED |
|
2038 |
if (sym == @symbol(ERROR_DRIVE_LOCKED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2039 |
RETURN ( __MKSMALLINT(ERROR_DRIVE_LOCKED) ); |
6277 | 2040 |
} |
2041 |
#endif |
|
2042 |
#ifdef ERROR_INVALID_DRIVE |
|
2043 |
if (sym == @symbol(ERROR_INVALID_DRIVE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2044 |
RETURN ( __MKSMALLINT(ERROR_INVALID_DRIVE) ); |
6277 | 2045 |
} |
2046 |
#endif |
|
2047 |
#ifdef ERROR_WRONG_DISK |
|
2048 |
if (sym == @symbol(ERROR_WRONG_DISK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2049 |
RETURN ( __MKSMALLINT(ERROR_WRONG_DISK) ); |
6277 | 2050 |
} |
2051 |
#endif |
|
2052 |
#ifdef ERROR_CURRENT_DIRECTORY |
|
2053 |
if (sym == @symbol(ERROR_CURRENT_DIRECTORY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2054 |
RETURN ( __MKSMALLINT(ERROR_CURRENT_DIRECTORY) ); |
6277 | 2055 |
} |
2056 |
#endif |
|
2057 |
#ifdef ERROR_CANNOT_MAKE |
|
2058 |
if (sym == @symbol(ERROR_CANNOT_MAKE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2059 |
RETURN ( __MKSMALLINT(ERROR_CANNOT_MAKE) ); |
6277 | 2060 |
} |
2061 |
#endif |
|
2062 |
#ifdef ERROR_NO_MORE_FILES |
|
2063 |
if (sym == @symbol(ERROR_NO_MORE_FILES)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2064 |
RETURN ( __MKSMALLINT(ERROR_NO_MORE_FILES) ); |
6277 | 2065 |
} |
2066 |
#endif |
|
2067 |
#ifdef ERROR_NOT_READY |
|
2068 |
if (sym == @symbol(ERROR_NOT_READY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2069 |
RETURN ( __MKSMALLINT(ERROR_NOT_READY) ); |
6277 | 2070 |
} |
2071 |
#endif |
|
2072 |
#ifdef ERROR_NOT_DOS_DISK |
|
2073 |
if (sym == @symbol(ERROR_NOT_DOS_DISK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2074 |
RETURN ( __MKSMALLINT(ERROR_NOT_DOS_DISK) ); |
6277 | 2075 |
} |
2076 |
#endif |
|
2077 |
#ifdef ERROR_OUT_OF_PAPER |
|
2078 |
if (sym == @symbol(ERROR_OUT_OF_PAPER)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2079 |
RETURN ( __MKSMALLINT(ERROR_OUT_OF_PAPER) ); |
6277 | 2080 |
} |
2081 |
#endif |
|
2082 |
#ifdef ERROR_PRINTQ_FULL |
|
2083 |
if (sym == @symbol(ERROR_PRINTQ_FULL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2084 |
RETURN ( __MKSMALLINT(ERROR_PRINTQ_FULL) ); |
6277 | 2085 |
} |
2086 |
#endif |
|
2087 |
||
2088 |
/* |
|
5133 | 2089 |
* POSIX errnos - these should be defined |
2090 |
*/ |
|
2091 |
#ifdef EPERM |
|
2092 |
if (sym == @symbol(EPERM)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2093 |
RETURN ( __MKSMALLINT(EPERM) ); |
5133 | 2094 |
} |
2095 |
#endif |
|
2096 |
||
2097 |
#ifdef ENOENT |
|
2098 |
if (sym == @symbol(ENOENT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2099 |
RETURN ( __MKSMALLINT(ENOENT) ); |
5133 | 2100 |
} |
2101 |
#endif |
|
2102 |
||
2103 |
#ifdef ESRCH |
|
2104 |
if (sym == @symbol(ESRCH)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2105 |
RETURN ( __MKSMALLINT(ESRCH) ); |
5133 | 2106 |
} |
2107 |
#endif |
|
2108 |
||
2109 |
#ifdef EINTR |
|
2110 |
if (sym == @symbol(EINTR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2111 |
RETURN ( __MKSMALLINT(EINTR) ); |
5133 | 2112 |
} |
2113 |
#endif |
|
2114 |
||
2115 |
#ifdef EIO |
|
2116 |
if (sym == @symbol(EIO)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2117 |
RETURN ( __MKSMALLINT(EIO) ); |
5133 | 2118 |
} |
2119 |
#endif |
|
2120 |
||
2121 |
#ifdef ENXIO |
|
2122 |
if (sym == @symbol(ENXIO)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2123 |
RETURN ( __MKSMALLINT(ENXIO) ); |
5133 | 2124 |
} |
2125 |
#endif |
|
2126 |
||
2127 |
#ifdef E2BIG |
|
2128 |
if (sym == @symbol(E2BIG)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2129 |
RETURN ( __MKSMALLINT(E2BIG) ); |
5133 | 2130 |
} |
2131 |
#endif |
|
2132 |
||
2133 |
#ifdef ENOEXEC |
|
2134 |
if (sym == @symbol(ENOEXEC)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2135 |
RETURN ( __MKSMALLINT(ENOEXEC) ); |
5133 | 2136 |
} |
2137 |
#endif |
|
2138 |
||
2139 |
#ifdef EBADF |
|
2140 |
if (sym == @symbol(EBADF)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2141 |
RETURN ( __MKSMALLINT(EBADF) ); |
5133 | 2142 |
} |
2143 |
#endif |
|
2144 |
||
2145 |
#ifdef ECHILD |
|
2146 |
if (sym == @symbol(ECHILD)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2147 |
RETURN ( __MKSMALLINT(ECHILD) ); |
5133 | 2148 |
} |
2149 |
#endif |
|
2150 |
||
2151 |
#if defined(EAGAIN) |
|
2152 |
if (sym == @symbol(EAGAIN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2153 |
RETURN ( __MKSMALLINT(EAGAIN) ); |
5133 | 2154 |
} |
2155 |
#endif |
|
2156 |
||
2157 |
#ifdef ENOMEM |
|
2158 |
if (sym == @symbol(ENOMEM)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2159 |
RETURN ( __MKSMALLINT(ENOMEM) ); |
5133 | 2160 |
} |
2161 |
#endif |
|
2162 |
||
2163 |
#ifdef EACCES |
|
2164 |
if (sym == @symbol(EACCES)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2165 |
RETURN ( __MKSMALLINT(EACCES) ); |
5133 | 2166 |
} |
2167 |
#endif |
|
2168 |
||
2169 |
#ifdef EFAULT |
|
2170 |
if (sym == @symbol(EFAULT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2171 |
RETURN ( __MKSMALLINT(EFAULT) ); |
5133 | 2172 |
} |
2173 |
#endif |
|
2174 |
||
2175 |
#ifdef EBUSY |
|
2176 |
if (sym == @symbol(EBUSY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2177 |
RETURN ( __MKSMALLINT(EBUSY) ); |
5133 | 2178 |
} |
2179 |
#endif |
|
2180 |
||
2181 |
#ifdef EXDEV |
|
2182 |
if (sym == @symbol(EXDEV)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2183 |
RETURN ( __MKSMALLINT(EXDEV) ); |
5133 | 2184 |
} |
2185 |
#endif |
|
2186 |
||
2187 |
#ifdef ENODEV |
|
2188 |
if (sym == @symbol(ENODEV)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2189 |
RETURN ( __MKSMALLINT(ENODEV) ); |
5133 | 2190 |
} |
2191 |
#endif |
|
2192 |
||
2193 |
#ifdef ENOTDIR |
|
2194 |
if (sym == @symbol(ENOTDIR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2195 |
RETURN ( __MKSMALLINT(ENOTDIR) ); |
5133 | 2196 |
} |
2197 |
#endif |
|
2198 |
||
2199 |
#ifdef EISDIR |
|
2200 |
if (sym == @symbol(EISDIR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2201 |
RETURN ( __MKSMALLINT(EISDIR) ); |
5133 | 2202 |
} |
2203 |
#endif |
|
2204 |
||
2205 |
#ifdef EINVAL |
|
2206 |
if (sym == @symbol(EINVAL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2207 |
RETURN ( __MKSMALLINT(EINVAL) ); |
5133 | 2208 |
} |
2209 |
#endif |
|
2210 |
||
2211 |
#ifdef ENFILE |
|
2212 |
if (sym == @symbol(ENFILE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2213 |
RETURN ( __MKSMALLINT(ENFILE) ); |
5133 | 2214 |
} |
2215 |
#endif |
|
2216 |
||
2217 |
#ifdef EMFILE |
|
2218 |
if (sym == @symbol(EMFILE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2219 |
RETURN ( __MKSMALLINT(EMFILE) ); |
5133 | 2220 |
} |
2221 |
#endif |
|
2222 |
||
2223 |
#ifdef ENOTTY |
|
2224 |
if (sym == @symbol(ENOTTY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2225 |
RETURN ( __MKSMALLINT(ENOTTY) ); |
5133 | 2226 |
} |
2227 |
#endif |
|
2228 |
||
2229 |
#ifdef EFBIG |
|
2230 |
if (sym == @symbol(EFBIG)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2231 |
RETURN ( __MKSMALLINT(EFBIG) ); |
5133 | 2232 |
} |
2233 |
#endif |
|
2234 |
||
2235 |
#ifdef ENOSPC |
|
2236 |
if (sym == @symbol(ENOSPC)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2237 |
RETURN ( __MKSMALLINT(ENOSPC) ); |
5133 | 2238 |
} |
2239 |
#endif |
|
2240 |
||
2241 |
#ifdef ESPIPE |
|
2242 |
if (sym == @symbol(ESPIPE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2243 |
RETURN ( __MKSMALLINT(ESPIPE) ); |
5133 | 2244 |
} |
2245 |
#endif |
|
2246 |
||
2247 |
#ifdef EROFS |
|
2248 |
if (sym == @symbol(EROFS)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2249 |
RETURN ( __MKSMALLINT(EROFS) ); |
5133 | 2250 |
} |
2251 |
#endif |
|
2252 |
||
2253 |
#ifdef EMLINK |
|
2254 |
if (sym == @symbol(EMLINK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2255 |
RETURN ( __MKSMALLINT(EMLINK) ); |
5133 | 2256 |
} |
2257 |
#endif |
|
2258 |
||
2259 |
#ifdef EPIPE |
|
2260 |
if (sym == @symbol(EPIPE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2261 |
RETURN ( __MKSMALLINT(EPIPE) ); |
5133 | 2262 |
} |
2263 |
#endif |
|
2264 |
||
2265 |
#ifdef EDOM |
|
2266 |
if (sym == @symbol(EDOM)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2267 |
RETURN ( __MKSMALLINT(EDOM) ); |
5133 | 2268 |
} |
2269 |
#endif |
|
2270 |
||
2271 |
#ifdef ERANGE |
|
2272 |
if (sym == @symbol(ERANGE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2273 |
RETURN ( __MKSMALLINT(ERANGE) ); |
5133 | 2274 |
} |
2275 |
#endif |
|
2276 |
||
2277 |
#ifdef EDEADLK |
|
2278 |
if (sym == @symbol(EDEADLK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2279 |
RETURN ( __MKSMALLINT(EDEADLK) ); |
5133 | 2280 |
} |
2281 |
#endif |
|
2282 |
||
2283 |
#ifdef ENAMETOOLONG |
|
2284 |
if (sym == @symbol(ENAMETOOLONG)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2285 |
RETURN ( __MKSMALLINT(ENAMETOOLONG) ); |
5133 | 2286 |
} |
2287 |
#endif |
|
2288 |
||
2289 |
#ifdef ENOLCK |
|
2290 |
if (sym == @symbol(ENOLCK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2291 |
RETURN ( __MKSMALLINT(ENOLCK) ); |
5133 | 2292 |
} |
2293 |
#endif |
|
2294 |
||
2295 |
#ifdef ENOSYS |
|
2296 |
if (sym == @symbol(ENOSYS)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2297 |
RETURN ( __MKSMALLINT(ENOSYS) ); |
5133 | 2298 |
} |
2299 |
#endif |
|
2300 |
||
2301 |
#ifdef ENOTEMPTY |
|
2302 |
if (sym == @symbol(ENOTEMPTY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2303 |
RETURN ( __MKSMALLINT(ENOTEMPTY) ); |
5133 | 2304 |
} |
2305 |
#endif |
|
2306 |
||
2307 |
#ifdef EEXIST |
|
2308 |
if (sym == @symbol(EEXIST)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2309 |
RETURN ( __MKSMALLINT(EEXIST) ); |
5133 | 2310 |
} |
2311 |
#endif |
|
2312 |
||
2313 |
#ifdef EILSEQ |
|
2314 |
if (sym == @symbol(EILSEQ)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2315 |
RETURN ( __MKSMALLINT(EILSEQ) ); |
5133 | 2316 |
} |
2317 |
#endif |
|
2318 |
||
2319 |
/* |
|
2320 |
* XPG3 errnos - defined on most systems |
|
2321 |
*/ |
|
2322 |
#ifdef ENOTBLK |
|
2323 |
if (sym == @symbol(ENOTBLK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2324 |
RETURN ( __MKSMALLINT(ENOTBLK) ); |
5133 | 2325 |
} |
2326 |
#endif |
|
2327 |
||
2328 |
#ifdef ETXTBSY |
|
2329 |
if (sym == @symbol(ETXTBSY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2330 |
RETURN ( __MKSMALLINT(ETXTBSY) ); |
5133 | 2331 |
} |
2332 |
#endif |
|
2333 |
||
2334 |
/* |
|
2335 |
* some others |
|
2336 |
*/ |
|
2337 |
#ifdef EWOULDBLOCK |
|
2338 |
if (sym == @symbol(EWOULDBLOCK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2339 |
RETURN ( __MKSMALLINT(EWOULDBLOCK) ); |
5133 | 2340 |
} |
2341 |
#endif |
|
2342 |
||
2343 |
#ifdef ENOMSG |
|
2344 |
if (sym == @symbol(ENOMSG)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2345 |
RETURN ( __MKSMALLINT(ENOMSG) ); |
5133 | 2346 |
} |
2347 |
#endif |
|
2348 |
||
2349 |
#ifdef ELOOP |
|
2350 |
if (sym == @symbol(ELOOP)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2351 |
RETURN ( __MKSMALLINT(ELOOP) ); |
5133 | 2352 |
} |
2353 |
#endif |
|
2354 |
||
2355 |
/* |
|
2356 |
* some stream errors |
|
2357 |
*/ |
|
2358 |
#ifdef ETIME |
|
2359 |
if (sym == @symbol(ETIME)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2360 |
RETURN ( __MKSMALLINT(ETIME) ); |
5133 | 2361 |
} |
2362 |
#endif |
|
2363 |
||
2364 |
#ifdef ENOSR |
|
2365 |
if (sym == @symbol(ENOSR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2366 |
RETURN ( __MKSMALLINT(ENOSR) ); |
5133 | 2367 |
} |
2368 |
#endif |
|
2369 |
||
2370 |
#ifdef ENOSTR |
|
2371 |
if (sym == @symbol(ENOSTR)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2372 |
RETURN ( __MKSMALLINT(ENOSTR) ); |
5133 | 2373 |
} |
2374 |
#endif |
|
2375 |
||
2376 |
#ifdef ECOMM |
|
2377 |
if (sym == @symbol(ECOMM)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2378 |
RETURN ( __MKSMALLINT(ECOMM) ); |
5133 | 2379 |
} |
2380 |
#endif |
|
2381 |
||
2382 |
#ifdef EPROTO |
|
2383 |
if (sym == @symbol(EPROTO)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2384 |
RETURN ( __MKSMALLINT(EPROTO) ); |
5133 | 2385 |
} |
2386 |
#endif |
|
2387 |
||
2388 |
/* |
|
2389 |
* nfs errors |
|
2390 |
*/ |
|
2391 |
#ifdef ESTALE |
|
2392 |
if (sym == @symbol(ESTALE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2393 |
RETURN ( __MKSMALLINT(ESTALE) ); |
5133 | 2394 |
} |
2395 |
#endif |
|
2396 |
||
2397 |
#ifdef EREMOTE |
|
2398 |
if (sym == @symbol(EREMOTE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2399 |
RETURN ( __MKSMALLINT(EREMOTE) ); |
5133 | 2400 |
} |
2401 |
#endif |
|
2402 |
||
2403 |
/* |
|
2404 |
* some networking errors |
|
2405 |
*/ |
|
2406 |
#ifdef EINPROGRESS |
|
2407 |
if (sym == @symbol(EINPROGRESS)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2408 |
RETURN ( __MKSMALLINT(EINPROGRESS) ); |
5133 | 2409 |
} |
2410 |
#endif |
|
2411 |
||
2412 |
#ifdef EALREADY |
|
2413 |
if (sym == @symbol(EALREADY)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2414 |
RETURN ( __MKSMALLINT(EALREADY) ); |
5133 | 2415 |
} |
2416 |
#endif |
|
2417 |
||
2418 |
#ifdef ENOTSOCK |
|
2419 |
if (sym == @symbol(ENOTSOCK)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2420 |
RETURN ( __MKSMALLINT(ENOTSOCK) ); |
5133 | 2421 |
} |
2422 |
#endif |
|
2423 |
||
2424 |
#ifdef EDESTADDRREQ |
|
2425 |
if (sym == @symbol(EDESTADDRREQ)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2426 |
RETURN ( __MKSMALLINT(EDESTADDRREQ) ); |
5133 | 2427 |
} |
2428 |
#endif |
|
2429 |
||
2430 |
#ifdef EMSGSIZE |
|
2431 |
if (sym == @symbol(EMSGSIZE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2432 |
RETURN ( __MKSMALLINT(EMSGSIZE) ); |
5133 | 2433 |
} |
2434 |
#endif |
|
2435 |
||
2436 |
#ifdef EPROTOTYPE |
|
2437 |
if (sym == @symbol(EPROTOTYPE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2438 |
RETURN ( __MKSMALLINT(EPROTOTYPE) ); |
5133 | 2439 |
} |
2440 |
#endif |
|
2441 |
||
2442 |
#ifdef ENOPROTOOPT |
|
2443 |
if (sym == @symbol(ENOPROTOOPT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2444 |
RETURN ( __MKSMALLINT(ENOPROTOOPT) ); |
5133 | 2445 |
} |
2446 |
#endif |
|
2447 |
||
2448 |
#ifdef EPROTONOSUPPORT |
|
2449 |
if (sym == @symbol(EPROTONOSUPPORT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2450 |
RETURN ( __MKSMALLINT(EPROTONOSUPPORT) ); |
5133 | 2451 |
} |
2452 |
#endif |
|
2453 |
||
2454 |
#ifdef ESOCKTNOSUPPORT |
|
2455 |
if (sym == @symbol(ESOCKTNOSUPPORT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2456 |
RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) ); |
5133 | 2457 |
} |
2458 |
#endif |
|
2459 |
||
2460 |
#ifdef EOPNOTSUPP |
|
2461 |
if (sym == @symbol(EOPNOTSUPP)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2462 |
RETURN ( __MKSMALLINT(EOPNOTSUPP) ); |
5133 | 2463 |
} |
2464 |
#endif |
|
2465 |
||
2466 |
#ifdef EPFNOSUPPORT |
|
2467 |
if (sym == @symbol(EPFNOSUPPORT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2468 |
RETURN ( __MKSMALLINT(EPFNOSUPPORT) ); |
5133 | 2469 |
} |
2470 |
#endif |
|
2471 |
||
2472 |
#ifdef EAFNOSUPPORT |
|
2473 |
if (sym == @symbol(EAFNOSUPPORT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2474 |
RETURN ( __MKSMALLINT(EAFNOSUPPORT) ); |
5133 | 2475 |
} |
2476 |
#endif |
|
2477 |
||
2478 |
#ifdef EADDRINUSE |
|
2479 |
if (sym == @symbol(EADDRINUSE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2480 |
RETURN ( __MKSMALLINT(EADDRINUSE) ); |
5133 | 2481 |
} |
2482 |
#endif |
|
2483 |
||
2484 |
#ifdef EADDRNOTAVAIL |
|
2485 |
if (sym == @symbol(EADDRNOTAVAIL)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2486 |
RETURN ( __MKSMALLINT(EADDRNOTAVAIL) ); |
5133 | 2487 |
} |
2488 |
#endif |
|
2489 |
||
2490 |
#ifdef ETIMEDOUT |
|
2491 |
if (sym == @symbol(ETIMEDOUT)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2492 |
RETURN ( __MKSMALLINT(ETIMEDOUT) ); |
5133 | 2493 |
} |
2494 |
#endif |
|
2495 |
||
2496 |
#ifdef ECONNREFUSED |
|
2497 |
if (sym == @symbol(ECONNREFUSED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2498 |
RETURN ( __MKSMALLINT(ECONNREFUSED) ); |
5133 | 2499 |
} |
2500 |
#endif |
|
2501 |
||
2502 |
#ifdef ENETDOWN |
|
2503 |
if (sym == @symbol(ENETDOWN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2504 |
RETURN ( __MKSMALLINT(ENETDOWN) ); |
5133 | 2505 |
} |
2506 |
#endif |
|
2507 |
||
2508 |
#ifdef ENETUNREACH |
|
2509 |
if (sym == @symbol(ENETUNREACH)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2510 |
RETURN ( __MKSMALLINT(ENETUNREACH) ); |
5133 | 2511 |
} |
2512 |
#endif |
|
2513 |
||
2514 |
#ifdef ENETRESET |
|
2515 |
if (sym == @symbol(ENETRESET)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2516 |
RETURN ( __MKSMALLINT(ENETRESET) ); |
5133 | 2517 |
} |
2518 |
#endif |
|
2519 |
||
2520 |
#ifdef ECONNABORTED |
|
2521 |
if (sym == @symbol(ECONNABORTED)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2522 |
RETURN ( __MKSMALLINT(ECONNABORTED) ); |
5133 | 2523 |
} |
2524 |
#endif |
|
2525 |
||
2526 |
#ifdef ECONNRESET |
|
2527 |
if (sym == @symbol(ECONNRESET)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2528 |
RETURN ( __MKSMALLINT(ECONNRESET) ); |
5133 | 2529 |
} |
2530 |
#endif |
|
2531 |
||
2532 |
#ifdef EISCONN |
|
2533 |
if (sym == @symbol(EISCONN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2534 |
RETURN ( __MKSMALLINT(EISCONN) ); |
5133 | 2535 |
} |
2536 |
#endif |
|
2537 |
||
2538 |
#ifdef ENOTCONN |
|
2539 |
if (sym == @symbol(ENOTCONN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2540 |
RETURN ( __MKSMALLINT(ENOTCONN) ); |
5133 | 2541 |
} |
2542 |
#endif |
|
2543 |
||
2544 |
#ifdef ESHUTDOWN |
|
2545 |
if (sym == @symbol(ESHUTDOWN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2546 |
RETURN ( __MKSMALLINT(ESHUTDOWN) ); |
5133 | 2547 |
} |
2548 |
#endif |
|
2549 |
||
2550 |
#ifdef EHOSTDOWN |
|
2551 |
if (sym == @symbol(EHOSTDOWN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2552 |
RETURN ( __MKSMALLINT(EHOSTDOWN) ); |
5133 | 2553 |
} |
2554 |
#endif |
|
2555 |
||
2556 |
#ifdef EHOSTUNREACH |
|
2557 |
if (sym == @symbol(EHOSTUNREACH)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2558 |
RETURN ( __MKSMALLINT(EHOSTUNREACH) ); |
5133 | 2559 |
} |
2560 |
#endif |
|
2561 |
%}. |
|
2562 |
^ -1 |
|
2563 |
! ! |
|
2564 |
||
2565 |
!Win32OperatingSystem class methodsFor:'executing OS commands'! |
|
2566 |
||
7066 | 2567 |
canExecuteCommand:aCommandString |
2568 |
"return true, if the OS can execute aCommand." |
|
2569 |
||
2570 |
|fn| |
|
2571 |
||
2572 |
fn := aCommandString asFilename. |
|
2573 |
( #('com' 'exe') includes:fn suffix) ifFalse:[^ false]. |
|
2574 |
^ super canExecuteCommand:aCommandString |
|
2575 |
||
2576 |
" |
|
2577 |
OperatingSystem canExecuteCommand:'fooBar' |
|
2578 |
OperatingSystem canExecuteCommand:'ls' |
|
2579 |
OperatingSystem canExecuteCommand:'cvs' |
|
2580 |
OperatingSystem canExecuteCommand:'cvs.exe' |
|
2581 |
OperatingSystem canExecuteCommand:'C:\Dokumente und Einstellungen\penk\work\stx\projects\smalltalk\cvs.exe' |
|
2582 |
OperatingSystem canExecuteCommand:'C:\Windows\cvs.exe' |
|
2583 |
" |
|
2584 |
||
2585 |
"Created: 4.11.1995 / 19:13:54 / cg" |
|
2586 |
! |
|
2587 |
||
5133 | 2588 |
commandAndArgsForOSCommand:aCommandString |
2589 |
"get a shell and shell arguments for command execution" |
|
2590 |
||
2591 |
|shell args wDir path words hasRedirection| |
|
2592 |
||
2593 |
"/ |
|
2594 |
"/ 'x:\WINNT\System32\cmd /c <command>' |
|
2595 |
"/ or 'x:\WINDOWS\System32\cmd /c <command>' |
|
2596 |
"/ or 'x:\WINDOWS\System\cmd /c <command>' |
|
2597 |
"/ or whatever ... |
|
2598 |
"/ |
|
2599 |
||
2600 |
"/ to workaround a bug in win95's command.com |
|
2601 |
"/ (which always returns a 0-exit code |
|
2602 |
"/ - even if the command failed), |
|
2603 |
"/ Here, we see if the command is found along the path and |
|
2604 |
"/ call it directly if found. |
|
2605 |
"/ If not found, assume its a builtIn or batch command |
|
2606 |
"/ and pass it to command.com. |
|
2607 |
"/ Also use command.com, if any I/O redirection is |
|
2608 |
"/ involved, since that is (not yet) handled here. |
|
2609 |
"/ |
|
2610 |
"/ I know: this is a kludge but should work for now... |
|
2611 |
"/ ...this will change in an upcoming version to include |
|
2612 |
"/ command.com command-line parsing here (sigh). |
|
2613 |
||
7065 | 2614 |
hasRedirection := false. |
2615 |
(aCommandString isNil or:[aCommandString includesAny:'<>|']) ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2616 |
hasRedirection := true |
7065 | 2617 |
]. |
2618 |
||
7062 | 2619 |
self isMSWINDOWSNTlike ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2620 |
shell := self getEnvironment:'COMSPEC'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2621 |
shell isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2622 |
wDir := self getWindowsSystemDirectory asFilename. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2623 |
shell := (wDir construct:'cmd.exe'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2624 |
shell exists ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2625 |
shell := (wDir construct:'command.com'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2626 |
shell exists ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2627 |
self error:'no command.com available'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2628 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2629 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2630 |
shell := shell pathName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2631 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2632 |
aCommandString isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2633 |
^ Array with:nil with:shell |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2634 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2635 |
^ Array with:nil with:(shell , ' /c ' , aCommandString) |
5133 | 2636 |
]. |
2637 |
||
7065 | 2638 |
"/ I/O redirection is not yet handled directly |
2639 |
"/ fallBack to command.com (below) to do it. |
|
2640 |
||
2641 |
hasRedirection ifFalse:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2642 |
words := aCommandString asCollectionOfSubstringsSeparatedBy:Character space. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2643 |
args := ' '. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2644 |
words from:2 to:(words size) do:[:s | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2645 |
args := args , (s , ' '). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2646 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2647 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2648 |
path := self pathOfCommand:(words at:1). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2649 |
path notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2650 |
"/ execute the command directly - |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2651 |
"/ without going through command.com |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2652 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2653 |
self isMSWINDOWSNTlike ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2654 |
args := path , args. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2655 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2656 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2657 |
^ Array with:path with:args |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2658 |
]. |
5133 | 2659 |
]. |
2660 |
||
2661 |
"/ windows-NT (where command.com works) |
|
2662 |
"/ or I/O redirection or no executable was found |
|
2663 |
||
2664 |
shell := self getEnvironment:'COMSPEC'. |
|
2665 |
shell isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2666 |
wDir := self getWindowsSystemDirectory asFilename. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2667 |
shell := (wDir construct:'cmd.exe'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2668 |
shell exists ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2669 |
shell := (wDir construct:'command.com'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2670 |
shell exists ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2671 |
self error:'no command.com available'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2672 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2673 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2674 |
shell := shell pathName. |
5133 | 2675 |
]. |
2676 |
aCommandString isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2677 |
^ Array with:shell with:shell |
5133 | 2678 |
]. |
2679 |
^ Array with:shell with:(shell , ' /c ' , aCommandString) |
|
2680 |
||
2681 |
"Modified: / 20.1.1998 / 16:57:19 / md" |
|
2682 |
"Modified: / 19.5.1999 / 10:01:24 / cg" |
|
2683 |
! |
|
2684 |
||
7080
a82683bc1843
Cleanup closeDescriptor handling in exec:withArguments:...
Stefan Vogel <sv@exept.de>
parents:
7077
diff
changeset
|
2685 |
exec:aCommandPath withArguments:argString environment:environment fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inDirectory:aDirectory |
7062 | 2686 |
"Internal lowLevel entry for combined fork & exec for WIN32 |
2687 |
||
2688 |
If fork is false (chain a command): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2689 |
execute the OS command specified by the argument, aCommandPath, with |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2690 |
arguments in argArray (no arguments, if nil). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2691 |
If successful, this method does not return and smalltalk is gone. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2692 |
If not successful, it does return. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2693 |
Normal use is with forkForCommand. |
7062 | 2694 |
|
2695 |
If fork is true (subprocess command execution): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2696 |
fork a child to do the above. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2697 |
The process id of the child process is returned; nil if the fork failed. |
7062 | 2698 |
|
2699 |
fdArray contains the filedescriptors, to be used for the child (if fork is true). |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2700 |
fdArray[1] = 15 -> use fd 15 as stdin. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2701 |
If an element of the array is set to nil, the corresponding filedescriptor |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2702 |
will be closed for the child. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2703 |
fdArray[0] == StdIn for child |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2704 |
fdArray[1] == StdOut for child |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2705 |
fdArray[2] == StdErr for child |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2706 |
on VMS, these must be channels as returned by createMailBox. |
7062 | 2707 |
|
2708 |
NOTE that in WIN32 the fds are HANDLES. |
|
2709 |
||
2710 |
If newPgrp is true, the subprocess will be established in a new process group. |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2711 |
The processgroup will be equal to id. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2712 |
newPgrp is not used on WIN32 and VMS systems." |
7062 | 2713 |
|
2714 |
|dirPath cmdPath cmdLine| |
|
2715 |
||
2716 |
aDirectory notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2717 |
dirPath := aDirectory asFilename asAbsoluteFilename osNameForDirectory. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2718 |
(dirPath endsWith:':') ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2719 |
dirPath := dirPath , '\'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2720 |
]. |
7062 | 2721 |
]. |
2722 |
||
2723 |
self isMSWINDOWSNTlike ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2724 |
cmdPath := aCommandPath. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2725 |
cmdLine := argString |
7062 | 2726 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2727 |
cmdPath := 'stxspawn.exe'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2728 |
cmdLine := 'stxspawn.exe ' , aCommandPath , ' ' , argString |
7062 | 2729 |
]. |
2730 |
||
2731 |
^ self |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2732 |
primExec:cmdPath |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2733 |
commandLine:cmdLine |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2734 |
fileDescriptors:fdArray |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2735 |
fork:doFork |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2736 |
newPgrp:newPgrp |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2737 |
inPath:dirPath |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2738 |
createFlags:nil |
7062 | 2739 |
|
2740 |
"Modified: / 31.1.1998 / 10:54:24 / md" |
|
2741 |
"Modified: / 15.5.1999 / 18:07:51 / cg" |
|
2742 |
! |
|
2743 |
||
5133 | 2744 |
getStatusOfProcess:aProcessId |
2745 |
"wait for a process to terminate and fetch its exit status. |
|
2746 |
This is required to avoid zombie processes." |
|
2747 |
||
2748 |
%{ |
|
2749 |
DWORD endStatus; |
|
2750 |
int status = -1; |
|
2751 |
||
2752 |
if (__isExternalAddress(aProcessId)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2753 |
HANDLE handle = _HANDLEVal(aProcessId); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2754 |
if (handle) { |
5133 | 2755 |
#ifdef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2756 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2757 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2758 |
endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, handle, INFINITE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2759 |
} while ((endStatus < 0) && (__threadErrno == EINTR)); |
5133 | 2760 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2761 |
endStatus = WaitForSingleObject(handle , INFINITE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2762 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2763 |
if (endStatus != WAIT_FAILED) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2764 |
if (GetExitCodeProcess(handle,&endStatus)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2765 |
status = endStatus; |
5133 | 2766 |
#ifdef PROCESSDEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2767 |
fprintf(stderr, "getexitcode status = %d\n",status); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2768 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2769 |
fprintf(stderr, "getexitcode failed.\n"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2770 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2771 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2772 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2773 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2774 |
RETURN ( __MKSMALLINT(status)); |
5133 | 2775 |
} |
2776 |
%}. |
|
2777 |
self primitiveFailed |
|
2778 |
! |
|
2779 |
||
2780 |
pathOfCommand:aCommand |
|
2781 |
"find where aCommand's executable file is; |
|
2782 |
return its full pathName if there is such a command, otherwise |
|
2783 |
return nil." |
|
2784 |
||
2785 |
|path f fExt| |
|
2786 |
||
2787 |
aCommand asFilename isAbsolute ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2788 |
aCommand asFilename exists ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2789 |
^ aCommand |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2790 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2791 |
^ nil |
5133 | 2792 |
]. |
2793 |
||
2794 |
path := self getEnvironment:'PATH'. |
|
2795 |
path notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2796 |
(path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2797 |
path isEmpty ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2798 |
f := aCommand asFilename |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2799 |
] ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2800 |
f := path asFilename construct:aCommand. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2801 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2802 |
self executableFileExtensions do:[:ext | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2803 |
ext notEmpty ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2804 |
fExt := (f pathName , '.' , ext) asFilename. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2805 |
] ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2806 |
fExt := f. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2807 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2808 |
fExt isExecutable ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2809 |
^ fExt pathName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2810 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2811 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
2812 |
]. |
5133 | 2813 |
]. |
2814 |
^ nil |
|
2815 |
||
2816 |
"windows: |
|
2817 |
||
2818 |
OperatingSystem pathOfCommand:'bcc32' |
|
2819 |
" |
|
2820 |
||
2821 |
"Modified: / 10.9.1998 / 17:51:49 / cg" |
|
2822 |
! |
|
2823 |
||
7080
a82683bc1843
Cleanup closeDescriptor handling in exec:withArguments:...
Stefan Vogel <sv@exept.de>
parents:
7077
diff
changeset
|
2824 |
primExec:commandPath commandLine:commandLine fileDescriptors:fdArray fork:doFork newPgrp:newPgrp inPath:dirName createFlags:flagsOrNil |
5133 | 2825 |
"Internal lowLevel entry for combined fork & exec for WIN32" |
2826 |
%{ |
|
2827 |
||
2828 |
/* |
|
2829 |
* if fork is false, chain to another command (not yet supported) |
|
2830 |
* otherwise, spawn a subprocess and let it execute the command. |
|
2831 |
* Currently, only the forking version is supported (who chains anyway ?) |
|
2832 |
*/ |
|
2833 |
#if 0 |
|
2834 |
char fullCmdPathBuffer[1024]; |
|
2835 |
char fullCmdLine[1024]; |
|
2836 |
char fullDirName[1024]; |
|
2837 |
char *fullCmdPath = fullCmdPathBuffer; |
|
2838 |
#else |
|
2839 |
char *cmdPath = 0; |
|
2840 |
char *cmdLine = 0; |
|
2841 |
#endif |
|
2842 |
char *dir = 0; |
|
2843 |
DWORD fdwCreate = 0; |
|
2844 |
STARTUPINFO lpsiStartInfo; |
|
2845 |
PROCESS_INFORMATION lppiProcInfo; |
|
7070 | 2846 |
SECURITY_ATTRIBUTES sa; |
5133 | 2847 |
|
2848 |
if (__isString(dirName)) { |
|
7118 | 2849 |
dir = __stringVal(dirName); |
5133 | 2850 |
} |
2851 |
if ((__isString(commandPath) || (commandPath == nil)) |
|
2852 |
&& __isString(commandLine)) { |
|
2853 |
#if 0 |
|
7118 | 2854 |
/* |
2855 |
* generate command line (cmd plus args) |
|
2856 |
*/ |
|
2857 |
if (__isWinNT) { |
|
2858 |
char *d; |
|
2859 |
||
2860 |
strcpy(fullCmdPath, __stringVal(aCommandPath)); |
|
2861 |
d = strchr(fullCmdPath,' '); |
|
2862 |
if (d) { |
|
2863 |
*d++ = 0; |
|
2864 |
strcpy(fullCmdLine, d); |
|
2865 |
} else { |
|
2866 |
fullCmdLine[0] = '\0'; |
|
2867 |
} |
|
2868 |
} else { |
|
2869 |
//fullCmdPath = 0; |
|
2870 |
strcpy(fullCmdPath,"stxspawn.exe"); |
|
2871 |
strcpy(fullCmdLine,"stxspawn.exe "); |
|
2872 |
strcat(fullCmdLine, __stringVal(aCommandPath)); |
|
2873 |
} |
|
2874 |
||
2875 |
if (__isString(argArray)) { |
|
2876 |
if (strlen(fullCmdLine) > 0) { |
|
2877 |
strcat(fullCmdLine, " "); |
|
2878 |
} |
|
2879 |
strcat(fullCmdLine, __stringVal(argArray)); |
|
2880 |
} else { |
|
2881 |
int i; |
|
2882 |
||
2883 |
for (i=0; i<__arraySize(argArray); i++) { |
|
2884 |
OBJ arg = __ArrayInstPtr(argArray)->a_element[i]; |
|
2885 |
||
2886 |
if (__isString(arg)) { |
|
2887 |
strcat(fullCmdLine, " "); |
|
2888 |
strcat(fullCmdLine, __stringVal(arg)); |
|
2889 |
} else { |
|
2890 |
/* ignore */ |
|
2891 |
fprintf(stderr, "bad (non-string) arg\n"); |
|
2892 |
} |
|
2893 |
} |
|
2894 |
} |
|
2895 |
#endif |
|
2896 |
if (commandPath != nil) { |
|
2897 |
cmdPath = __stringVal(commandPath); |
|
2898 |
} |
|
2899 |
cmdLine = __stringVal(commandLine); |
|
2900 |
||
2901 |
/* |
|
2902 |
* create descriptors as req'd |
|
2903 |
*/ |
|
2904 |
sa.nLength = sizeof( sa ); |
|
2905 |
sa.lpSecurityDescriptor = NULL; |
|
2906 |
sa.bInheritHandle = TRUE; |
|
2907 |
||
2908 |
memset(&lppiProcInfo, 0, sizeof (lppiProcInfo)); |
|
2909 |
||
2910 |
memset(&lpsiStartInfo, 0, sizeof (lpsiStartInfo)); |
|
2911 |
lpsiStartInfo.cb = sizeof(lpsiStartInfo); |
|
2912 |
lpsiStartInfo.lpReserved = NULL; |
|
2913 |
lpsiStartInfo.lpDesktop = NULL; |
|
2914 |
lpsiStartInfo.lpTitle = NULL; |
|
2915 |
lpsiStartInfo.dwX = 0; |
|
2916 |
lpsiStartInfo.dwY = 0; |
|
2917 |
lpsiStartInfo.dwXSize = 100; |
|
2918 |
lpsiStartInfo.dwYSize = 100; |
|
2919 |
lpsiStartInfo.dwXCountChars = 0; |
|
2920 |
lpsiStartInfo.dwYCountChars = 0; |
|
2921 |
lpsiStartInfo.dwFillAttribute = 0; |
|
2922 |
if (0 /*__isWinNT*/) { |
|
2923 |
lpsiStartInfo.dwFlags = STARTF_USESTDHANDLES; |
|
2924 |
lpsiStartInfo.wShowWindow = SW_SHOWDEFAULT; |
|
2925 |
} else { |
|
2926 |
lpsiStartInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES /*| STARTF_USEPOSITION*/; |
|
2927 |
lpsiStartInfo.wShowWindow = SW_HIDE /*SW_SHOWDEFAULT*/; |
|
2928 |
} |
|
2929 |
lpsiStartInfo.cbReserved2 = 0; |
|
2930 |
lpsiStartInfo.lpReserved2 = NULL; |
|
2931 |
lpsiStartInfo.hStdInput = NULL; |
|
2932 |
lpsiStartInfo.hStdOutput = NULL; |
|
2933 |
lpsiStartInfo.hStdError = NULL; |
|
2934 |
||
2935 |
/* |
|
2936 |
* set create process flags |
|
2937 |
* if the flags arg is nil, use common defaults; |
|
2938 |
* if non-nil, it must be a positive integer containing the fdwCreate bits. |
|
2939 |
*/ |
|
2940 |
if (flagsOrNil != nil) { |
|
2941 |
fdwCreate = __longIntVal(flagsOrNil); |
|
2942 |
} else { |
|
2943 |
if (0 /* __isWinNT */) |
|
2944 |
fdwCreate = 0; //IDLE_PRIORITY_CLASS; |
|
2945 |
else |
|
2946 |
fdwCreate = CREATE_NEW_CONSOLE; //|IDLE_PRIORITY_CLASS; // DETACHED_PROCESS; // NORMAL_PRIORITY_CLASS ; |
|
2947 |
||
2948 |
if (newPgrp == true) { |
|
2949 |
fdwCreate |= CREATE_NEW_PROCESS_GROUP; |
|
2950 |
} |
|
2951 |
} |
|
2952 |
||
2953 |
if (fdArray == nil) { |
|
2954 |
lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (0); |
|
2955 |
lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (1); |
|
2956 |
lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (2); |
|
2957 |
} else if (__isArray(fdArray) && (__arraySize(fdArray) >= 3)) { |
|
2958 |
if (__ArrayInstPtr(fdArray)->a_element[0] != nil) { |
|
2959 |
if (__isExternalAddress(__ArrayInstPtr(fdArray)->a_element[0])) { |
|
2960 |
lpsiStartInfo.hStdInput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[0]); |
|
2961 |
} else { |
|
2962 |
lpsiStartInfo.hStdInput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[0])); |
|
2963 |
} |
|
2964 |
} |
|
2965 |
if (__ArrayInstPtr(fdArray)->a_element[1] != nil) { |
|
2966 |
if (__isExternalAddress(__ArrayInstPtr(fdArray)->a_element[1])) { |
|
2967 |
lpsiStartInfo.hStdOutput = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[1]); |
|
2968 |
} else { |
|
2969 |
lpsiStartInfo.hStdOutput = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[1])); |
|
2970 |
} |
|
2971 |
} |
|
2972 |
if (__ArrayInstPtr(fdArray)->a_element[2] != nil) { |
|
2973 |
if (__isExternalAddress(__ArrayInstPtr(fdArray)->a_element[2])) { |
|
2974 |
lpsiStartInfo.hStdError = _HANDLEVal(__ArrayInstPtr(fdArray)->a_element[2]); |
|
2975 |
} else { |
|
2976 |
lpsiStartInfo.hStdError = (HANDLE) _get_osfhandle (__intVal(__ArrayInstPtr(fdArray)->a_element[2])); |
|
2977 |
} |
|
2978 |
} |
|
5133 | 2979 |
#ifdef PROCESSDEBUGWIN32 |
7118 | 2980 |
fprintf(stderr, "stdin %x\n", lpsiStartInfo.hStdInput); |
2981 |
fprintf(stderr, "stdout %x\n",lpsiStartInfo.hStdOutput); |
|
2982 |
fprintf(stderr, "stderr %x\n",lpsiStartInfo.hStdError); |
|
2983 |
#endif |
|
2984 |
} else { |
|
2985 |
fprintf(stderr, "Win32OS: bad fd arg in createProcess\n"); |
|
2986 |
} |
|
2987 |
||
2988 |
if (doFork == true) { |
|
5133 | 2989 |
#ifdef PROCESSDEBUGWIN32 |
7118 | 2990 |
fprintf(stderr, "create process cmdPath:<%s> cmdLine:<%s> in <%s>\n", cmdPath, cmdLine, dir); |
2991 |
#endif |
|
2992 |
if (CreateProcess( cmdPath, |
|
2993 |
cmdLine, |
|
2994 |
&sa, &sa, /* sec-attribs */ |
|
2995 |
sa.bInheritHandle, /* inherit handles */ |
|
2996 |
fdwCreate, |
|
2997 |
NULL, /* env */ |
|
2998 |
dir, |
|
2999 |
&lpsiStartInfo, |
|
3000 |
&lppiProcInfo )) |
|
3001 |
{ |
|
3002 |
CloseHandle(lppiProcInfo.hThread); |
|
5133 | 3003 |
#ifdef PROCESSDEBUGWIN32 |
7118 | 3004 |
fprintf(stderr, "created process hProcess=%x\n", lppiProcInfo.hProcess); |
3005 |
#endif |
|
3006 |
RETURN (__MKEXTERNALADDRESS(lppiProcInfo.hProcess)); |
|
3007 |
} |
|
5133 | 3008 |
#ifdef PROCESSDEBUGWIN32 |
7118 | 3009 |
fprintf(stderr, "created process error %d\n", GetLastError()); |
3010 |
#endif |
|
3011 |
RETURN (nil); |
|
3012 |
} else { |
|
3013 |
; /* should never be called that way */ |
|
3014 |
} |
|
5133 | 3015 |
} |
3016 |
%}. |
|
3017 |
" |
|
3018 |
path-argument not string |
|
3019 |
or argArray not an array/nil |
|
3020 |
or malloc failed |
|
3021 |
or not supported by OS |
|
3022 |
" |
|
3023 |
^ self primitiveFailed |
|
3024 |
! |
|
3025 |
||
7158 | 3026 |
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream auxFrom:anExternalAuxStream inDirectory:dirOrNil |
5133 | 3027 |
"start executing the OS command as specified by the argument, aCommandString |
3028 |
as a separate process; do not wait for the command to finish. |
|
3029 |
The commandString is passed to a shell for execution - see the description of |
|
3030 |
'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual). |
|
3031 |
The command gets stdIn, stdOut and stdErr assigned from the arguments; |
|
3032 |
each may be nil. |
|
3033 |
Return the processId if successful, nil otherwise. |
|
3034 |
Use #monitorPid:action: for synchronization and exec status return, |
|
3035 |
or #killProcess: to stop it." |
|
3036 |
||
3037 |
|ret in out err shellAndArgs errStream outStream inStream| |
|
3038 |
||
3039 |
aCommandString isNil ifTrue:[^ nil]. |
|
3040 |
||
3041 |
anExternalInStream notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3042 |
in := anExternalInStream fileDescriptor. |
5133 | 3043 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3044 |
self isMSWINDOWSNTlike ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3045 |
inStream := 'nul' asFilename readStream. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3046 |
inStream notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3047 |
in := inStream fileDescriptor. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3048 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3049 |
] |
5133 | 3050 |
]. |
3051 |
anExternalOutStream notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3052 |
out := anExternalOutStream fileDescriptor. |
5133 | 3053 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3054 |
self isMSWINDOWSNTlike ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3055 |
outStream := 'nul' asFilename writeStream. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3056 |
outStream notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3057 |
out := outStream fileDescriptor. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3058 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3059 |
] |
5133 | 3060 |
]. |
3061 |
anExternalErrStream notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3062 |
err := anExternalErrStream fileDescriptor. |
5133 | 3063 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3064 |
self isMSWINDOWSNTlike ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3065 |
errStream := 'nul' asFilename writeStream. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3066 |
errStream notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3067 |
err := errStream fileDescriptor. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3068 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3069 |
] |
5133 | 3070 |
]. |
7158 | 3071 |
anExternalAuxStream notNil ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3072 |
self error:'Aux stream is not supported in Windows' mayProceed:true. |
7158 | 3073 |
]. |
5133 | 3074 |
|
3075 |
shellAndArgs := self commandAndArgsForOSCommand:aCommandString. |
|
3076 |
ret := self |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3077 |
exec:(shellAndArgs at:1) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3078 |
withArguments:(shellAndArgs at:2) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3079 |
environment:nil |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3080 |
fileDescriptors:(Array with:in with:out with:err) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3081 |
fork:true |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3082 |
newPgrp:false |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3083 |
inDirectory:dirOrNil. |
5133 | 3084 |
|
3085 |
inStream notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3086 |
inStream close |
5133 | 3087 |
]. |
3088 |
outStream notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3089 |
outStream close |
5133 | 3090 |
]. |
3091 |
errStream notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3092 |
errStream close |
5133 | 3093 |
]. |
3094 |
^ ret |
|
3095 |
||
3096 |
"Created: / 10.11.1998 / 20:48:35 / cg" |
|
3097 |
"Modified: / 19.5.1999 / 10:43:01 / cg" |
|
3098 |
! ! |
|
3099 |
||
3100 |
!Win32OperatingSystem class methodsFor:'file access'! |
|
3101 |
||
3102 |
closeFd:anInteger |
|
3103 |
"low level close of a filedescriptor" |
|
3104 |
||
3105 |
%{ |
|
3106 |
if (__isExternalAddress(anInteger) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3107 |
if( !CloseHandle( anInteger ) ) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3108 |
fprintf( stderr, "Could not close handle : %d\n", anInteger); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3109 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3110 |
RETURN(self); |
5133 | 3111 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3112 |
if (__isSmallInteger(anInteger)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3113 |
close(__intVal(anInteger)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3114 |
RETURN(self); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3115 |
} |
5133 | 3116 |
} |
3117 |
%}. |
|
3118 |
^ self primitiveFailed. |
|
3119 |
! |
|
3120 |
||
3121 |
createDirectory:aPathName |
|
3122 |
"create a new directory with name 'aPathName', which may be an absolute |
|
3123 |
path, or relative to the current directory. |
|
3124 |
Return true if successful (or the directory existed already), false if failed. |
|
3125 |
This is a low-level entry - use Filename protocol for compatibility." |
|
3126 |
||
3127 |
"/ if it already exists this is ok |
|
3128 |
||
3129 |
(self isDirectory:aPathName) ifTrue:[^ true]. |
|
3130 |
||
3131 |
%{ |
|
3132 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3133 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3134 |
SECURITY_ATTRIBUTES sa; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3135 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3136 |
sa.nLength = sizeof( sa ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3137 |
sa.lpSecurityDescriptor = NULL; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3138 |
sa.bInheritHandle = TRUE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3139 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3140 |
ret = CreateDirectory(__stringVal(aPathName), &sa); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3141 |
if (ret != TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3142 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3143 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3144 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3145 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3146 |
RETURN (true); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
3147 |
} |
5133 | 3148 |
%}. |
3149 |
self primitiveFailed |
|
3150 |
||
3151 |
" |
|
3152 |
OperatingSystem createDirectory:'foo' |
|
3153 |
" |
|
3154 |
||
3155 |
"Modified: 20.12.1995 / 11:24:13 / stefan" |
|
3156 |
"Modified: 29.6.1996 / 14:06:54 / cg" |
|
3157 |
! |
|
3158 |
||
6293 | 3159 |
createFileForReadAppend:pathName |
3160 |
^ self openFile:pathName attributes:#(#'GENERIC_READ' #'GENERIC_WRITE') |
|
3161 |
! |
|
3162 |
||
3163 |
createFileForReadWrite:pathName |
|
6297 | 3164 |
^ self openFile:pathName attributes:#(#'GENERIC_READ' #'GENERIC_WRITE' #'CREATE_ALWAYS') |
6293 | 3165 |
! |
3166 |
||
5133 | 3167 |
linkFile:oldPath to:newPath |
3168 |
"link the file 'oldPath' to 'newPath'. The link will be a hard link. |
|
3169 |
Return true if successful, false if not." |
|
3170 |
||
3171 |
(oldPath isString not or:[newPath isString not]) ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3172 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3173 |
"/ bad argument(s) given |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3174 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3175 |
^ self primitiveFailed |
5133 | 3176 |
]. |
3177 |
||
3178 |
"/ |
|
3179 |
"/ this OperatingSystem does not support links |
|
3180 |
"/ |
|
3181 |
^ UnsupportedOperationSignal raise |
|
3182 |
||
3183 |
" |
|
3184 |
OperatingSystem linkFile:'foo' to:'bar' |
|
3185 |
" |
|
3186 |
! |
|
3187 |
||
6293 | 3188 |
openFile:pathName attributes:attributeSpec |
3189 |
"non public internal helper. |
|
3190 |
open a file, return an os specific fileHandle. |
|
3191 |
attributes is a collection of symbols specifying how the file is |
|
3192 |
to be opened." |
|
3193 |
||
6297 | 3194 |
|fileHandle errorNumber argumentError| |
6293 | 3195 |
|
3196 |
fileHandle := Win32Handle new. |
|
3197 |
||
3198 |
%{ |
|
3199 |
HANDLE h; |
|
3200 |
char *name; |
|
3201 |
OBJ *ap = __ArrayInstPtr(attributeSpec)->a_element; |
|
3202 |
int numAttrib = __arraySize(attributeSpec); |
|
3203 |
int i; |
|
3204 |
DWORD access, share, create, attr; |
|
3205 |
||
3206 |
if (! __isString(pathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3207 |
fileHandle = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3208 |
argumentError = @symbol(badPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3209 |
goto badArgument; |
6293 | 3210 |
} |
3211 |
if (! __isArray(attributeSpec)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3212 |
fileHandle = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3213 |
argumentError = @symbol(badAttributeSpec); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3214 |
goto badArgument; |
6293 | 3215 |
} |
3216 |
||
3217 |
name = __stringVal(pathName); |
|
3218 |
||
3219 |
share = 0; |
|
3220 |
access = 0; |
|
3221 |
create = 0; |
|
3222 |
attr = 0; |
|
3223 |
||
3224 |
for (i=0; i<numAttrib;i++) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3225 |
OBJ attrSym = ap[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3226 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3227 |
if (attrSym == @symbol(FILE_SHARE_READ)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3228 |
share |= FILE_SHARE_READ; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3229 |
} else if (attrSym == @symbol(FILE_SHARE_WRITE)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3230 |
share |= FILE_SHARE_WRITE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3231 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3232 |
} else if (attrSym == @symbol(GENERIC_READ)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3233 |
access |= GENERIC_READ; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3234 |
} else if (attrSym == @symbol(GENERIC_WRITE)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3235 |
access |= GENERIC_WRITE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3236 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3237 |
} else if (attrSym == @symbol(CREATE_NEW)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3238 |
create |= CREATE_NEW; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3239 |
} else if (attrSym == @symbol(CREATE_ALWAYS)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3240 |
create |= CREATE_ALWAYS; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3241 |
} else if (attrSym == @symbol(OPEN_EXISTING)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3242 |
create |= OPEN_EXISTING; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3243 |
} else if (attrSym == @symbol(OPEN_ALWAYS)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3244 |
create |= OPEN_ALWAYS; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3245 |
} else if (attrSym == @symbol(TRUNCATE_EXISTING)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3246 |
create |= TRUNCATE_EXISTING; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3247 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3248 |
} else if (attrSym == @symbol(FILE_ATTRIBUTE_HIDDEN)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3249 |
attr |= FILE_ATTRIBUTE_HIDDEN; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3250 |
} else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3251 |
attr |= FILE_ATTRIBUTE_READONLY; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3252 |
} else if (attrSym == @symbol(FILE_ATTRIBUTE_READONLY)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3253 |
attr |= FILE_ATTRIBUTE_READONLY; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3254 |
} else if (attrSym == @symbol(FILE_FLAG_WRITE_THROUGH)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3255 |
attr |= FILE_FLAG_WRITE_THROUGH; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3256 |
} else if (attrSym == @symbol(FILE_FLAG_SEQUENTIAL_SCAN)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3257 |
attr |= FILE_FLAG_SEQUENTIAL_SCAN; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3258 |
} else if (attrSym == @symbol(FILE_FLAG_DELETE_ON_CLOSE)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3259 |
attr |= FILE_FLAG_DELETE_ON_CLOSE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3260 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3261 |
fprintf(stderr, "Win32OS [warning]: unsupported open mode\n"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3262 |
} |
6293 | 3263 |
} |
6297 | 3264 |
if (create == 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3265 |
fileHandle = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3266 |
argumentError = @symbol(missingCreateMode); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3267 |
goto badArgument; |
6297 | 3268 |
} |
6293 | 3269 |
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
|
3270 |
name, access, share, create, attr); |
6293 | 3271 |
|
3272 |
h = CreateFile(name, access, share, 0 /* sa */, create, attr, 0 /* hTempl */); |
|
3273 |
if (h != INVALID_HANDLE_VALUE) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3274 |
__externalAddressVal(fileHandle) = (void *)h; |
6293 | 3275 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3276 |
fileHandle = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3277 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
6293 | 3278 |
} |
3279 |
||
3280 |
badArgument: ; |
|
3281 |
%}. |
|
3282 |
fileHandle notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3283 |
fileHandle registerForFinalization. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3284 |
^ fileHandle. |
6293 | 3285 |
]. |
3286 |
errorNumber isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3287 |
self error:'invalid argument(s): ', argumentError. |
6293 | 3288 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3289 |
(self errorHolderForNumber:errorNumber) reportError |
6293 | 3290 |
]. |
3291 |
self halt. |
|
3292 |
! |
|
3293 |
||
3294 |
openFileForAppend:pathName |
|
3295 |
^ self halt |
|
3296 |
! |
|
3297 |
||
3298 |
openFileForRead:pathName |
|
6297 | 3299 |
^ self openFile:pathName attributes:#(#'GENERIC_READ' #'OPEN_EXISTING') |
6293 | 3300 |
! |
3301 |
||
3302 |
openFileForReadAppend:pathName |
|
3303 |
^ self halt |
|
3304 |
! |
|
3305 |
||
3306 |
openFileForReadWrite:pathName |
|
3307 |
^ self openFile:pathName attributes:#(#'GENERIC_READ' #'GENERIC_WRITE') |
|
3308 |
! |
|
3309 |
||
3310 |
openFileForWrite:pathName |
|
6304 | 3311 |
^ self openFile:pathName attributes:#(#'GENERIC_WRITE' #'OPEN_EXISTING') |
6293 | 3312 |
! |
3313 |
||
5133 | 3314 |
recursiveCopyDirectory:sourcePathName to:destination |
3315 |
"copy the directory named 'sourcePathName' and all contained files/directories to 'destination'. |
|
3316 |
Return true if successful." |
|
3317 |
||
3318 |
^ false |
|
3319 |
||
3320 |
"Modified: / 4.6.1998 / 04:29:49 / cg" |
|
3321 |
! |
|
3322 |
||
3323 |
removeDirectory:fullPathName |
|
3324 |
"remove the directory named 'fullPathName'. |
|
3325 |
The directory must be empty and you must have appropriate access rights. |
|
3326 |
Return true if successful, false if directory is not empty or no permission. |
|
3327 |
This is a lowLevel entry - use Filename protocol for compatibility." |
|
3328 |
||
3329 |
%{ |
|
3330 |
int ret; |
|
3331 |
||
3332 |
if (__isString(fullPathName)) { |
|
3333 |
#ifdef DO_WRAP_CALLS |
|
7199
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 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3336 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3337 |
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
|
3338 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3339 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3340 |
ret = STX_API_CALL1( "RemoveDirectory", RemoveDirectory, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3341 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3342 |
} |
5133 | 3343 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3344 |
ret = RemoveDirectory((char *)__stringVal(fullPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3345 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3346 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3347 |
if (ret != TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3348 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3349 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3350 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3351 |
RETURN (true); |
5133 | 3352 |
} |
3353 |
%}. |
|
3354 |
"/ |
|
3355 |
"/ either not a string argument, |
|
3356 |
"/ or not supported by OS |
|
3357 |
"/ |
|
3358 |
^ self primitiveFailed |
|
3359 |
||
3360 |
" |
|
3361 |
OperatingSystem createDirectory:'foo' |
|
3362 |
OperatingSystem removeDirectory:'foo' |
|
3363 |
" |
|
3364 |
! |
|
3365 |
||
3366 |
removeFile:fullPathName |
|
3367 |
"remove the file named 'fullPathName'; return true if successful. |
|
3368 |
This is a lowLevel entry - use Filename protocol for compatibility." |
|
3369 |
||
3370 |
%{ |
|
3371 |
int ret; |
|
3372 |
||
3373 |
if (__isString(fullPathName)) { |
|
3374 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3375 |
{ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3376 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3377 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3378 |
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
|
3379 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3380 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3381 |
ret = STX_API_CALL1( "DeleteFile", DeleteFile, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3382 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3383 |
} |
5133 | 3384 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3385 |
ret = DeleteFile((char *)__stringVal(fullPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3386 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3387 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3388 |
if (ret != TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3389 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3390 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3391 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3392 |
RETURN (true); |
5133 | 3393 |
} |
3394 |
%}. |
|
3395 |
^ self primitiveFailed |
|
3396 |
! |
|
3397 |
||
3398 |
renameFile:oldPath to:newPath |
|
3399 |
"rename the file 'oldPath' to 'newPath'. |
|
3400 |
Someone else has to care for the names to be correct and |
|
3401 |
correct for the OS used - therefore, this should not be called |
|
3402 |
directlt. Instead, use Filename protocol to rename; this cares for |
|
3403 |
any invalid names. |
|
3404 |
Returns true if successful, false if not" |
|
3405 |
||
3406 |
%{ |
|
3407 |
int ret, eno; |
|
3408 |
||
3409 |
if (__isString(oldPath) && __isString(newPath)) { |
|
3410 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3411 |
char _oldPath[MAXPATHLEN], _newPath[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3412 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3413 |
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
|
3414 |
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
|
3415 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3416 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3417 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3418 |
ret = STX_C_CALL2( "rename", rename, _oldPath, _newPath); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3419 |
} 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
|
3420 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3421 |
__BEGIN_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3422 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3423 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3424 |
ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3425 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3426 |
__END_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3427 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3428 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3429 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3430 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3431 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3432 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3433 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3434 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3435 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3436 |
RETURN (true); |
5133 | 3437 |
} |
3438 |
%}. |
|
3439 |
^ self primitiveFailed |
|
3440 |
||
3441 |
" |
|
3442 |
OperatingSystem renameFile:'foo' to:'bar' |
|
3443 |
" |
|
3444 |
! |
|
3445 |
||
3446 |
truncateFile:aPathName to:newSize |
|
3447 |
"change a files size return true on success, false on failure. |
|
3448 |
This may not be supported on all architectures. |
|
3449 |
||
3450 |
This is a low-level entry - use Filename protocol." |
|
3451 |
||
3452 |
^ self primitiveFailed |
|
3453 |
! ! |
|
3454 |
||
3455 |
!Win32OperatingSystem class methodsFor:'file access rights'! |
|
3456 |
||
3457 |
accessMaskFor:aSymbol |
|
3458 |
"return the access bits mask for numbers as returned by |
|
3459 |
OperatingSystem>>accessModeOf: |
|
3460 |
and expected by OperatingSystem>>changeAccessModeOf:to:. |
|
3461 |
Since these numbers are OS dependent, always use the mask |
|
3462 |
(never hardcode 8rxxx into your code)." |
|
3463 |
||
3464 |
%{ /* NOCONTEXT */ |
|
3465 |
/* posix systems should define these ... */ |
|
3466 |
# ifndef S_IRUSR |
|
3467 |
# define S_IRUSR 0400 |
|
3468 |
# endif |
|
3469 |
# ifndef S_IWUSR |
|
3470 |
# define S_IWUSR 0200 |
|
3471 |
# endif |
|
3472 |
# ifndef S_IXUSR |
|
3473 |
# define S_IXUSR 0100 |
|
3474 |
# endif |
|
3475 |
# ifndef S_IRGRP |
|
3476 |
# define S_IRGRP 0040 |
|
3477 |
# endif |
|
3478 |
# ifndef S_IWGRP |
|
3479 |
# define S_IWGRP 0020 |
|
3480 |
# endif |
|
3481 |
# ifndef S_IXGRP |
|
3482 |
# define S_IXGRP 0010 |
|
3483 |
# endif |
|
3484 |
# ifndef S_IROTH |
|
3485 |
# define S_IROTH 0004 |
|
3486 |
# endif |
|
3487 |
# ifndef S_IWOTH |
|
3488 |
# define S_IWOTH 0002 |
|
3489 |
# endif |
|
3490 |
# ifndef S_IXOTH |
|
3491 |
# define S_IXOTH 0001 |
|
3492 |
# endif |
|
3493 |
||
3494 |
if (aSymbol == @symbol(readUser)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3495 |
RETURN ( __MKSMALLINT(S_IRUSR) ); |
5133 | 3496 |
} |
3497 |
if (aSymbol == @symbol(writeUser)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3498 |
RETURN ( __MKSMALLINT(S_IWUSR) ); |
5133 | 3499 |
} |
3500 |
if (aSymbol == @symbol(executeUser)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3501 |
RETURN ( __MKSMALLINT(S_IXUSR) ); |
5133 | 3502 |
} |
3503 |
if (aSymbol == @symbol(readGroup)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3504 |
RETURN ( __MKSMALLINT(S_IRGRP) ); |
5133 | 3505 |
} |
3506 |
if (aSymbol == @symbol(writeGroup)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3507 |
RETURN ( __MKSMALLINT(S_IWGRP) ); |
5133 | 3508 |
} |
3509 |
if (aSymbol == @symbol(executeGroup)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3510 |
RETURN ( __MKSMALLINT(S_IXGRP) ); |
5133 | 3511 |
} |
3512 |
if (aSymbol == @symbol(readOthers)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3513 |
RETURN ( __MKSMALLINT(S_IROTH) ); |
5133 | 3514 |
} |
3515 |
if (aSymbol == @symbol(writeOthers)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3516 |
RETURN ( __MKSMALLINT(S_IWOTH) ); |
5133 | 3517 |
} |
3518 |
if (aSymbol == @symbol(executeOthers)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3519 |
RETURN ( __MKSMALLINT(S_IXOTH) ); |
5133 | 3520 |
} |
3521 |
%}. |
|
3522 |
^ self primitiveFailed |
|
3523 |
||
3524 |
" |
|
3525 |
OperatingSystem accessMaskFor:#readUser |
|
3526 |
" |
|
3527 |
! |
|
3528 |
||
3529 |
accessModeOf:aPathName |
|
3530 |
"return a number representing access rights rwxrwxrwx for owner, |
|
3531 |
group and others. Return nil if such a file does not exist. |
|
3532 |
Notice that the returned number is OS dependent - use the |
|
3533 |
modeMasks as returned by OperatingSystem>>accessMaskFor:" |
|
3534 |
||
3535 |
" |
|
3536 |
this could have been implemented as: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3537 |
(self infoOf:aPathName) at:#mode |
5133 | 3538 |
but for huge directory searches the code below is faster |
3539 |
" |
|
3540 |
||
3541 |
%{ |
|
3542 |
struct stat buf; |
|
3543 |
int ret; |
|
3544 |
||
3545 |
if (__isString(aPathName)) { |
|
3546 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3547 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3548 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3549 |
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
|
3550 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3551 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3552 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3553 |
ret = STX_C_CALL2( "stat", stat, _aPathName, &buf); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3554 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 3555 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3556 |
__BEGIN_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3557 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3558 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3559 |
ret = stat( (char *)__stringVal(aPathName), &buf); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3560 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3561 |
__END_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3562 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3563 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3564 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3565 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3566 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3567 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3568 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3569 |
RETURN ( nil ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3570 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3571 |
RETURN ( __MKSMALLINT(buf.st_mode & 0777) ); |
5133 | 3572 |
} |
3573 |
%}. |
|
3574 |
^ self primitiveFailed |
|
3575 |
||
3576 |
" |
|
3577 |
(OperatingSystem accessModeOf:'/') printStringRadix:8 |
|
3578 |
" |
|
3579 |
! |
|
3580 |
||
3581 |
changeAccessModeOf:aPathName to:modeBits |
|
3582 |
"change the access rights of aPathName to the OS dependent modeBits. |
|
3583 |
You should construct this mask using accessMaskFor, to be OS |
|
3584 |
independent. Return true if changed, |
|
3585 |
false if such a file does not exist or change was not allowd." |
|
3586 |
||
3587 |
%{ |
|
3588 |
int ret; |
|
3589 |
||
3590 |
if (__isString(aPathName) && __isSmallInteger(modeBits)) { |
|
3591 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3592 |
int chmod(); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3593 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3594 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3595 |
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
|
3596 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3597 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3598 |
ret = STX_C_CALL2( "chmod", chmod, _aPathName, __intVal(modeBits)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3599 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 3600 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3601 |
__BEGIN_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3602 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3603 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3604 |
ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3605 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3606 |
__END_INTERRUPTABLE__ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3607 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3608 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3609 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3610 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3611 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3612 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3613 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3614 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3615 |
RETURN ( true ); |
5133 | 3616 |
} |
3617 |
%}. |
|
3618 |
^ self primitiveFailed |
|
3619 |
! ! |
|
3620 |
||
3621 |
!Win32OperatingSystem class methodsFor:'file queries'! |
|
3622 |
||
3623 |
caseSensitiveFilenames |
|
3624 |
"return true, if the OS has caseSensitive file naming. |
|
3625 |
On MSDOS, this will return false; |
|
3626 |
on a real OS, we return true." |
|
3627 |
||
3628 |
^ false |
|
3629 |
! |
|
3630 |
||
3631 |
compressPath:pathName |
|
3632 |
"return the pathName compressed - that is, remove all ..-entries |
|
3633 |
and . entries. This does not always (in case of symbolic links) |
|
3634 |
return the true pathName and is therefore used as a fallback |
|
3635 |
if realPath and popen failed." |
|
3636 |
||
3637 |
|names n "{ Class: SmallInteger }" | |
|
3638 |
||
3639 |
names := pathName |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3640 |
asCollectionOfSubstringsSeparatedBy:self fileSeparator. |
5133 | 3641 |
names := names asOrderedCollection. |
3642 |
" |
|
3643 |
cut off initial double-slashes |
|
3644 |
" |
|
3645 |
[names startsWith:#('' '')] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3646 |
names removeFirst. |
5133 | 3647 |
]. |
3648 |
" |
|
3649 |
cut off double-slashes at end |
|
3650 |
" |
|
3651 |
[names endsWith:#('')] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3652 |
names removeLast. |
5133 | 3653 |
]. |
3654 |
" |
|
3655 |
cut off current-dir at beginning |
|
3656 |
" |
|
3657 |
n := names size. |
|
3658 |
[(n >= 2) and:[names startsWith:#('.')]] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3659 |
names removeFirst. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3660 |
n := n - 1. |
5133 | 3661 |
]. |
3662 |
||
3663 |
" |
|
3664 |
cut off parent-dirs at end |
|
3665 |
" |
|
3666 |
[(n > 2) |
|
3667 |
and:[(names endsWith:#('..')) |
|
3668 |
and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3669 |
names removeLast; removeLast. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3670 |
n := n - 2. |
5133 | 3671 |
]. |
3672 |
||
3673 |
^ names asStringWith:self fileSeparator |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3674 |
from:1 |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3675 |
to:n |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3676 |
compressTabs:false final:nil |
7077 | 3677 |
|
3678 |
" |
|
3679 |
OperatingSystem compressPath:'.\..' |
|
3680 |
OperatingSystem compressPath:'\foo\bar\baz\..' |
|
7102 | 3681 |
OperatingSystem compressPath:'foo\bar\baz\..' |
7077 | 3682 |
OperatingSystem compressPath:'foo\bar\baz\..\' |
3683 |
OperatingSystem compressPath:'foo\bar\baz\..\\\' |
|
3684 |
OperatingSystem compressPath:'\\\foo\bar\baz\..\\\' |
|
5133 | 3685 |
" |
3686 |
||
3687 |
"Modified: 1.11.1996 / 20:13:48 / cg" |
|
3688 |
! |
|
3689 |
||
3690 |
fileSeparator |
|
3691 |
"return the character used to separate names in a path. |
|
3692 |
This character differs for MSDOS and other systems, |
|
3693 |
(but those are currently not supported - so this is some |
|
3694 |
preparation for the future)" |
|
3695 |
||
3696 |
^ $\ |
|
3697 |
! |
|
3698 |
||
3699 |
getDiskInfoOf:aVolumeName |
|
3700 |
"returns a dictionary filled with any of: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3701 |
freeBytes |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3702 |
totalBytes |
5133 | 3703 |
and possibly additional (OS-specific) information" |
3704 |
||
3705 |
|info ok sectorsPerCluster bytesPerSector freeClusters totalClusters |
|
3706 |
type| |
|
3707 |
||
3708 |
%{ |
|
3709 |
DWORD __sectorsPerCluster, __bytesPerSector, __freeClusters, __totalClusters; |
|
3710 |
||
3711 |
if (__isString(aVolumeName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3712 |
if (GetDiskFreeSpace(__stringVal(aVolumeName), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3713 |
&__sectorsPerCluster, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3714 |
&__bytesPerSector, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3715 |
&__freeClusters, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3716 |
&__totalClusters) == TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3717 |
sectorsPerCluster = __MKUINT(__sectorsPerCluster); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3718 |
bytesPerSector = __MKUINT(__bytesPerSector); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3719 |
freeClusters = __MKUINT(__freeClusters); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3720 |
totalClusters = __MKUINT(__totalClusters); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3721 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3722 |
switch (GetDriveType(__stringVal(aVolumeName))) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3723 |
case DRIVE_REMOVABLE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3724 |
type = @symbol(removable); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3725 |
case DRIVE_FIXED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3726 |
type = @symbol(fixed); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3727 |
case DRIVE_REMOTE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3728 |
type = @symbol(network); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3729 |
case DRIVE_CDROM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3730 |
type = @symbol(cdrom); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3731 |
case DRIVE_RAMDISK: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3732 |
type = @symbol(ramdisk); break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3733 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3734 |
ok = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3735 |
} |
5133 | 3736 |
} |
3737 |
%}. |
|
3738 |
ok == true ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3739 |
info := IdentityDictionary new. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3740 |
info at:#sectorsPerCluster put:sectorsPerCluster. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3741 |
info at:#bytesPerSector put:bytesPerSector. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3742 |
info at:#freeClusters put:freeClusters. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3743 |
info at:#totalClusters put:totalClusters. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3744 |
info at:#freeBytes put:(freeClusters * sectorsPerCluster * bytesPerSector). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3745 |
info at:#totalBytes put:(totalClusters * sectorsPerCluster * bytesPerSector). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3746 |
type notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3747 |
info at:#type put:type |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3748 |
]. |
5133 | 3749 |
]. |
3750 |
^ info |
|
3751 |
||
3752 |
" |
|
3753 |
self getDiskInfoOf:'c:\' |
|
3754 |
self getDiskInfoOf:'d:\' |
|
3755 |
" |
|
3756 |
! |
|
3757 |
||
3758 |
getDriveList |
|
3759 |
"return a list of volumes in the system. |
|
3760 |
On unix, no such thing like a volume exists |
|
3761 |
- there, a syntetic list with root, home & current is returned. |
|
3762 |
On MSDOS, a list of drive letters is (eventually) returned. |
|
3763 |
On VMS, a list of volumes is (eventually) returned." |
|
3764 |
||
3765 |
|list| |
|
3766 |
||
3767 |
list := OrderedCollection new. |
|
3768 |
%{ |
|
3769 |
/* |
|
3770 |
* add drive letters as strings to list ... |
|
3771 |
*/ |
|
3772 |
char buffer[1024]; |
|
3773 |
char *cp; |
|
3774 |
||
3775 |
GetLogicalDriveStrings(1023, buffer); |
|
3776 |
for (cp=buffer; *cp; ) { |
|
3777 |
__SSEND1(list, @symbol(add:), 0, __MKSTRING(cp)); |
|
3778 |
cp += strlen(cp) + 1; |
|
3779 |
} |
|
3780 |
%}. |
|
3781 |
^ list |
|
3782 |
! |
|
3783 |
||
3784 |
getFileVersionInfoOf:aPathName |
|
3785 |
"retrieves the versionData from an executable or dll. |
|
3786 |
The returned value is either a byteArray, which should be |
|
3787 |
processed further with extractVersionValue (VerQueryValue), |
|
3788 |
or nil. |
|
3789 |
This is a WIN32 specific entry, not for common usage." |
|
3790 |
%{ |
|
3791 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3792 |
int sz; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3793 |
DWORD dummy; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3794 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3795 |
sz = GetFileVersionInfoSize(__stringVal(aPathName), &dummy); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3796 |
if (sz > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3797 |
OBJ versionData; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3798 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3799 |
versionData = __BYTEARRAY_UNINITIALIZED_NEW_INT(sz); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3800 |
if (versionData == nil) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3801 |
RETURN (nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3802 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3803 |
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
|
3804 |
RETURN (nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3805 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3806 |
RETURN (versionData); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3807 |
} |
5133 | 3808 |
} |
3809 |
%}. |
|
3810 |
^ nil |
|
3811 |
! |
|
3812 |
||
3813 |
getNullDevice |
|
3814 |
"get the name of the null-device." |
|
3815 |
||
3816 |
^ 'nul' |
|
3817 |
! |
|
3818 |
||
3819 |
infoOf:aPathName |
|
3820 |
"return some object filled with info for the file 'aPathName'; |
|
3821 |
the info (for which corresponding access methods are understood by |
|
3822 |
the returned object) is: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3823 |
type - a symbol giving the files type |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3824 |
mode - numeric access mode |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3825 |
uid - owners user id |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3826 |
gid - owners group id |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3827 |
size - files size |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3828 |
id - files number (i.e. inode number) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3829 |
accessed - last access time (as Timestamp) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3830 |
modified - last modification time (as Timestamp) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3831 |
statusChanged - last status change time (as Timestamp) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3832 |
alternativeName - (windows only:) the MSDOS name of the file |
5133 | 3833 |
|
3834 |
Some of the fields may be returned as nil on systems which do not provide |
|
3835 |
all of the information. |
|
3836 |
Return nil if such a file does not exist. |
|
3837 |
For symbolic links (if supported by the OS), |
|
3838 |
the info of the pointed-to-file (i.e. the target) is returned; |
|
3839 |
use #linkInfoOf: to get info about the link itself. |
|
3840 |
" |
|
3841 |
||
3842 |
|info type mode uid gid size id |
|
3843 |
atime mtime ctime |
|
3844 |
aYr aMon aDay aHr aMin aSec aMS |
|
3845 |
mYr mMon mDay mHr mMin mSec mMS |
|
3846 |
cYr cMon cDay cHr cMin cSec cMS |
|
7062 | 3847 |
fileName alternativeName| |
5133 | 3848 |
|
3849 |
%{ |
|
3850 |
struct stat buf; |
|
3851 |
int ret; |
|
7062 | 3852 |
char alternativeFileNameBuffer[15]; |
3853 |
char fileNameBuffer[MAX_PATH+1]; |
|
3854 |
||
5133 | 3855 |
unsigned INT ino; |
3856 |
||
3857 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3858 |
HANDLE hFile; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3859 |
SYSTEMTIME creationTime; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3860 |
SYSTEMTIME accessTime; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3861 |
SYSTEMTIME modificationTime; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3862 |
int modeBits = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3863 |
WIN32_FIND_DATA findStruct; |
5133 | 3864 |
|
3865 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3866 |
{ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3867 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3868 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3869 |
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
|
3870 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3871 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3872 |
hFile = STX_API_CALL2( "FindFirstFile", FindFirstFile, _aPathName, &findStruct); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3873 |
} while ((hFile < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3874 |
} |
5133 | 3875 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3876 |
hFile = FindFirstFile(__stringVal(aPathName), &findStruct); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3877 |
if (hFile < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3878 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3879 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3880 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3881 |
if (! hFile || (hFile == (HANDLE)(-1)) || (hFile == INVALID_HANDLE_VALUE)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3882 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3883 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3884 |
FindClose(hFile); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3885 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3886 |
id = __MKSMALLINT(0); /* could get it by opening ... */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3887 |
size = __MKLARGEINT64(1, findStruct.nFileSizeLow, findStruct.nFileSizeHigh); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3888 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3889 |
if (findStruct.cFileName[0] != '\0') { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3890 |
bcopy(findStruct.cFileName, fileNameBuffer, MAX_PATH); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3891 |
fileNameBuffer[MAX_PATH] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3892 |
fileName = __MKSTRING(fileNameBuffer); /* FULL name */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3893 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3894 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3895 |
if (findStruct.cAlternateFileName[0] != '\0') { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3896 |
bcopy(findStruct.cAlternateFileName, alternativeFileNameBuffer, 14); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3897 |
alternativeFileNameBuffer[14] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3898 |
alternativeName = __MKSTRING(alternativeFileNameBuffer); /* DOS name */ |
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 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3901 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3902 |
* simulate access bits |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3903 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3904 |
if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_READONLY) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3905 |
modeBits = 0444; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3906 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3907 |
modeBits = 0666; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3908 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3909 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3910 |
if (findStruct.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3911 |
type = @symbol(directory); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3912 |
modeBits |= 0111; /* executable */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3913 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3914 |
type = @symbol(regular); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3915 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3916 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3917 |
mode = __MKSMALLINT(modeBits); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3918 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3919 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3920 |
* sigh - convert from stupid time to useful time |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3921 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3922 |
FileTimeToSystemTime(&(findStruct.ftCreationTime), &creationTime); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3923 |
FileTimeToSystemTime(&(findStruct.ftLastAccessTime), &accessTime); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3924 |
FileTimeToSystemTime(&(findStruct.ftLastWriteTime), &modificationTime); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3925 |
aYr = __MKSMALLINT(accessTime.wYear); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3926 |
aMon = __MKSMALLINT(accessTime.wMonth); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3927 |
aDay = __MKSMALLINT(accessTime.wDay); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3928 |
aHr = __MKSMALLINT(accessTime.wHour); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3929 |
aMin = __MKSMALLINT(accessTime.wMinute); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3930 |
aSec = __MKSMALLINT(accessTime.wSecond); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3931 |
aMS = __MKSMALLINT(accessTime.wMilliseconds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3932 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3933 |
mYr = __MKSMALLINT(modificationTime.wYear); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3934 |
mMon = __MKSMALLINT(modificationTime.wMonth); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3935 |
mDay = __MKSMALLINT(modificationTime.wDay); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3936 |
mHr = __MKSMALLINT(modificationTime.wHour); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3937 |
mMin = __MKSMALLINT(modificationTime.wMinute); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3938 |
mSec = __MKSMALLINT(modificationTime.wSecond); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3939 |
mMS = __MKSMALLINT(modificationTime.wMilliseconds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3940 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3941 |
cYr = __MKSMALLINT(creationTime.wYear); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3942 |
cMon = __MKSMALLINT(creationTime.wMonth); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3943 |
cDay = __MKSMALLINT(creationTime.wDay); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3944 |
cHr = __MKSMALLINT(creationTime.wHour); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3945 |
cMin = __MKSMALLINT(creationTime.wMinute); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3946 |
cSec = __MKSMALLINT(creationTime.wSecond); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3947 |
cMS = __MKSMALLINT(creationTime.wMilliseconds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3948 |
} |
5133 | 3949 |
} |
3950 |
%}. |
|
6377
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
3951 |
mode isNil ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3952 |
(self isDirectory:aPathName) ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3953 |
"/ 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
|
3954 |
"/ simulate |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3955 |
mode := 8r777. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3956 |
type := #directory. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3957 |
uid := gid := 0. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3958 |
size := 0. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3959 |
id := 0. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3960 |
atime := mtime := ctime := AbsoluteTime now. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3961 |
]. |
6377
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
3962 |
]. |
5133 | 3963 |
mode notNil ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3964 |
atime isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3965 |
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
|
3966 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3967 |
mtime isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3968 |
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
|
3969 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3970 |
ctime isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3971 |
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
|
3972 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3973 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3974 |
info := FileStatusInfo |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3975 |
type:type |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3976 |
mode:mode |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3977 |
uid:uid |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3978 |
gid:gid |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3979 |
size:size |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3980 |
id:id |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3981 |
accessed:atime |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3982 |
modified:mtime |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3983 |
created:ctime |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3984 |
path:nil |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3985 |
fullName:fileName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3986 |
alternativeName:alternativeName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
3987 |
^ info |
5133 | 3988 |
]. |
6726 | 3989 |
^ nil |
5133 | 3990 |
|
3991 |
" |
|
6377
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
3992 |
OperatingSystem infoOf:'c:\windows' |
5133 | 3993 |
OperatingSystem infoOf:'stx.exe' |
3994 |
(OperatingSystem infoOf:'/') uid |
|
3995 |
(OperatingSystem infoOf:'/') accessed |
|
3996 |
" |
|
6377
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
3997 |
|
0113dcb902c5
simulate :drive as a directory
Claus Gittinger <cg@exept.de>
parents:
6372
diff
changeset
|
3998 |
"Modified: / 4.2.2002 / 17:15:08 / cg" |
5133 | 3999 |
! |
4000 |
||
4001 |
isDirectory:aPathName |
|
4002 |
"return true, if 'aPathName' is a valid directory path name. |
|
4003 |
(i.e. exists and is a directory). |
|
4004 |
This also returns true for symbolic links pointing to a directory; |
|
4005 |
if you need to check for this, use #linkInfo:." |
|
4006 |
||
4007 |
%{ |
|
4008 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4009 |
int ret; |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
4010 |
|
5133 | 4011 |
#ifdef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4012 |
char _aPathName[MAXPATHLEN]; |
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 |
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
|
4015 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4016 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4017 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4018 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 4019 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4020 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4021 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4022 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4023 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4024 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4025 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4026 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4027 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4028 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4029 |
RETURN ( (ret & FILE_ATTRIBUTE_DIRECTORY) ? true : false); |
5133 | 4030 |
} |
4031 |
%}. |
|
4032 |
^ self primitiveFailed |
|
4033 |
||
4034 |
"an alternative implementation would be: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4035 |
^ (self infoOf:aPathName) type == #directory |
5133 | 4036 |
" |
4037 |
! |
|
4038 |
||
4039 |
isExecutable:aPathName |
|
4040 |
"return true, if the given file is executable. |
|
4041 |
For symbolic links, the pointed-to-file is checked." |
|
4042 |
||
4043 |
%{ |
|
4044 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4045 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4046 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4047 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4048 |
* under windows, there is no executable attribute ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4049 |
* so, only check for the files existence here. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4050 |
*/ |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
4051 |
#ifdef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4052 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4053 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4054 |
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
|
4055 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4056 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4057 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4058 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 4059 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4060 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4061 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4062 |
__threadErrno = __WIN32_ERR(GetLastError()); |
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 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4065 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4066 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4067 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4068 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4069 |
RETURN (true); |
5133 | 4070 |
} |
4071 |
%}. |
|
4072 |
! |
|
4073 |
||
4074 |
isReadable:aPathName |
|
4075 |
"return true, if the file/dir 'aPathName' is readable. |
|
4076 |
For symbolic links, the pointed-to-file is checked." |
|
4077 |
||
4078 |
%{ |
|
4079 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4080 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4081 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4082 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4083 |
* under windows, all files are readable ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4084 |
* so, only check for the files existence here. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4085 |
*/ |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
4086 |
#ifdef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4087 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4088 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4089 |
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
|
4090 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4091 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4092 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4093 |
} 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
|
4094 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4095 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4096 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4097 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4098 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4099 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4100 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4101 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4102 |
RETURN (false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4103 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4104 |
RETURN (true); |
5133 | 4105 |
} |
4106 |
%}. |
|
4107 |
^ self primitiveFailed |
|
4108 |
! |
|
4109 |
||
4110 |
isSymbolicLink:aPathName |
|
4111 |
"return true, if the given file is a symbolic link" |
|
4112 |
||
4113 |
^ (self linkInfoOf:aPathName) notNil |
|
4114 |
||
4115 |
" |
|
4116 |
OperatingSystem isSymbolicLink:'Make.proto' |
|
4117 |
OperatingSystem isSymbolicLink:'Makefile' |
|
4118 |
" |
|
4119 |
! |
|
4120 |
||
4121 |
isValidPath:aPathName |
|
4122 |
"return true, if 'aPathName' is a valid path name |
|
4123 |
(i.e. the file or directory exists)" |
|
4124 |
||
4125 |
%{ |
|
4126 |
struct stat buf; |
|
4127 |
int ret; |
|
4128 |
||
4129 |
if (__isString(aPathName) || __isSymbol(aPathName) ) { |
|
4130 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4131 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4132 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4133 |
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
|
4134 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4135 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4136 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4137 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 4138 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4139 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4140 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4141 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4142 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4143 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4144 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4145 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4146 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4147 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4148 |
RETURN (true); |
5133 | 4149 |
} |
4150 |
%}. |
|
4151 |
^ self primitiveFailed |
|
4152 |
! |
|
4153 |
||
4154 |
isWritable:aPathName |
|
4155 |
"return true, if the given file is writable. |
|
4156 |
For symbolic links, the pointed-to-file is checked." |
|
4157 |
||
4158 |
%{ |
|
4159 |
int ret; |
|
4160 |
||
4161 |
if (__isString(aPathName)) { |
|
4162 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4163 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4164 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4165 |
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
|
4166 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4167 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4168 |
ret = STX_API_CALL1( "GetFileAttributes", GetFileAttributes, _aPathName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4169 |
} while ((ret < 0) && (__threadErrno == EINTR)); |
5133 | 4170 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4171 |
ret = GetFileAttributes((char *) __stringVal(aPathName)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4172 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4173 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4174 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4175 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4176 |
if (ret < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4177 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4178 |
RETURN ( false ); |
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 |
RETURN ( (ret & FILE_ATTRIBUTE_READONLY) ? false : true); |
5133 | 4181 |
} |
4182 |
%}. |
|
4183 |
^ self primitiveFailed |
|
4184 |
! |
|
4185 |
||
4186 |
linkInfoOf:aPathName |
|
4187 |
"return a dictionary filled with info for the file 'aPathName', |
|
4188 |
IFF aPathName is a symbolic link. |
|
4189 |
If aPathName is invalid, or its NOT a symbolic link, nil is returned. |
|
4190 |
(which means, that systems like VMS or MSDOS always return nil here.) |
|
4191 |
||
4192 |
The contents of the dictionary gives info about the link itself, |
|
4193 |
on contrast to #infoOf:, which returns the info of the pointed to file |
|
4194 |
in case of a symbolic link." |
|
4195 |
||
4196 |
^ nil |
|
4197 |
! |
|
4198 |
||
4199 |
mimeTypeForSuffix:aFileSuffix |
|
4200 |
"given a file suffix, return a corresponding mimeType. |
|
4201 |
Here, the Registry is consulted. |
|
4202 |
Returns nil if no mimeType for the given suffix is known." |
|
4203 |
||
4204 |
^ RegistryEntry |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4205 |
stringValueFor:'Content Type' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4206 |
atKey:('HKEY_CLASSES_ROOT\.' , aFileSuffix) |
5133 | 4207 |
|
4208 |
" |
|
4209 |
self mimeTypeForSuffix:'au' |
|
4210 |
" |
|
4211 |
||
4212 |
! |
|
4213 |
||
4214 |
parentDirectoryName |
|
4215 |
"return the name used to refer to parent directories. |
|
4216 |
In MSDOS, Unix and other systems this is '..', but maybe different |
|
4217 |
for other systems. |
|
4218 |
(but those are currently not supported - so this is some |
|
4219 |
preparation for the future)" |
|
4220 |
||
4221 |
^ '..' |
|
4222 |
! |
|
4223 |
||
4224 |
pathNameOf:pathName |
|
4225 |
"return the pathName of the argument, aPathString, |
|
4226 |
- thats the full pathname of the directory, starting at '/'. |
|
4227 |
This method needs the path to be valid |
|
4228 |
(i.e. all directories must exist, be readable and executable). |
|
4229 |
Notice: if symbolic links are involved, the result may look different |
|
4230 |
from what you expect." |
|
4231 |
||
4232 |
|p path| |
|
4233 |
||
4234 |
"some systems have a convenient function for this ..." |
|
4235 |
path := self primPathNameOf:pathName. |
|
4236 |
||
4237 |
path isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4238 |
(self isValidPath:pathName) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4239 |
p := pathName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4240 |
[(p size > 1) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4241 |
and:[p endsWith:(self fileSeparator)] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4242 |
] whileTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4243 |
p := p copyWithoutLast:1. |
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 |
^ p |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4246 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4247 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4248 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4249 |
"/ 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
|
4250 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4251 |
path := self compressPath:pathName |
5133 | 4252 |
]. |
4253 |
^ path. |
|
4254 |
||
4255 |
" |
|
4256 |
OperatingSystem pathNameOf:'.' |
|
4257 |
OperatingSystem pathNameOf:'../smalltalk/../smalltalk' |
|
4258 |
OperatingSystem pathNameOf:'../../..' |
|
4259 |
OperatingSystem pathNameOf:'..' |
|
4260 |
OperatingSystem pathNameOf:'/tmp////' |
|
4261 |
OperatingSystem pathNameOf:'/foo/bar' |
|
4262 |
OperatingSystem pathNameOf:'/foo/bar/' |
|
4263 |
OperatingSystem pathNameOf:'/foo/bar//' |
|
4264 |
" |
|
4265 |
||
4266 |
"Modified: 29.11.1996 / 18:02:12 / stefan" |
|
4267 |
"Modified: 10.1.1997 / 19:10:42 / cg" |
|
4268 |
! |
|
4269 |
||
4270 |
primIdOf:aPathName |
|
4271 |
"the actual code to return the fileNumber (i.e. inode number) of a file." |
|
4272 |
||
4273 |
^ nil |
|
4274 |
! |
|
4275 |
||
4276 |
primPathNameOf:aPathName |
|
4277 |
"return the pathName of the argument, aPathString, |
|
4278 |
- thats the full pathname of the directory, starting at '/'. |
|
4279 |
This method here returns nil, if the OS does not provide a |
|
4280 |
realPath library function. |
|
4281 |
Notice: if symbolic links are involved, the result may look different |
|
4282 |
from what you expect." |
|
4283 |
||
4284 |
%{ /* xxSTACK: 16000 */ |
|
4285 |
||
4286 |
if (__isString(aPathName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4287 |
char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4288 |
char *pFinal; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4289 |
int rslt; |
5133 | 4290 |
|
4291 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4292 |
char _aPathName[MAXPATHLEN]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4293 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4294 |
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
|
4295 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4296 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4297 |
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
|
4298 |
} while ((rslt < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4299 |
if (rslt > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4300 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4301 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4302 |
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
|
4303 |
} while ((rslt < 0) && (__threadErrno == EINTR)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4304 |
} |
5133 | 4305 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4306 |
rslt = GetFullPathName(__stringVal(aPathName), sizeof(nameBuffer), nameBuffer, &pFinal); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4307 |
if (rslt > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4308 |
rslt = GetLongPathName(nameBuffer, nameBuffer, sizeof(nameBuffer)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4309 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4310 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4311 |
if (rslt > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4312 |
RETURN ( __MKSTRING(nameBuffer) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4313 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4314 |
__threadErrno = __WIN32_ERR(GetLastError()); |
5133 | 4315 |
} |
4316 |
%}. |
|
4317 |
^ nil |
|
7102 | 4318 |
" |
4319 |
self primPathNameOf:'.' |
|
4320 |
" |
|
5133 | 4321 |
! |
4322 |
||
4323 |
timeOfLastAccess:aPathName |
|
4324 |
"return the time, when the file was last accessed. |
|
4325 |
For nonexistent files, nil is returned." |
|
4326 |
||
4327 |
"could be implemented as: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4328 |
(self infoOf:aPathName) accessed |
5133 | 4329 |
" |
4330 |
| i| |
|
4331 |
||
4332 |
i := self infoOf:aPathName. |
|
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
4333 |
i notNil ifTrue:[^ i accessTime]. |
5133 | 4334 |
^ nil. |
4335 |
||
4336 |
" |
|
4337 |
OperatingSystem timeOfLastAccess:'/' |
|
4338 |
" |
|
4339 |
! |
|
4340 |
||
4341 |
timeOfLastChange:aPathName |
|
4342 |
"return the time, when the file was last changed. |
|
4343 |
For nonexistent files, nil is returned." |
|
4344 |
||
4345 |
"could be implemented as: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4346 |
(self infoOf:aPathName) modified |
5133 | 4347 |
" |
4348 |
||
4349 |
| i| |
|
4350 |
||
4351 |
i := self infoOf:aPathName. |
|
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
4352 |
i notNil ifTrue:[^ i modificationTime]. |
5133 | 4353 |
^ nil. |
4354 |
||
4355 |
" |
|
4356 |
OperatingSystem timeOfLastChange:'/' |
|
4357 |
" |
|
4358 |
! |
|
4359 |
||
4360 |
typeOf:aPathName |
|
4361 |
"return the type of a file as a symbol; for nonexistent files, |
|
4362 |
nil is returned. |
|
4363 |
Notice: for symbolic links, the type of the pointed-to file is returned." |
|
4364 |
||
4365 |
|i| |
|
4366 |
||
4367 |
" |
|
4368 |
this could have been implemented as: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4369 |
(self infoOf:aPathName) type |
5133 | 4370 |
" |
4371 |
||
4372 |
i := self infoOf:aPathName. |
|
4373 |
i notNil ifTrue:[^ i type]. |
|
4374 |
^ nil. |
|
4375 |
||
4376 |
" |
|
4377 |
OperatingSystem typeOf:'/' |
|
4378 |
OperatingSystem typeOf:'.' |
|
4379 |
OperatingSystem typeOf:'Make.proto' |
|
4380 |
OperatingSystem typeOf:'resources/motif.style' |
|
4381 |
" |
|
4382 |
! |
|
4383 |
||
4384 |
volumeNameOf:aPathString |
|
4385 |
"return the volumeName of the argument, aPath |
|
4386 |
- thats the name of the volume where aPath is. |
|
4387 |
Not all OperatingSystem support/use volumes; on unix, |
|
4388 |
this always returns an empty string." |
|
4389 |
||
7102 | 4390 |
aPathString size < 2 ifTrue:[^ '']. |
5133 | 4391 |
(aPathString at:2) == $: ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4392 |
^ (aPathString at:1) asString. |
5133 | 4393 |
]. |
4394 |
^ '' |
|
4395 |
! ! |
|
4396 |
||
4397 |
!Win32OperatingSystem class methodsFor:'interrupts & signals'! |
|
4398 |
||
4399 |
blockingTest |
|
4400 |
"this is a test method; |
|
4401 |
For testing double CTRL-C in blocking primitives" |
|
4402 |
||
4403 |
%{ |
|
4404 |
while(1) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4405 |
printf("b"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4406 |
Sleep(50); |
5133 | 4407 |
} |
4408 |
%}. |
|
4409 |
" |
|
4410 |
OperatingSystem blockingTest |
|
4411 |
" |
|
4412 |
! |
|
4413 |
||
4414 |
defaultSignal:signalNumber |
|
4415 |
"revert to the default action on arrival of a (Unix-)signal. |
|
4416 |
Dont confuse Unix signals with smalltalk signals. |
|
4417 |
WARNING: for some signals, it is no good idea to revert to default; |
|
4418 |
for example, the default for SIGINT (i.e. ^C) is to exit; while the |
|
4419 |
default for SIGQUIT (^ \) is to dump core. |
|
4420 |
Also, NOTICE that signal numbers are not portable between unix |
|
4421 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4422 |
a signal." |
|
4423 |
||
4424 |
%{ /* NOCONTEXT */ |
|
4425 |
||
4426 |
if (__isSmallInteger(signalNumber)) { |
|
4427 |
#ifdef SIG_DFL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4428 |
signal(__intVal(signalNumber), SIG_DFL); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4429 |
RETURN (self); |
5133 | 4430 |
#endif |
4431 |
} |
|
4432 |
%}. |
|
4433 |
" |
|
4434 |
this error is triggered on non-integer argument |
|
4435 |
" |
|
4436 |
^ self primitiveFailed |
|
4437 |
||
4438 |
"you better save a snapshot image before trying this ..." |
|
4439 |
" |
|
4440 |
'if you hit ^C now, Smalltalk will exit immediately' printNewline. |
|
4441 |
OperatingSystem defaultSignal:(OperatingSystem sigINT). |
|
4442 |
1 to:1000000 do:[:i| ]. |
|
4443 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4444 |
'normal ^C handling again.' printNewline |
|
4445 |
" |
|
4446 |
! |
|
4447 |
||
4448 |
disableIOInterruptsOn:fd |
|
4449 |
"turn off IO interrupts for a filedescriptor" |
|
4450 |
||
4451 |
" |
|
4452 |
this error is triggered on non-integer argument |
|
4453 |
or if the OS does not support IO interrupts. |
|
4454 |
" |
|
4455 |
^ self primitiveFailed |
|
4456 |
! |
|
4457 |
||
4458 |
disableSignal:signalNumber |
|
4459 |
"disable (Unix-) signal processing for signalNumber. |
|
4460 |
Dont confuse Unix signals with smalltalk signals. |
|
4461 |
WARNING: for some signals, it is no good idea to disable |
|
4462 |
them; for example, disabling the SIGINT signal turns off ^C |
|
4463 |
handling. |
|
4464 |
Also, NOTICE that signal numbers are not portable between unix |
|
4465 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4466 |
a signal. |
|
4467 |
Use only for fully debugged stand alone applications." |
|
4468 |
||
4469 |
%{ /* NOCONTEXT */ |
|
4470 |
||
4471 |
if (__isSmallInteger(signalNumber)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4472 |
int sigNo = __intVal(signalNumber); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4473 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4474 |
if (sigNo == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4475 |
RETURN (self); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4476 |
} |
5133 | 4477 |
#ifdef SIG_IGN |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4478 |
signal(sigNo, SIG_IGN); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4479 |
RETURN (self); |
5133 | 4480 |
#endif |
4481 |
} |
|
4482 |
%}. |
|
4483 |
" |
|
4484 |
this error is triggered on non-integer argument |
|
4485 |
" |
|
4486 |
^ self primitiveFailed |
|
4487 |
||
4488 |
" |
|
4489 |
'now, ^C is totally ignored ...' printNewline. |
|
4490 |
OperatingSystem disableSignal:(OperatingSystem sigINT). |
|
4491 |
1 to:1000000 do:[:i| ]. |
|
4492 |
OperatingSystem enableSignal:(OperatingSystem sigINT). |
|
4493 |
'^C handled again.' printNewline |
|
4494 |
" |
|
4495 |
! |
|
4496 |
||
4497 |
disableTimer |
|
4498 |
"disable timer interrupts. |
|
4499 |
WARNING: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4500 |
the system will not operate correctly with timer interrupts |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4501 |
disabled, because no scheduling or timeouts are possible." |
5133 | 4502 |
|
4503 |
%{ /* NOCONTEXT */ |
|
4504 |
||
4505 |
extern void __win32ClearTimer(); |
|
4506 |
||
4507 |
__win32ClearTimer(); |
|
4508 |
%}. |
|
4509 |
^ true |
|
4510 |
! |
|
4511 |
||
4512 |
enableChildSignalInterrupts |
|
4513 |
"enable childSignal interrupts |
|
4514 |
(SIGCHLD, if the architecture supports it). |
|
4515 |
After enabling, these signals will send the message |
|
4516 |
'childSignalInterrupt' to the ChildSignalInterruptHandler object." |
|
4517 |
||
4518 |
self enableSignal:(self sigCHLD) |
|
4519 |
! |
|
4520 |
||
4521 |
enableIOInterruptsOn:fd |
|
4522 |
"turn on IO interrupts for a filedescriptor" |
|
4523 |
||
4524 |
" |
|
4525 |
this error is triggered on non-integer argument |
|
4526 |
or if the system does not support SIGIO |
|
4527 |
" |
|
4528 |
^ self primitiveFailed |
|
4529 |
! |
|
4530 |
||
4531 |
enableSignal:signalNumber |
|
4532 |
"enable (Unix-)signal processing for signalNumber. |
|
4533 |
Dont confuse Unix signals with smalltalk signals. |
|
4534 |
The signal will be delivered to one of the standard handlers |
|
4535 |
(SIGINT, SIGQUIT, etc) or to a general handler, which |
|
4536 |
sends #signalInterrupt:. |
|
4537 |
||
4538 |
NOTICE that signal numbers are not portable between unix |
|
4539 |
systems - use OperatingSystem sigXXX to get the numeric value for |
|
4540 |
a signal." |
|
4541 |
||
4542 |
%{ /* NOCONTEXT */ |
|
4543 |
||
4544 |
#ifdef NSIG |
|
4545 |
# define SIG_LIMIT NSIG |
|
4546 |
#else |
|
4547 |
# ifdef SIGUSR2 |
|
4548 |
# define SIG_LIMIT SIGUSR2 |
|
4549 |
# else |
|
4550 |
# ifdef SIGUSR |
|
4551 |
# define SIG_LIMIT SIGUSR |
|
4552 |
# endif |
|
4553 |
# endif |
|
4554 |
#endif |
|
4555 |
||
4556 |
#if defined(SIGPOLL) && !defined(SIGIO) |
|
4557 |
# define SIGIO SIGPOLL |
|
4558 |
#endif |
|
4559 |
||
4560 |
#ifdef SIGCHLD |
|
4561 |
# define CHILD_SIGNAL SIGCHLD |
|
4562 |
#else |
|
4563 |
# ifdef SIGCLD |
|
4564 |
# define CHILD_SIGNAL SIGCLD |
|
4565 |
# endif |
|
4566 |
#endif |
|
4567 |
||
4568 |
int sigNr; |
|
4569 |
||
4570 |
#if defined(SIGINT) || defined(SIGQUIT) |
|
4571 |
# ifndef __signalUserInterrupt |
|
4572 |
extern void __signalUserInterrupt(SIGHANDLER_ARG); |
|
4573 |
# endif |
|
4574 |
#endif |
|
4575 |
||
4576 |
#ifdef SIGFPE |
|
4577 |
# ifndef __signalFpExceptionInterrupt |
|
4578 |
extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG); |
|
4579 |
# endif |
|
4580 |
#endif |
|
4581 |
||
4582 |
#ifdef SIGIO |
|
4583 |
# ifndef __signalIoInterrupt |
|
4584 |
extern void __signalIoInterrupt(SIGHANDLER_ARG); |
|
4585 |
# endif |
|
4586 |
#endif |
|
4587 |
||
4588 |
#ifdef CHILD_SIGNAL |
|
4589 |
# ifndef __signalChildInterrupt |
|
4590 |
extern void __signalChildInterrupt(SIGHANDLER_ARG); |
|
4591 |
# endif |
|
4592 |
#endif |
|
4593 |
||
4594 |
#ifdef SIGPIPE |
|
4595 |
# ifndef __signalPIPEInterrupt |
|
4596 |
extern void __signalPIPEInterrupt(SIGHANDLER_ARG); |
|
4597 |
# endif |
|
4598 |
#endif |
|
4599 |
||
4600 |
#ifdef SIGBUS |
|
4601 |
# ifndef __signalBUSInterrupt |
|
4602 |
extern void __signalBUSInterrupt(SIGHANDLER_ARG); |
|
4603 |
# endif |
|
4604 |
#endif |
|
4605 |
||
4606 |
#ifdef SIGSEGV |
|
4607 |
# ifndef __signalSEGVInterrupt |
|
4608 |
extern void __signalSEGVInterrupt(SIGHANDLER_ARG); |
|
4609 |
# endif |
|
4610 |
#endif |
|
4611 |
||
4612 |
#if defined(SIGILL) || defined(SIGEMT) |
|
4613 |
# ifndef __signalTrapInterrupt |
|
4614 |
extern void __signalTrapInterrupt(SIGHANDLER_ARG); |
|
4615 |
# endif |
|
4616 |
#endif |
|
4617 |
||
4618 |
#ifdef SIGALRM |
|
4619 |
# ifndef WIN32 |
|
4620 |
# ifndef __signalTimerInterrupt |
|
4621 |
extern void __signalTimerInterrupt(SIGHANDLER_ARG); |
|
4622 |
# endif |
|
4623 |
# endif |
|
4624 |
#endif |
|
4625 |
||
4626 |
#ifndef __signalInterrupt |
|
4627 |
extern void __signalInterrupt(SIGHANDLER_ARG); |
|
4628 |
#endif |
|
4629 |
void (*handler)(SIGHANDLER_ARG); |
|
4630 |
||
4631 |
if (__isSmallInteger(signalNumber) |
|
4632 |
&& ((sigNr = __intVal(signalNumber)) >= 0) |
|
4633 |
#ifdef SIG_LIMIT |
|
4634 |
&& (sigNr <= SIG_LIMIT) |
|
4635 |
#endif |
|
4636 |
) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4637 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4638 |
* standard signals are forced into standard handlers |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4639 |
* - all others go into general signalInterrupt |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4640 |
*/ |
5133 | 4641 |
#if defined(SIGPOLL) && defined(SIGIO) |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4642 |
if (sigNr == SIGPOLL) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4643 |
sigNr = SIGIO; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4644 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4645 |
switch (sigNr) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4646 |
case 0: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4647 |
/* enabling a non-supported signal */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4648 |
RETURN (self); |
5133 | 4649 |
|
4650 |
#ifdef SIGBREAK |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4651 |
case SIGBREAK: |
5133 | 4652 |
#endif |
4653 |
#ifdef SIGINT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4654 |
case SIGINT: |
5133 | 4655 |
#endif |
4656 |
#ifdef SIGQUIT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4657 |
case SIGQUIT: |
5133 | 4658 |
#endif |
4659 |
#ifdef SIGNALDEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4660 |
printf("ConsoleSignal %d\n",sigNr); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4661 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4662 |
SetConsoleCtrlHandler((PHANDLER_ROUTINE)__signalUserInterruptWIN32,TRUE); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4663 |
RETURN (self); |
5133 | 4664 |
#ifdef SIGFPE |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4665 |
case SIGFPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4666 |
handler = __signalFpExceptionInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4667 |
break; |
5133 | 4668 |
#endif |
4669 |
||
4670 |
#ifdef SIGPIPE |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4671 |
case SIGPIPE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4672 |
handler = __signalPIPEInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4673 |
break; |
5133 | 4674 |
#endif |
4675 |
#ifdef SIGBUS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4676 |
case SIGBUS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4677 |
handler = __signalBUSInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4678 |
break; |
5133 | 4679 |
#endif |
4680 |
#ifdef SIGSEGV |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4681 |
case SIGSEGV: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4682 |
handler = __signalSEGVInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4683 |
break; |
5133 | 4684 |
#endif |
4685 |
#ifdef SIGILL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4686 |
case SIGILL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4687 |
handler = __signalTrapInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4688 |
break; |
5133 | 4689 |
#endif |
4690 |
#ifdef SIGEMT |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4691 |
case SIGEMT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4692 |
handler = __signalTrapInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4693 |
break; |
5133 | 4694 |
#endif |
4695 |
#ifdef SIGIO |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4696 |
case SIGIO: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4697 |
handler = __signalIoInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4698 |
break; |
5133 | 4699 |
#endif |
4700 |
||
4701 |
#ifdef CHILD_SIGNAL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4702 |
case CHILD_SIGNAL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4703 |
handler = __signalChildInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4704 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4705 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4706 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4707 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4708 |
handler = __signalInterrupt; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4709 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4710 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4711 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4712 |
{ |
5133 | 4713 |
#ifdef HAS_SIGACTION |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4714 |
struct sigaction act; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4715 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4716 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4717 |
* 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
|
4718 |
* thread switch, another thread can do a garbage collect |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4719 |
* and restarted system calls may write into old |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4720 |
* (collected) addresses. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4721 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4722 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4723 |
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
|
4724 |
sigemptyset(&act.sa_mask); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4725 |
act.sa_handler = handler; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4726 |
sigaction(sigNr, &act, 0); |
5133 | 4727 |
#else |
4728 |
# ifdef HAS_SIGVEC |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4729 |
struct sigvec vec; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4730 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4731 |
vec.sv_flags = SV_INTERRUPT; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4732 |
sigemptyset(&vec.sv_mask); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4733 |
vec.sv_handler = handler; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4734 |
sigvec(sigNr, &vec, NULL); |
5133 | 4735 |
# else |
4736 |
# ifdef WIN32 |
|
4737 |
# ifdef SIGNALDEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4738 |
printf("signal %d can't change handler\n",sigNr); |
5133 | 4739 |
# endif |
4740 |
# else |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4741 |
(void) signal(sigNr, handler); |
5133 | 4742 |
# endif |
4743 |
# endif |
|
4744 |
#endif |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4745 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4746 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4747 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4748 |
* maybe, we should Return the old enable-status |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4749 |
* as boolean here ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4750 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4751 |
RETURN (self); |
5133 | 4752 |
} |
4753 |
%}. |
|
4754 |
||
4755 |
" |
|
4756 |
this error is triggered on non-integer argument, or |
|
4757 |
if the signal number is not in the valid range (1..NSIG) |
|
4758 |
" |
|
4759 |
^ self primitiveFailed |
|
4760 |
! |
|
4761 |
||
4762 |
enableTimer:milliSeconds |
|
4763 |
"setup for a timerInterrupt, to be signalled after some (real) time." |
|
4764 |
||
4765 |
%{ /* NOCONTEXT */ |
|
4766 |
extern void __win32SetTimer(); |
|
4767 |
||
4768 |
if (__isSmallInteger(milliSeconds)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4769 |
int millis; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4770 |
millis = __intVal(milliSeconds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4771 |
__win32SetTimer(millis); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4772 |
RETURN (true); |
5133 | 4773 |
} |
4774 |
%}. |
|
4775 |
^ false |
|
4776 |
! |
|
4777 |
||
6535 | 4778 |
isFatalSignal:aNumber |
4779 |
"return true if a signal with number aNumber is a fatal signal, |
|
4780 |
i.e. some severe internal error occured" |
|
4781 |
||
4782 |
^ (aNumber == self sigSEGV) |
|
4783 |
or:[aNumber == self sigILL |
|
4784 |
or:[aNumber == self sigBUS]] |
|
4785 |
! |
|
4786 |
||
5133 | 4787 |
killProcess:processId |
4788 |
"kill a process. |
|
4789 |
The process terminates immediately and has no chance to perform any cleanup actions. |
|
4790 |
||
4791 |
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
|
4792 |
you have to fetch the processes exitstatus with |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4793 |
OperatingSystem>>getStatusOfProcess:aProcessId." |
5133 | 4794 |
|
4795 |
self terminateProcess:processId |
|
4796 |
! |
|
4797 |
||
4798 |
sendSignal:signalNumber to:processId |
|
4799 |
"send a unix signal to some process (maybe myself). |
|
4800 |
Returns false if any error occurred, true otherwise. |
|
4801 |
||
4802 |
Do not confuse UNIX signals with Smalltalk-Signals. |
|
4803 |
||
4804 |
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
|
4805 |
you may have to fetch the processes exitstatus with |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4806 |
OperatingSystem>>getStatusOfProcess:aProcessId |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4807 |
if the signal terminates that process." |
5133 | 4808 |
|
4809 |
"/ |
|
4810 |
"/ either invalid argument (non-integers) |
|
4811 |
"/ or not supported by OS |
|
4812 |
"/ |
|
4813 |
^ self primitiveFailed |
|
4814 |
! |
|
4815 |
||
4816 |
terminateProcess:processId |
|
4817 |
"terminate a process. |
|
4818 |
The process has a chance to do some cleanup. |
|
4819 |
WIN32: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4820 |
Under unix, we have terminateProcess, which does a soft |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4821 |
terminate (giving the process a chance to cleanup) and |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4822 |
killProcess, which does a hard terminate. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4823 |
Under WIN32, both (currently) use the TerminateProcess |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4824 |
function, which unconditionally causes a process to exit. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4825 |
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
|
4826 |
Use it only in extreme circumstances. The state of |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4827 |
global data maintained by dynamic-link libraries (DLLs) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4828 |
may be compromised if TerminateProcess is used. |
7065 | 4829 |
TODO: send it a WM_QUIT instead, to allow for proper shutdown." |
4830 |
||
4831 |
self terminateProcess:processId exitCode:0 |
|
4832 |
! |
|
4833 |
||
4834 |
terminateProcess:processId exitCode:exitCode |
|
4835 |
"terminate a process. |
|
4836 |
The process has a chance to do some cleanup. |
|
4837 |
WIN32: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4838 |
Under unix, we have terminateProcess, which does a soft |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4839 |
terminate (giving the process a chance to cleanup) and |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4840 |
killProcess, which does a hard terminate. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4841 |
Under WIN32, both (currently) use the TerminateProcess |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4842 |
function, which unconditionally causes a process to exit. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4843 |
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
|
4844 |
Use it only in extreme circumstances. The state of |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4845 |
global data maintained by dynamic-link libraries (DLLs) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4846 |
may be compromised if TerminateProcess is used. |
5133 | 4847 |
TODO: send it a WM_QUIT instead, to allow for proper shutdown." |
4848 |
||
4849 |
%{ |
|
4850 |
if (__isExternalAddress(processId) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4851 |
HANDLE __pid = _HANDLEVal(processId); |
5133 | 4852 |
|
4853 |
#ifdef PROCESS1DEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4854 |
printf("Terminate ProcessHandle %x\n", __pid); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4855 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4856 |
if (__pid != 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4857 |
TerminateProcess(__pid, __intVal(exitCode)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4858 |
CloseHandle(__pid); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4859 |
_HANDLEVal(processId) = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4860 |
} |
5133 | 4861 |
} |
4862 |
#ifdef PROCESS1DEBUGWIN32 |
|
4863 |
else { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4864 |
printf("Terminate wrong ProcessHandle\n"); |
5133 | 4865 |
} |
4866 |
#endif |
|
4867 |
%} |
|
4868 |
||
4869 |
"Modified: / 28.12.1995 / 15:05:37 / stefan" |
|
4870 |
"Modified: / 27.1.1998 / 20:05:47 / cg" |
|
4871 |
! |
|
4872 |
||
4873 |
terminateProcessGroup:processGroupId |
|
4874 |
"terminate a process group. |
|
4875 |
The processes have a chance to do some cleanup. |
|
4876 |
WIN32: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4877 |
The TerminateProcess function is used to unconditionally cause |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4878 |
a process to exit. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4879 |
Use it only in extreme circumstances. The state of |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4880 |
global data maintained by dynamic-link libraries (DLLs) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4881 |
may be compromised if TerminateProcess is used. |
5133 | 4882 |
Not implemented - TODO: enumerate all sub-processes and terminate them all ..." |
4883 |
||
4884 |
%{ |
|
4885 |
if (__isExternalAddress(processGroupId) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4886 |
HANDLE __pgid = _HANDLEVal(processGroupId); |
5133 | 4887 |
|
4888 |
#ifdef PROCESS1DEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4889 |
printf("primTerminateProcessGroup ProcessHandle %x not yet implemented.\n", __pgid); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4890 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4891 |
if (__pgid != 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4892 |
} |
5133 | 4893 |
} |
4894 |
#ifdef PROCESS1DEBUGWIN32 |
|
4895 |
else { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4896 |
printf("primTerminateProcessGroup wrong ProcessGroupHandle\n"); |
5133 | 4897 |
} |
4898 |
#endif |
|
4899 |
%} |
|
4900 |
! ! |
|
4901 |
||
4902 |
!Win32OperatingSystem class methodsFor:'ipc support'! |
|
4903 |
||
4904 |
makePipe |
|
4905 |
"make a pipe, return array with two filedescriptors on success, |
|
4906 |
nil on failure. |
|
4907 |
This is a lowLevel entry, not for public use. |
|
4908 |
See ExternalStream>>makePipe for a more user-friendly, public interface." |
|
4909 |
||
4910 |
|fd1 fd2| |
|
4911 |
||
4912 |
%{ |
|
4913 |
HANDLE pipeRead = (HANDLE)0; |
|
4914 |
HANDLE pipeWrite = (HANDLE)0; |
|
4915 |
||
4916 |
SECURITY_ATTRIBUTES process; |
|
4917 |
||
4918 |
process.nLength = sizeof( process ); |
|
4919 |
process.lpSecurityDescriptor = NULL; |
|
4920 |
process.bInheritHandle = TRUE; |
|
4921 |
||
4922 |
if( ! CreatePipe( &pipeRead, &pipeWrite, &process, 0 ) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4923 |
@global(LastErrorNumber) = __MKSMALLINT( __WIN32_ERR(GetLastError()) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4924 |
RETURN ( nil ); |
5133 | 4925 |
} |
4926 |
||
4927 |
#ifdef USE_HANDLES |
|
4928 |
fd1 = __MKEXTERNALADDRESS(pipeRead); |
|
4929 |
fd2 = __MKEXTERNALADDRESS(pipeWrite); |
|
4930 |
#else |
|
4931 |
/* |
|
4932 |
* make fileDescriptors from handles |
|
4933 |
*/ |
|
4934 |
# ifdef PROCESSDEBUGWIN32 |
|
4935 |
printf("piperead %x\n",pipeRead); |
|
4936 |
printf("pipewrite %x\n",pipeWrite); |
|
4937 |
# endif |
|
4938 |
fd1 = __MKSMALLINT(_open_osfhandle(pipeRead, O_BINARY)); |
|
4939 |
fd2 = __MKSMALLINT(_open_osfhandle(pipeWrite, O_BINARY)); |
|
4940 |
#endif |
|
4941 |
%}. |
|
4942 |
fd1 notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4943 |
^ Array with:fd1 with:fd2. |
5133 | 4944 |
]. |
4945 |
^ nil |
|
4946 |
! ! |
|
4947 |
||
4948 |
!Win32OperatingSystem class methodsFor:'misc'! |
|
4949 |
||
4950 |
closePid:pid |
|
4951 |
"free pid resource" |
|
4952 |
%{ |
|
4953 |
if (__isExternalAddress(pid) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4954 |
if (_HANDLEVal(pid) != 0) { |
5133 | 4955 |
#ifdef PROCESSDEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4956 |
printf("Close ProcessHandle %x\n",_HANDLEVal(pid)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4957 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4958 |
CloseHandle(_HANDLEVal(pid)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4959 |
_HANDLEVal(pid) = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4960 |
} |
5133 | 4961 |
} |
4962 |
%}. |
|
4963 |
^ true. |
|
4964 |
||
4965 |
"Created: 28.1.1998 / 14:23:04 / md" |
|
4966 |
"Modified: 28.1.1998 / 14:27:18 / md" |
|
4967 |
! ! |
|
4968 |
||
4969 |
!Win32OperatingSystem class methodsFor:'os queries'! |
|
4970 |
||
4971 |
executableFileExtensions |
|
4972 |
"return a collection of extensions for executable program files. |
|
4973 |
Only req'd for msdos like systems ..." |
|
4974 |
||
4975 |
^ #('com' 'exe') |
|
4976 |
||
4977 |
"Created: 2.5.1997 / 11:42:29 / cg" |
|
4978 |
! |
|
4979 |
||
4980 |
getDomainName |
|
4981 |
"return the domain this host is in. |
|
4982 |
Notice: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4983 |
not all systems support this; on some, 'unknown' is returned." |
5133 | 4984 |
|
4985 |
|name idx hostName k| |
|
4986 |
||
4987 |
DomainName notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4988 |
^ DomainName |
5133 | 4989 |
]. |
4990 |
||
4991 |
name := self getEnvironment:'DOMAIN'. |
|
4992 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4993 |
name := self getEnvironment:'DOMAINNAME'. |
5133 | 4994 |
]. |
4995 |
||
4996 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4997 |
"/ sometimes, we can extract the domainName from the hostName ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4998 |
hostName := self getHostName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
4999 |
hostName notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5000 |
idx := hostName indexOf:$.. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5001 |
idx ~~ 0 ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5002 |
name := hostName copyFrom:idx+1. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5003 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5004 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5005 |
name isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5006 |
"/ ok, search the registry ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5007 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5008 |
"/ under NT, it is found there ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5009 |
k := RegistryEntry key:'HKEY_LOCAL_MACHINE\System'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5010 |
k notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5011 |
k subKeysDo:[:subKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5012 |
subKey subKeysDo:[:subSubKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5013 |
|tcp params| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5014 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5015 |
(subSubKey path asLowercase endsWith:'services') ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5016 |
tcp := subSubKey subKeyNamed:'tcpip'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5017 |
tcp notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5018 |
params := tcp subKeyNamed:'parameters'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5019 |
params notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5020 |
name := params valueNamed:'Domain'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5021 |
params close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5022 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5023 |
tcp close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5024 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5025 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5026 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5027 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5028 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5029 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5030 |
name isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5031 |
"/ under Win95/Win98, it is found there ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5032 |
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
|
5033 |
k notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5034 |
name := k valueNamed:'Domain'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5035 |
k close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5036 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5037 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5038 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5039 |
name isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5040 |
'Win32OperatingSystem [warning]: cannot find out domainname' errorPrintCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5041 |
name := 'unknown'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5042 |
] |
5133 | 5043 |
]. |
5044 |
DomainName := name. |
|
5045 |
^ name |
|
5046 |
||
5047 |
" |
|
5048 |
DomainName := nil. OperatingSystem getDomainName |
|
5049 |
OperatingSystem getHostName |
|
5050 |
" |
|
5051 |
||
5052 |
"Modified: 26.4.1996 / 10:04:54 / stefan" |
|
5053 |
! |
|
5054 |
||
5055 |
getEnvironment:aStringOrSymbol |
|
5056 |
"get an environment string" |
|
5057 |
||
5058 |
%{ /* NOCONTEXT */ |
|
5059 |
||
5060 |
char *env; |
|
5061 |
||
5062 |
if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5063 |
char buff[512]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5064 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5065 |
env = NULL; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5066 |
if (GetEnvironmentVariable(__stringVal(aStringOrSymbol), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5067 |
buff, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5068 |
sizeof(buff)-1)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5069 |
env = buff; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5070 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5071 |
if (env) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5072 |
RETURN ( __MKSTRING(env) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5073 |
} |
5133 | 5074 |
} |
5075 |
%} |
|
5076 |
. |
|
5077 |
^ nil |
|
5078 |
||
5079 |
" |
|
5080 |
OperatingSystem getEnvironment:'LANG' |
|
5081 |
OperatingSystem getEnvironment:'LOGIN' |
|
5082 |
OperatingSystem getEnvironment:'HOME' |
|
5083 |
OperatingSystem getEnvironment:'NNTPSERVER' |
|
5084 |
OperatingSystem getEnvironment:'MAIL' |
|
5085 |
OperatingSystem getEnvironment:'PATH' |
|
5086 |
" |
|
5087 |
! |
|
5088 |
||
5089 |
getHostName |
|
5090 |
"return the hostname we are running on - if there is |
|
5091 |
a HOST environment variable, we are much faster here ... |
|
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| |
|
5096 |
||
5097 |
HostName notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5098 |
^ HostName |
5133 | 5099 |
]. |
5100 |
||
5101 |
%{ /* STACK: 2048 */ |
|
5102 |
#if defined(HAS_GETHOSTNAME) |
|
5103 |
char buffer[256]; |
|
5104 |
||
5105 |
if (gethostname(buffer, sizeof(buffer)) == 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5106 |
name = __MKSTRING(buffer); |
5133 | 5107 |
} |
5108 |
#else |
|
5109 |
char buffer[128]; |
|
5110 |
int buffSize = sizeof(buffer); |
|
5111 |
||
5112 |
if (GetComputerName(buffer, &buffSize) == TRUE) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5113 |
name = __MKSTRING(buffer); |
5133 | 5114 |
} |
5115 |
#endif |
|
5116 |
%}. |
|
5117 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5118 |
name := self getEnvironment:'HOST'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5119 |
name isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5120 |
name := self getEnvironment:'HOSTNAME'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5121 |
] |
5133 | 5122 |
]. |
5123 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5124 |
'Win32OperatingSystem [warning]: cannot find out hostname' errorPrintCR. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5125 |
name := 'unknown'. |
5133 | 5126 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5127 |
"/ on some systems, the hostname already contains the domain. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5128 |
"/ decompose it here. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5129 |
idx := name indexOf:$.. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5130 |
idx ~~ 0 ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5131 |
DomainName := name copyFrom:(idx+1). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5132 |
name := name copyTo:(idx-1). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5133 |
] |
5133 | 5134 |
]. |
5135 |
HostName := name. |
|
5136 |
^ name |
|
5137 |
||
5138 |
" |
|
5139 |
OperatingSystem getHostName |
|
5140 |
" |
|
5141 |
! |
|
5142 |
||
5143 |
getLocaleInfo |
|
5144 |
"return a dictionary filled with values from the locale information; |
|
5145 |
Not all fields may be present, depending on the OS's setup and capabilities. |
|
5146 |
Possible fields are: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5147 |
decimalPoint <String> |
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 |
thousandsSep <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5150 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5151 |
internationalCurrencySymbol <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5152 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5153 |
currencySymbol <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5154 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5155 |
monetaryDecimalPoint <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5156 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5157 |
monetaryThousandsSeparator <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5158 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5159 |
positiveSign <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5160 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5161 |
negativeSign <String> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5162 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5163 |
internationalFractionalDigits <Integer> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5164 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5165 |
fractionalDigits <Integer> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5166 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5167 |
positiveSignPrecedesCurrencySymbol <Boolean> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5168 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5169 |
negativeSignPrecedesCurrencySymbol <Boolean> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5170 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5171 |
positiveSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5172 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5173 |
negativeSignSeparatedBySpaceFromCurrencySymbol <Boolean> |
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 |
positiveSignPosition <Symbol> |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5176 |
one of: #parenthesesAround, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5177 |
#signPrecedes, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5178 |
#signSuceeds, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5179 |
#signPrecedesCurrencySymbol, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5180 |
#signSuceedsCurrencySymbol |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5181 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5182 |
negativeSignPosition <like above> |
5133 | 5183 |
|
5184 |
it is up to the application to deal with undefined values. |
|
5185 |
||
5186 |
Notice, that (for now), the system does not use this information; |
|
5187 |
it should be used by applications as required. |
|
5188 |
" |
|
5189 |
||
5190 |
|info val| |
|
5191 |
||
5192 |
LocaleInfo notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5193 |
"/ 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
|
5194 |
"/ support this. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5195 |
^ LocaleInfo |
5133 | 5196 |
]. |
5197 |
||
5198 |
info := IdentityDictionary new. |
|
5199 |
%{ |
|
5200 |
char *decimalPoint; /* something like "." (US) or "," (german) */ |
|
5201 |
char *thousandsSep; /* something like "," (US) or "." (german) */ |
|
5202 |
char *intCurrencySymbol; /* international currency symbol; something like "USD " "DM " */ |
|
5203 |
char *currencySymbol; /* local currency symbol; something like "USD " "DM " */ |
|
5204 |
char *monDecimalPoint; /* money: decimal point */ |
|
5205 |
char *monThousandsSep; /* money: thousands sep */ |
|
5206 |
char *positiveSign; |
|
5207 |
char *negativeSign; |
|
5208 |
int intFractDigits; /* money: international digits after decPoint */ |
|
5209 |
int fractDigits; /* money: local digits after decPoint */ |
|
5210 |
int csPosPrecedes; /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */ |
|
5211 |
int csNegPrecedes; /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */ |
|
5212 |
int csPosSepBySpace; /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */ |
|
5213 |
int csNegSepBySpace; /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */ |
|
5214 |
int csPosSignPosition; /* money: 0: ()'s around the value & currency symbol */ |
|
5215 |
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
|
5216 |
/* 2: sign succeeds the value & currency symbol */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5217 |
/* 3: sign immediately precedes the currency symbol */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5218 |
/* 4: sign immediately suceeds the currency symbol */ |
5133 | 5219 |
|
5220 |
#if defined(HAS_LOCALECONV) |
|
5221 |
struct lconv *conf; |
|
5222 |
||
5223 |
conf = localeconv(); |
|
5224 |
if (conf) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5225 |
decimalPoint = conf->decimal_point; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5226 |
thousandsSep = conf->thousands_sep; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5227 |
intCurrencySymbol = conf->int_curr_symbol; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5228 |
currencySymbol = conf->currency_symbol; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5229 |
monDecimalPoint = conf->mon_decimal_point; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5230 |
monThousandsSep = conf->mon_thousands_sep; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5231 |
positiveSign = conf->positive_sign; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5232 |
negativeSign = conf->negative_sign; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5233 |
intFractDigits = conf->int_frac_digits; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5234 |
fractDigits = conf->frac_digits; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5235 |
csPosPrecedes = conf->p_cs_precedes; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5236 |
csNegPrecedes = conf->n_cs_precedes; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5237 |
csPosSepBySpace = conf->p_sep_by_space; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5238 |
csNegSepBySpace = conf->n_sep_by_space; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5239 |
csPosSignPosition = conf->p_sign_posn; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5240 |
csNegSignPosition = conf->n_sign_posn; |
5133 | 5241 |
} |
5242 |
#else |
|
5243 |
decimalPoint = (char *)0; |
|
5244 |
thousandsSep = (char *)0; |
|
5245 |
intCurrencySymbol = (char *)0; |
|
5246 |
currencySymbol = (char *)0; |
|
5247 |
monDecimalPoint = (char *)0; |
|
5248 |
monThousandsSep = (char *)0; |
|
5249 |
positiveSign = (char *)0; |
|
5250 |
negativeSign =(char *)0; |
|
5251 |
intFractDigits = -1; |
|
5252 |
fractDigits = -1; |
|
5253 |
csPosPrecedes = -1; |
|
5254 |
csNegPrecedes = -1; |
|
5255 |
csPosSepBySpace = -1; |
|
5256 |
csNegSepBySpace = -1; |
|
5257 |
csPosSignPosition = -1; |
|
5258 |
csNegSignPosition = -1; |
|
5259 |
#endif |
|
5260 |
if (decimalPoint) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5261 |
val = __MKSTRING(decimalPoint); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5262 |
__AT_PUT_(info, @symbol(decimalPoint), val); |
5133 | 5263 |
} |
5264 |
if (thousandsSep) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5265 |
val = __MKSTRING(thousandsSep); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5266 |
__AT_PUT_(info, @symbol(thousandsSeparator), val); |
5133 | 5267 |
} |
5268 |
if (intCurrencySymbol) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5269 |
val = __MKSTRING(intCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5270 |
__AT_PUT_(info, @symbol(internationCurrencySymbol), val); |
5133 | 5271 |
} |
5272 |
if (currencySymbol) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5273 |
val = __MKSTRING(currencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5274 |
__AT_PUT_(info, @symbol(currencySymbol), val); |
5133 | 5275 |
} |
5276 |
if (monDecimalPoint) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5277 |
val = __MKSTRING(monDecimalPoint); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5278 |
__AT_PUT_(info, @symbol(monetaryDecimalPoint), val); |
5133 | 5279 |
} |
5280 |
if (monThousandsSep) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5281 |
val = __MKSTRING(monThousandsSep); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5282 |
__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val); |
5133 | 5283 |
} |
5284 |
if (positiveSign) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5285 |
val = __MKSTRING(positiveSign); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5286 |
__AT_PUT_(info, @symbol(positiveSign), val); |
5133 | 5287 |
} |
5288 |
if (negativeSign) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5289 |
val = __MKSTRING(negativeSign); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5290 |
__AT_PUT_(info, @symbol(negativeSign), val); |
5133 | 5291 |
} |
5292 |
if (intFractDigits >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5293 |
__AT_PUT_(info, @symbol(internationalFractionalDigits), __MKSMALLINT(intFractDigits)); |
5133 | 5294 |
} |
5295 |
if (fractDigits >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5296 |
__AT_PUT_(info, @symbol(fractionalDigits), __MKSMALLINT(fractDigits)); |
5133 | 5297 |
} |
5298 |
if (csPosPrecedes >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5299 |
if (csPosPrecedes == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5300 |
val = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5301 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5302 |
val = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5303 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5304 |
__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val ); |
5133 | 5305 |
} |
5306 |
if (csNegPrecedes >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5307 |
if (csNegPrecedes == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5308 |
val = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5309 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5310 |
val = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5311 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5312 |
__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val ); |
5133 | 5313 |
} |
5314 |
if (csPosSepBySpace >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5315 |
if (csPosSepBySpace == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5316 |
val = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5317 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5318 |
val = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5319 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5320 |
__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val); |
5133 | 5321 |
} |
5322 |
if (csNegSepBySpace >= 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5323 |
if (csNegSepBySpace == 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5324 |
val = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5325 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5326 |
val = true; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5327 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5328 |
__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val); |
5133 | 5329 |
} |
5330 |
switch (csPosSignPosition) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5331 |
case 0: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5332 |
val = @symbol(parenthesesAround); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5333 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5334 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5335 |
case 1: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5336 |
val = @symbol(signPrecedes); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5337 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5338 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5339 |
case 2: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5340 |
val = @symbol(signSuceeds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5341 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5342 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5343 |
case 3: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5344 |
val = @symbol(signPrecedesCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5345 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5346 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5347 |
case 4: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5348 |
val = @symbol(signSuceedsCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5349 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5350 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5351 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5352 |
val = nil; |
5133 | 5353 |
} |
5354 |
if (val != nil) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5355 |
__AT_PUT_(info, @symbol(positiveSignPosition), val); |
5133 | 5356 |
} |
5357 |
||
5358 |
switch (csNegSignPosition) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5359 |
case 0: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5360 |
val = @symbol(parenthesesAround); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5361 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5362 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5363 |
case 1: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5364 |
val = @symbol(signPrecedes); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5365 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5366 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5367 |
case 2: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5368 |
val = @symbol(signSuceeds); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5369 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5370 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5371 |
case 3: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5372 |
val = @symbol(signPrecedesCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5373 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5374 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5375 |
case 4: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5376 |
val = @symbol(signSuceedsCurrencySymbol); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5377 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5378 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5379 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5380 |
val = nil; |
5133 | 5381 |
} |
5382 |
if (val != nil) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5383 |
__AT_PUT_(info, @symbol(negativeSignPosition), val); |
5133 | 5384 |
} |
5385 |
%}. |
|
5386 |
^ info |
|
5387 |
||
5388 |
" |
|
5389 |
OperatingSystem getLocaleInfo |
|
5390 |
" |
|
5391 |
||
5392 |
"Created: 23.12.1995 / 14:19:20 / cg" |
|
5393 |
! |
|
5394 |
||
7287
b10efc6c9407
Fix spelling (getNetworkMACAddresses)
Stefan Vogel <sv@exept.de>
parents:
7199
diff
changeset
|
5395 |
getNetworkMACAddresses |
6542 | 5396 |
"return a dictionary filled with |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5397 |
key -> name of interface |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5398 |
value -> the MAC adress (as ByteArray) |
6542 | 5399 |
for each interface |
5400 |
" |
|
5401 |
||
5402 |
|nAdapters rawData| |
|
5403 |
||
5404 |
rawData := ByteArray new:(32 * 6). |
|
5405 |
%{ |
|
6543 | 5406 |
#ifndef NO_GETADAPTERSINFO |
6542 | 5407 |
IP_ADAPTER_INFO AdapterInfo[32]; |
5408 |
DWORD dwBufLen = sizeof(AdapterInfo); |
|
5409 |
DWORD dwStatus; |
|
5410 |
||
5411 |
dwStatus = GetAdaptersInfo( |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5412 |
AdapterInfo, // [out] buffer to receive data |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5413 |
&dwBufLen); // [in] size of receive data buffer |
6542 | 5414 |
|
5415 |
if (dwStatus == ERROR_SUCCESS) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5416 |
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5417 |
unsigned char *bP; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5418 |
int nA = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5419 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5420 |
bP = __byteArrayVal(rawData); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5421 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5422 |
nA++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5423 |
bcopy(pAdapterInfo->Address, bP, 6); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5424 |
bP += 6; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5425 |
// PrintMACaddress(pAdapterInfo->Address); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5426 |
pAdapterInfo = pAdapterInfo->Next; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5427 |
} while(pAdapterInfo); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5428 |
nAdapters = __mkSmallInteger(nA); |
6542 | 5429 |
} |
6543 | 5430 |
#endif /* not NO_GETADAPTERSINFO */ |
6542 | 5431 |
%}. |
5432 |
nAdapters isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5433 |
self primitiveFailed. |
6542 | 5434 |
]. |
5435 |
self halt. |
|
5436 |
! |
|
5437 |
||
5133 | 5438 |
getProcessId |
5439 |
"return the (unix-)processId" |
|
5440 |
||
5441 |
%{ /* NOCONTEXT */ |
|
5442 |
||
5443 |
int pid = 0; |
|
5444 |
||
5445 |
pid = GetCurrentProcessId() & 0x3FFFFFFF; |
|
5446 |
RETURN ( __MKSMALLINT(pid) ); |
|
5447 |
%} |
|
5448 |
" |
|
5449 |
OperatingSystem getProcessId |
|
5450 |
" |
|
5451 |
! |
|
5452 |
||
5453 |
getSystemID |
|
5454 |
"if supported by the OS, return the systemID; |
|
5455 |
a unique per machine identification. |
|
5456 |
WARNING: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5457 |
not all systems support this; on some, 'unknown' is returned." |
5133 | 5458 |
|
5459 |
%{ /* NO_CONTEXT */ |
|
5460 |
#if defined(HAS_GETHOSTID) |
|
5461 |
int runningId; |
|
5462 |
OBJ arr; |
|
5463 |
||
5464 |
runningId = gethostid(); |
|
5465 |
arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4); |
|
5466 |
*(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId; |
|
5467 |
RETURN (arr); |
|
5468 |
#endif |
|
5469 |
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL) |
|
5470 |
{ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5471 |
char buffer[128]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5472 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5473 |
buffer[0] = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5474 |
if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5475 |
buffer[127] = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5476 |
if (strlen(buffer) > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5477 |
RETURN(__MKSTRING(buffer)); |
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 |
} |
5133 | 5480 |
} |
5481 |
#endif |
|
5482 |
%}. |
|
5483 |
^ 'unknown' |
|
5484 |
||
5485 |
" |
|
5486 |
OperatingSystem getSystemID |
|
5487 |
" |
|
5488 |
! |
|
5489 |
||
5490 |
getSystemInfo |
|
5491 |
"return info on the system weare running on. |
|
5492 |
If the system supports the uname system call, that info is returned; |
|
5493 |
otherwise, some simulated info is returned. |
|
5494 |
||
5495 |
WARNING: |
|
5496 |
Do not depend on the amount and contents of the returned information, some |
|
5497 |
systems may return more/less than others. Also, the contents depends on the |
|
5498 |
OS, for example, linux returns 'ix86', while WIN32 returns 'x86'. |
|
5499 |
||
5500 |
This method is mainly provided to augment error reports with some system |
|
5501 |
information. |
|
5502 |
(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
|
5503 |
may be based upon this info). |
5133 | 5504 |
Your application should NOT depend upon this in any way. |
5505 |
||
5506 |
The returned info may (or may not) contain: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5507 |
#system -> some operating system identification (irix, Linux, nt, win32s ...) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5508 |
#version -> OS version (some os version identification) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5509 |
#release -> OS release (3.5, 1.2.1 ...) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5510 |
#node -> some host identification (hostname) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5511 |
#domain -> domain name (hosts domain) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5512 |
#machine -> type of machine (i586, mips ...) |
5133 | 5513 |
|
5514 |
win32: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5515 |
#physicalRam -> total amount of physical memory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5516 |
#freeRam -> amount of free memory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5517 |
#swapSize -> size of swapSpace (page file) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5518 |
#freeSwap -> free bytes in swapSpace |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5519 |
#virtualRam -> total amount of virtual memory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5520 |
#freeVirtual -> amount of free virtual memory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5521 |
#memoryLoad -> percentage of memory usage (useless) |
6740
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5522 |
" |
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5523 |
|
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5524 |
|sys node rel ver mach dom info arch |
5133 | 5525 |
physicalRam freeRam swapSize freeSwap |
5526 |
virtualRam freeVirtual memoryLoad| |
|
5527 |
||
5528 |
%{ /* STACK: 4096 */ |
|
5529 |
||
5530 |
char vsnBuffer[32]; |
|
5531 |
char *s; |
|
6740
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5532 |
int winVer, verMinor, verMajor; |
5133 | 5533 |
DWORD vsn; |
5534 |
SYSTEM_INFO sysInfo; |
|
5535 |
MEMORYSTATUS memStatus; |
|
5536 |
||
5537 |
vsn = GetVersion(); |
|
6740
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5538 |
winVer = LOWORD(vsn); |
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5539 |
verMinor = HIBYTE(winVer); |
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5540 |
verMajor = LOBYTE(winVer); |
5133 | 5541 |
|
5542 |
if (HIWORD(vsn) & 0x8000) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5543 |
s = "win95"; |
5133 | 5544 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5545 |
if ((verMajor > 5) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5546 |
|| ((verMajor == 5) && (verMinor >= 1))) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5547 |
s = "xp"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5548 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5549 |
s = "nt"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5550 |
} |
5133 | 5551 |
} |
5552 |
sys = __MKSTRING(s); |
|
6740
809af7f7f2b9
getSystemInfo: knows about XP
Claus Gittinger <cg@exept.de>
parents:
6726
diff
changeset
|
5553 |
sprintf(vsnBuffer, "%d.%d", verMajor, verMinor); |
5133 | 5554 |
rel = __MKSTRING(vsnBuffer); |
5555 |
||
5556 |
GetSystemInfo(&sysInfo); |
|
5557 |
memStatus.dwLength = sizeof(memStatus); |
|
5558 |
GlobalMemoryStatus(&memStatus); |
|
5559 |
||
5560 |
memoryLoad = __MKUINT(memStatus.dwMemoryLoad); |
|
5561 |
physicalRam = __MKUINT(memStatus.dwTotalPhys); |
|
5562 |
freeRam = __MKUINT(memStatus.dwAvailPhys); |
|
5563 |
swapSize = __MKUINT(memStatus.dwTotalPageFile); |
|
5564 |
freeSwap = __MKUINT(memStatus.dwAvailPageFile); |
|
5565 |
virtualRam = __MKUINT(memStatus.dwTotalVirtual); |
|
5566 |
freeVirtual = __MKUINT(memStatus.dwAvailVirtual); |
|
5567 |
||
5568 |
#if defined(__BORLANDC__) && (__BORLANDC__ <= 1339) |
|
5569 |
/* BorlandC3 ... */ |
|
5570 |
switch (sysInfo.u.s.wProcessorArchitecture) |
|
5571 |
#else |
|
5572 |
/* MSC, BorlandC4 ... */ |
|
5573 |
switch (sysInfo.wProcessorArchitecture) |
|
5574 |
#endif |
|
5575 |
{ |
|
5576 |
#ifdef PROCESSOR_ARCHITECTURE_INTEL |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5577 |
case PROCESSOR_ARCHITECTURE_INTEL: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5578 |
s = "intel"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5579 |
break; |
5133 | 5580 |
#endif |
5581 |
#ifdef PROCESSOR_ARCHITECTURE_MIPS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5582 |
case PROCESSOR_ARCHITECTURE_MIPS: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5583 |
s = "mips"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5584 |
break; |
5133 | 5585 |
#endif |
5586 |
#ifdef PROCESSOR_ARCHITECTURE_ALPHA |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5587 |
case PROCESSOR_ARCHITECTURE_ALPHA: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5588 |
s = "alpha"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5589 |
break; |
5133 | 5590 |
#endif |
5591 |
#ifdef PROCESSOR_ARCHITECTURE_PPC |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5592 |
case PROCESSOR_ARCHITECTURE_PPC: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5593 |
s = "ppc"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5594 |
break; |
5133 | 5595 |
#endif |
5596 |
#ifdef PROCESSOR_ARCHITECTURE_ARM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5597 |
case PROCESSOR_ARCHITECTURE_ARM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5598 |
s = "arm"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5599 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5600 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5601 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5602 |
s = "unknown"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5603 |
break; |
5133 | 5604 |
} |
5605 |
arch = __MKSTRING(s); |
|
5606 |
||
5607 |
switch (sysInfo.dwProcessorType) { |
|
5608 |
#ifdef PROCESSOR_INTEL_386 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5609 |
case PROCESSOR_INTEL_386: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5610 |
s = "i386"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5611 |
break; |
5133 | 5612 |
#endif |
5613 |
#ifdef PROCESSOR_INTEL_486 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5614 |
case PROCESSOR_INTEL_486: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5615 |
s = "i486"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5616 |
break; |
5133 | 5617 |
#endif |
5618 |
#ifdef PROCESSOR_INTEL_PENTIUM |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5619 |
case PROCESSOR_INTEL_PENTIUM: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5620 |
s = "i586"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5621 |
break; |
5133 | 5622 |
#endif |
5623 |
#ifdef PROCESSOR_INTEL_860 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5624 |
case PROCESSOR_INTEL_860: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5625 |
s = "i860"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5626 |
break; |
5133 | 5627 |
#endif |
5628 |
#ifdef PROCESSOR_MIPS_R2000 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5629 |
case PROCESSOR_MIPS_R2000: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5630 |
s = "r2000"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5631 |
break; |
5133 | 5632 |
#endif |
5633 |
#ifdef PROCESSOR_MIPS_R3000 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5634 |
case PROCESSOR_MIPS_R3000: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5635 |
s = "r3000"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5636 |
break; |
5133 | 5637 |
#endif |
5638 |
#ifdef PROCESSOR_MIPS_R4000 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5639 |
case PROCESSOR_MIPS_R4000: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5640 |
s = "r4000"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5641 |
break; |
5133 | 5642 |
#endif |
5643 |
#ifdef PROCESSOR_ALPHA_21064 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5644 |
case PROCESSOR_ALPHA_21064: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5645 |
s = "alpha21064"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5646 |
break; |
5133 | 5647 |
#endif |
5648 |
#ifdef PROCESSOR_ARM_7TDMI |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5649 |
case PROCESSOR_ARM_7TDMI: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5650 |
s = "arm70001"; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5651 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5652 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5653 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5654 |
sprintf(vsnBuffer, "%d", sysInfo.dwProcessorType); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5655 |
s = vsnBuffer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5656 |
break; |
5133 | 5657 |
} |
5658 |
mach = __MKSTRING(s); |
|
5659 |
%}. |
|
5660 |
sys isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5661 |
sys := self getSystemType. |
5133 | 5662 |
]. |
5663 |
node isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5664 |
node := self getHostName. |
5133 | 5665 |
]. |
5666 |
dom isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5667 |
dom := self getDomainName. |
5133 | 5668 |
]. |
5669 |
mach isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5670 |
mach := self getCPUType. |
5133 | 5671 |
]. |
5672 |
arch isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5673 |
arch := 'unknown'. |
5133 | 5674 |
]. |
5675 |
||
5676 |
info := IdentityDictionary new. |
|
5677 |
info at:#system put:sys. |
|
5678 |
info at:#node put:node. |
|
5679 |
rel notNil ifTrue:[info at:#release put:rel]. |
|
5680 |
ver notNil ifTrue:[info at:#version put:ver]. |
|
5681 |
mach notNil ifTrue:[info at:#machine put:mach]. |
|
5682 |
arch notNil ifTrue:[info at:#architecture put:arch]. |
|
5683 |
dom notNil ifTrue:[info at:#domain put:dom]. |
|
5684 |
||
5685 |
info at:#memoryLoad put:memoryLoad. |
|
5686 |
info at:#physicalRam put:physicalRam. |
|
5687 |
info at:#freeRam put:freeRam. |
|
5688 |
info at:#swapSize put:swapSize. |
|
5689 |
info at:#freeSwap put:freeSwap. |
|
5690 |
info at:#virtualRam put:virtualRam. |
|
5691 |
info at:#freeVirtual put:freeVirtual. |
|
5692 |
||
5693 |
info at:#osType put:(self getOSType). |
|
5694 |
^ info |
|
5695 |
||
5696 |
" |
|
5697 |
OperatingSystem getSystemInfo |
|
5698 |
" |
|
5699 |
! |
|
5700 |
||
5701 |
getSystemType |
|
5702 |
"return a string giving the type of system we're running on. |
|
5703 |
This is almost the same as getOSType, but the returned string |
|
5704 |
is slightly different for some systems (i.e. iris vs. irix). |
|
5705 |
Dont depend on this - use getOSType. I dont really see a point |
|
5706 |
here ... |
|
5707 |
(except for slight differences between next/mach and other machs)" |
|
5708 |
||
5709 |
^ 'win32' |
|
5710 |
||
5711 |
" |
|
5712 |
OperatingSystem getSystemType |
|
5713 |
" |
|
5714 |
! |
|
5715 |
||
5716 |
getWindowsDirectory |
|
5717 |
"internal interface - only for Windows based systems. |
|
5718 |
Return the windows directory |
|
5719 |
(which - depending on the system - may be \WINNT, \WINDOWS or whatever) |
|
5720 |
On non-windows systems, nil is returned." |
|
5721 |
||
5722 |
%{ |
|
5723 |
char buffer[MAXPATHLEN]; |
|
5724 |
||
5725 |
if (GetWindowsDirectory(buffer, MAXPATHLEN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5726 |
RETURN (__MKSTRING(buffer)); |
5133 | 5727 |
} |
5728 |
%}. |
|
5729 |
^ nil |
|
5730 |
||
5731 |
" |
|
5732 |
OperatingSystem getWindowsDirectory |
|
5733 |
" |
|
5734 |
! |
|
5735 |
||
5736 |
getWindowsSystemDirectory |
|
5737 |
"internal interface - only for Windows based systems. |
|
5738 |
Return the windows system directory |
|
5739 |
(which - depending on the system - may be \WINNT\SYSTEM32, |
|
5740 |
\WINDOWS\SYSTEM or whatever) |
|
5741 |
On non-windows systems, nil is returned." |
|
5742 |
||
5743 |
%{ |
|
5744 |
char buffer[MAXPATHLEN]; |
|
5745 |
||
5746 |
if (GetSystemDirectory(buffer, MAXPATHLEN)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5747 |
RETURN (__MKSTRING(buffer)); |
5133 | 5748 |
} |
5749 |
%}. |
|
5750 |
^ nil |
|
5751 |
||
5752 |
" |
|
5753 |
OperatingSystem getWindowsSystemDirectory |
|
5754 |
" |
|
5755 |
! |
|
5756 |
||
5757 |
hasConsole |
|
5758 |
"return true, if there is some kind of console available |
|
5759 |
(i.e. for proper stdIn, stdOut and stdErr handling). |
|
5760 |
This only returns false when running únder windows, and |
|
5761 |
the system is running as a pure windows application. |
|
5762 |
If false, the miniDebugger is useless and not used." |
|
5763 |
||
5764 |
%{ /* NOCONTEXT */ |
|
5765 |
extern int __getNoConsoleFlag(); |
|
5766 |
||
5767 |
RETURN ( __getNoConsoleFlag() ? false : true); |
|
5768 |
%} |
|
5769 |
! |
|
5770 |
||
5771 |
isMSDOSlike |
|
5772 |
"return true, if the OS we're running on is msdos like |
|
5773 |
(in contrast to unix-like or vms-like). |
|
5774 |
This returns true for any of msdos, win32s, win95, |
|
5775 |
winNT and os/2." |
|
5776 |
||
5777 |
^ true |
|
5778 |
! |
|
5779 |
||
5780 |
isMSWINDOWSNTlike |
|
5781 |
"This returns true if running in a Windows-NT system." |
|
5782 |
||
5783 |
%{ /* NOCONTEXT */ |
|
5784 |
if (__isWinNT) |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5785 |
RETURN(true); |
5133 | 5786 |
%}. |
5787 |
^ false. |
|
5788 |
! |
|
5789 |
||
5790 |
isMSWINDOWSlike |
|
5791 |
"return true, if running on a MS-Windows like system. |
|
5792 |
This returns true for any of win32s, win95 and winNT." |
|
5793 |
||
5794 |
^ true |
|
5795 |
! |
|
5796 |
||
5797 |
maxFileNameLength |
|
5798 |
"return the max number of characters in a filename. |
|
5799 |
CAVEAT: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5800 |
Actually, the following is somewhat wrong - some systems |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5801 |
support different sizes, depending on the volume. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5802 |
We return a somewhat conservative number here. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5803 |
Another entry, to query for volume specific max |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
5804 |
will be added in the future." |
5133 | 5805 |
|
5806 |
%{ /* NOCONTEXT */ |
|
5807 |
||
5808 |
/* |
|
5809 |
* TODO: newer systems provide a query function for this ... use it |
|
5810 |
*/ |
|
5811 |
/* |
|
5812 |
* mhmh - depends on the filesystem type |
|
5813 |
*/ |
|
5814 |
RETURN ( __MKSMALLINT(MAXFILELEN) ); |
|
5815 |
%} |
|
5816 |
" |
|
5817 |
OperatingSystem maxFileNameLength |
|
5818 |
" |
|
5819 |
! |
|
5820 |
||
5821 |
maxPathLength |
|
5822 |
"return the max number of characters in a pathName." |
|
5823 |
||
5824 |
%{ /* NOCONTEXT */ |
|
5825 |
RETURN ( __MKSMALLINT(MAXPATHLEN) ); |
|
5826 |
%} |
|
5827 |
" |
|
5828 |
OperatingSystem maxPathLength |
|
5829 |
" |
|
5830 |
! |
|
5831 |
||
5832 |
pathSeparator |
|
5833 |
"return the character which separates items in the PATH variable" |
|
5834 |
||
5835 |
^ $; |
|
5836 |
||
5837 |
"Created: 2.5.1997 / 11:36:47 / cg" |
|
5838 |
! |
|
5839 |
||
5840 |
platformName |
|
5841 |
"return a string describing the OS platform very we're running on. |
|
5842 |
This returns #unix for all unix derivatives, |
|
5843 |
#os2, #win32, #vms or #mac for the others. |
|
5844 |
I.e. it is much less specific than getOSType or getSystemType." |
|
5845 |
||
5846 |
^ #win32 |
|
5847 |
||
5848 |
" |
|
5849 |
OperatingSystem platformName |
|
5850 |
" |
|
5851 |
||
5852 |
"Modified: 20.6.1997 / 17:37:26 / cg" |
|
5853 |
! |
|
5854 |
||
7158 | 5855 |
primGetDomainName |
5856 |
%{ |
|
5857 |
#if 0 /* not needed */ |
|
5858 |
HINSTANCE hNetApi32 = LoadLibrary("netapi32.dll"); |
|
5859 |
DWORD (__stdcall *pfnNetApiBufferFree)(LPVOID Buffer); |
|
5860 |
DWORD (__stdcall *pfnNetWkstaGetInfo)(LPWSTR servername, DWORD level, void *bufptr); |
|
5861 |
||
5862 |
if (hNetApi32) { |
|
5863 |
pfnNetApiBufferFree = (DWORD (__stdcall *)(void *)) GetProcAddress(hNetApi32, "NetApiBufferFree"); |
|
5864 |
pfnNetWkstaGetInfo = (DWORD (__stdcall *)(LPWSTR, DWORD, void *)) GetProcAddress(hNetApi32, "NetWkstaGetInfo"); |
|
5865 |
} |
|
5866 |
||
5867 |
if (hNetApi32 && pfnNetWkstaGetInfo && pfnNetApiBufferFree) { |
|
5868 |
/* this way is more reliable, in case user has a local account. */ |
|
5869 |
char dname[256]; |
|
5870 |
DWORD dnamelen = sizeof(dname); |
|
5871 |
struct { |
|
5872 |
DWORD wki100_platform_id; |
|
5873 |
LPWSTR wki100_computername; |
|
5874 |
LPWSTR wki100_langroup; |
|
5875 |
DWORD wki100_ver_major; |
|
5876 |
DWORD wki100_ver_minor; |
|
5877 |
} *pwi; |
|
5878 |
||
5879 |
/* NERR_Success *is* 0*/ |
|
5880 |
if (0 == pfnNetWkstaGetInfo(NULL, 100, &pwi)) { |
|
5881 |
if (pwi->wki100_langroup && *(pwi->wki100_langroup)) { |
|
5882 |
WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_langroup, |
|
5883 |
-1, (LPSTR)dname, dnamelen, NULL, NULL); |
|
5884 |
} |
|
5885 |
else { |
|
5886 |
WideCharToMultiByte(CP_ACP, NULL, pwi->wki100_computername, |
|
5887 |
-1, (LPSTR)dname, dnamelen, NULL, NULL); |
|
5888 |
} |
|
5889 |
pfnNetApiBufferFree(pwi); |
|
5890 |
FreeLibrary(hNetApi32); |
|
5891 |
RETURN (__MKSTRING(dname)); |
|
5892 |
} |
|
5893 |
FreeLibrary(hNetApi32); |
|
5894 |
} else { |
|
5895 |
/* Win95 doesn't have NetWksta*(), so do it the old way */ |
|
5896 |
char name[256]; |
|
5897 |
DWORD size = sizeof(name); |
|
5898 |
if (hNetApi32) |
|
5899 |
FreeLibrary(hNetApi32); |
|
5900 |
if (GetUserName(name,&size)) { |
|
5901 |
char sid[1024]; |
|
5902 |
DWORD sidlen = sizeof(sid); |
|
5903 |
char dname[256]; |
|
5904 |
DWORD dnamelen = sizeof(dname); |
|
5905 |
SID_NAME_USE snu; |
|
5906 |
if (LookupAccountName(NULL, name, (PSID)&sid, &sidlen, |
|
5907 |
dname, &dnamelen, &snu)) { |
|
5908 |
RETURN (__MKSTRING(dname)); /* all that for this */ |
|
5909 |
} |
|
5910 |
} |
|
5911 |
} |
|
5912 |
#endif /* not needed */ |
|
5913 |
%}. |
|
5914 |
^ nil |
|
5915 |
! |
|
5916 |
||
5133 | 5917 |
setLocaleInfo:anInfoDictionary |
5918 |
"set the locale information; if set, this oerrides the OS's settings. |
|
5919 |
(internal in ST/X only - the OS's settings remain unaffected) |
|
5920 |
See description of fields in #getLocaleInfo. |
|
5921 |
||
5922 |
Notice, that (for now), the system does not use this information; |
|
5923 |
it should be used by applications as required." |
|
5924 |
||
5925 |
LocaleInfo := anInfoDictionary |
|
5926 |
||
5927 |
" |
|
5928 |
|d| |
|
5929 |
||
5930 |
d := IdentityDictionary new. |
|
5931 |
d at:#decimalPoint put:'.' . |
|
5932 |
d at:#thousandsSeparator put:',' . |
|
5933 |
d at:#currencySymbol put:'USD' . |
|
5934 |
d at:#monetaryDecimalPoint put:'.' . |
|
5935 |
d at:#monetaryThousandsSeparator put:'.' . |
|
5936 |
d at:#fractionalDigits put:2 . |
|
5937 |
d at:#positiveSign put:'+' . |
|
5938 |
d at:#negativeSign put:'-' . |
|
5939 |
d at:#positiveSignPrecedesCurrencySymbol put:true . |
|
5940 |
d at:#negativeSignPrecedesCurrencySymbol put:false . |
|
5941 |
OperatingSystem setLocaleInfo:d |
|
5942 |
" |
|
5943 |
! |
|
5944 |
||
5945 |
supportsChildInterrupts |
|
5946 |
"return true, if the OS supports childProcess termination signalling |
|
5947 |
through interrupts (i.e. SIGCHILD)" |
|
5948 |
||
5949 |
%{ /* NOCONTEXT */ |
|
5950 |
#if defined(SIGCHLD) || defined(SIGCLD) |
|
5951 |
RETURN (true); |
|
5952 |
#endif |
|
5953 |
%}. |
|
5954 |
^ false |
|
5955 |
||
5956 |
" |
|
5957 |
OperatingSystem supportsChildInterrupts |
|
5958 |
" |
|
5959 |
! |
|
5960 |
||
5961 |
supportsFileOwnerGroups |
|
5962 |
"return true, if the OS's file system supports file |
|
5963 |
group ownership - all OS's except windows do" |
|
5964 |
||
5965 |
^ false |
|
5966 |
||
5967 |
"Created: / 10.9.1998 / 17:57:03 / cg" |
|
5968 |
! |
|
5969 |
||
5970 |
supportsFileOwners |
|
5971 |
"return true, if the OS's file system supports file |
|
5972 |
ownership - all OS's except windows do" |
|
5973 |
||
5974 |
^ false |
|
5975 |
||
5976 |
"Created: / 10.9.1998 / 17:55:16 / cg" |
|
5977 |
"Modified: / 10.9.1998 / 17:57:11 / cg" |
|
5978 |
! |
|
5979 |
||
5980 |
supportsIOInterrupts |
|
5981 |
"return true, if the OS supports IO availability interrupts |
|
5982 |
(i.e. SIGPOLL/SIGIO). |
|
5983 |
||
5984 |
Currently, this mechanism does not work on all |
|
5985 |
systems ... |
|
5986 |
" |
|
5987 |
||
5988 |
^ false |
|
5989 |
||
5990 |
" |
|
5991 |
OperatingSystem supportsIOInterrupts |
|
5992 |
" |
|
5993 |
! |
|
5994 |
||
5995 |
supportsNonBlockingIO |
|
5996 |
"return true, if the OS supports nonblocking IO." |
|
5997 |
||
5998 |
^ false |
|
5999 |
||
6000 |
" |
|
6001 |
OperatingSystem supportsNonBlockingIO |
|
6002 |
" |
|
6003 |
! |
|
6004 |
||
6005 |
supportsSelect |
|
6006 |
"return true, if the OS supports selecting on multiple |
|
6007 |
filedescriptors via select. |
|
6008 |
If false is returned, ProcessorScheduler will poll in 50ms |
|
6009 |
intervals for I/O becoming ready." |
|
6010 |
||
6011 |
%{ /* NOCONTEXT */ |
|
6012 |
||
6013 |
# if defined(WIN32S) |
|
6014 |
RETURN (false); |
|
6015 |
# endif |
|
6016 |
%}. |
|
6017 |
^ true |
|
6018 |
||
6019 |
" |
|
6020 |
OperatingSystem supportsSelect |
|
6021 |
" |
|
6022 |
! |
|
6023 |
||
6024 |
supportsSelectOnPipes |
|
6025 |
"return true, if the OS supports selecting on pipe |
|
6026 |
filedescriptors via select. |
|
6027 |
If false is returned, ProcessorScheduler will poll in 50ms |
|
6028 |
intervals for I/O becoming ready." |
|
6029 |
||
6030 |
^ false |
|
6031 |
||
6032 |
" |
|
6033 |
OperatingSystem supportsSelectOnPipes |
|
6034 |
" |
|
6035 |
||
6036 |
"Modified: / 14.12.1999 / 19:41:03 / cg" |
|
6037 |
"Created: / 14.12.1999 / 19:43:13 / cg" |
|
6038 |
! |
|
6039 |
||
6040 |
supportsSelectOnSockets |
|
6041 |
"return true, if the OS supports selecting on socket |
|
6042 |
filedescriptors via select. |
|
6043 |
If false is returned, ProcessorScheduler will poll in 50ms |
|
6044 |
intervals for I/O becoming ready." |
|
6045 |
||
6046 |
^ false |
|
6047 |
||
6048 |
" |
|
6049 |
OperatingSystem supportsSelectOnSockets |
|
6050 |
" |
|
6051 |
||
6052 |
"Modified: / 14.12.1999 / 19:41:03 / cg" |
|
6053 |
! |
|
6054 |
||
6055 |
supportsVolumes |
|
6056 |
"return true, if the OS supports disk volumes. |
|
6057 |
False is returned for UNIX, true for MSDOS and VMS" |
|
6058 |
||
6059 |
^ true |
|
6060 |
! ! |
|
6061 |
||
6062 |
!Win32OperatingSystem class methodsFor:'path queries'! |
|
6063 |
||
5144 | 6064 |
defaultPackagePath |
5147 | 6065 |
|pPath pkgDirPath dirs p| |
5144 | 6066 |
|
6067 |
pPath := super defaultPackagePath. |
|
6068 |
pkgDirPath := self stxPackageDirPath. |
|
6069 |
pkgDirPath notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6070 |
"/ and also add the packageDirPath from the registry ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6071 |
dirs := pkgDirPath asCollectionOfSubstringsSeparatedBy:$;. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6072 |
dirs do:[:aDir | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6073 |
(pPath includes:aDir) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6074 |
pPath add:aDir. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6075 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6076 |
] |
5144 | 6077 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6078 |
#( |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6079 |
'\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6080 |
'\programme\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6081 |
'\programme\eXept\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6082 |
'\programs\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6083 |
'\programs\eXept\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6084 |
) do:[:d | |dd| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6085 |
dd := d asFilename constructString:'packages'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6086 |
(pPath includes:dd) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6087 |
pPath add:dd. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6088 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6089 |
dd := (d asFilename construct:Smalltalk versionString) constructString:'packages'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6090 |
(pPath includes:dd) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6091 |
pPath add:dd. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6092 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6093 |
]. |
5144 | 6094 |
]. |
6095 |
||
6096 |
"/ under windows, the commandName includes the path - good. |
|
5922 | 6097 |
p := Smalltalk commandName. |
6098 |
p notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6099 |
p := p asFilename directory constructString:'packages'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6100 |
(pPath includes:p) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6101 |
pPath add:p. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6102 |
] |
5147 | 6103 |
]. |
5144 | 6104 |
pPath := pPath select:[:p | p asFilename exists]. |
6105 |
^ pPath |
|
6106 |
||
6107 |
" |
|
6108 |
self defaultPackagePath |
|
6109 |
" |
|
6110 |
||
6111 |
"Created: / 24.12.1999 / 00:10:41 / cg" |
|
5147 | 6112 |
"Modified: / 24.12.1999 / 00:33:26 / cg" |
5144 | 6113 |
! |
6114 |
||
5133 | 6115 |
defaultSystemPath |
5147 | 6116 |
|sysPath libDirPath p| |
5133 | 6117 |
|
6118 |
sysPath := super defaultSystemPath. |
|
5136 | 6119 |
libDirPath := self stxLibDirPath. |
6120 |
libDirPath notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6121 |
"/ and also add the libDirPath from the registry ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6122 |
(sysPath includes:libDirPath) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6123 |
sysPath add:libDirPath |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6124 |
]. |
5136 | 6125 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6126 |
#( |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6127 |
'\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6128 |
'\programme\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6129 |
'\programme\eXept\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6130 |
'\programs\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6131 |
'\programs\eXept\smalltalk' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6132 |
) do:[:d | |dd| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6133 |
(d asFilename isDirectory) ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6134 |
(sysPath includes:d) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6135 |
sysPath add:d. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6136 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6137 |
dd := d , '\' , Smalltalk versionString. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6138 |
(sysPath includes:dd) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6139 |
sysPath add:dd. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6140 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6141 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6142 |
]. |
5133 | 6143 |
]. |
6144 |
||
6145 |
"/ under windows, the commandName includes the path - good. |
|
5918 | 6146 |
p := Smalltalk commandName. |
6147 |
p notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6148 |
p := p asFilename directoryName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6149 |
(sysPath includes:p) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6150 |
sysPath add:p. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6151 |
] |
5147 | 6152 |
]. |
5133 | 6153 |
^ sysPath |
5136 | 6154 |
|
5147 | 6155 |
"Modified: / 24.12.1999 / 00:29:18 / cg" |
5133 | 6156 |
! |
6157 |
||
6158 |
stxBinDirPath |
|
6159 |
"ask the registry for the binary directory" |
|
6160 |
||
6161 |
|k p| |
|
6162 |
||
6163 |
k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString. |
|
6164 |
k notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6165 |
p := k valueNamed:'BinDir'. |
5133 | 6166 |
]. |
6167 |
^ p |
|
6168 |
||
6169 |
" |
|
6170 |
OperatingSystem stxBinDirPath |
|
6171 |
" |
|
6172 |
! |
|
6173 |
||
6174 |
stxLibDirPath |
|
6175 |
"ask the registry for the lib directory" |
|
6176 |
||
6177 |
|k p| |
|
6178 |
||
6179 |
k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString. |
|
6180 |
k notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6181 |
p := k valueNamed:'LibDir'. |
5133 | 6182 |
]. |
6183 |
^ p |
|
6184 |
||
6185 |
" |
|
6186 |
OperatingSystem stxLibDirPath |
|
6187 |
" |
|
5144 | 6188 |
! |
6189 |
||
6190 |
stxPackageDirPath |
|
6191 |
"ask the registry for the package directory" |
|
6192 |
||
6193 |
|k p| |
|
6194 |
||
6195 |
k := RegistryEntry key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X\' , Smalltalk versionString. |
|
6196 |
k notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6197 |
p := k valueNamed:'PackageDirPath'. |
5144 | 6198 |
]. |
6199 |
^ p |
|
6200 |
||
6201 |
" |
|
6202 |
OperatingSystem stxPackageDirPath |
|
6203 |
" |
|
6204 |
||
6205 |
"Created: / 24.12.1999 / 00:11:12 / cg" |
|
5133 | 6206 |
! ! |
6207 |
||
6208 |
!Win32OperatingSystem class methodsFor:'private'! |
|
6209 |
||
6210 |
osProcessStatusClass |
|
6211 |
^ OSProcessStatus |
|
6212 |
||
6213 |
"Created: / 12.6.1998 / 16:30:43 / cg" |
|
6214 |
! ! |
|
6215 |
||
6216 |
!Win32OperatingSystem class methodsFor:'system management'! |
|
6217 |
||
6218 |
exitWindows |
|
6219 |
"do not use - may be removed without notice" |
|
6220 |
||
6221 |
self exitWindows:#shutdown confirm:'Do you really want to shutdown the system' |
|
6222 |
! |
|
6223 |
||
6224 |
exitWindows:how confirm:confirmationMessageOrNil |
|
6225 |
"this method is temporary - |
|
6226 |
since my windows system menu crashes so often |
|
6227 |
(even CTRL-ALT-DEL does no longer function, but ST/X is |
|
6228 |
still alive), |
|
6229 |
I added this in order to be able to shutdown w95 cleanly" |
|
6230 |
||
6231 |
confirmationMessageOrNil notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6232 |
(Dialog confirm:confirmationMessageOrNil) ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6233 |
^ false |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6234 |
]. |
5133 | 6235 |
]. |
6236 |
%{ |
|
6237 |
int flag; |
|
6238 |
||
6239 |
if (how == @symbol(shutdown)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6240 |
flag = EWX_SHUTDOWN; |
5133 | 6241 |
} else if (how == @symbol(reboot)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6242 |
flag = EWX_REBOOT; |
5133 | 6243 |
} else if (how == @symbol(logoff)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6244 |
flag = EWX_LOGOFF; |
5133 | 6245 |
} else if (how == @symbol(forceShutdown)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6246 |
flag = EWX_SHUTDOWN | EWX_FORCE; |
5133 | 6247 |
} else if (how == @symbol(forceReboot)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6248 |
flag = EWX_REBOOT | EWX_FORCE; |
5133 | 6249 |
} else if (how == @symbol(forceLogoff)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6250 |
flag = EWX_LOGOFF | EWX_FORCE; |
5133 | 6251 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6252 |
RETURN (false); |
5133 | 6253 |
} |
6254 |
RETURN ((ExitWindowsEx(flag, 0) == TRUE) ? true : false); |
|
6255 |
%} |
|
6256 |
! ! |
|
6257 |
||
6258 |
!Win32OperatingSystem class methodsFor:'time and date'! |
|
6259 |
||
6260 |
computeDatePartsOf:osTime for:aBlock |
|
6261 |
"compute year, month and day from the OS time, osTime |
|
6262 |
and evaluate the argument, a 3-arg block with these. |
|
6263 |
Conversion is to localtime including any daylight saving adjustments." |
|
6264 |
||
6265 |
|year month day osSeconds| |
|
6266 |
||
6267 |
osSeconds := osTime // 1000. |
|
6268 |
%{ |
|
6269 |
struct tm* tmPtr; |
|
6270 |
INT t; |
|
6271 |
TIME_T tt; |
|
6272 |
||
6273 |
t = __longIntVal(osSeconds); |
|
6274 |
tt = (TIME_T)t; |
|
6275 |
||
6276 |
tmPtr = localtime(&tt); |
|
6277 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
|
6278 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6279 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
6280 |
%}. |
|
6281 |
aBlock value:year value:month value:day |
|
6282 |
||
6283 |
" |
|
6284 |
OperatingSystem computeDatePartsOf:0 for:[:y :m :d | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6285 |
y printCR. m printCR. d printCR |
5133 | 6286 |
] |
6287 |
" |
|
6288 |
! |
|
6289 |
||
6290 |
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis |
|
6291 |
"return the OS-dependent time for the given time and day. |
|
6292 |
The arguments are assumed to be in localtime including |
|
6293 |
any daylight saving adjustings." |
|
6294 |
||
6295 |
|osSeconds| |
|
6296 |
||
6297 |
%{ |
|
6298 |
struct tm tm; |
|
6299 |
TIME_T t; |
|
6300 |
||
6301 |
if (__bothSmallInteger(y, m) |
|
6302 |
&& __bothSmallInteger(d, h) |
|
6303 |
&& __bothSmallInteger(min, s)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6304 |
tm.tm_hour = __intVal(h); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6305 |
tm.tm_min = __intVal(min); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6306 |
tm.tm_sec = __intVal(s); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6307 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6308 |
tm.tm_year = __intVal(y) - 1900; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6309 |
tm.tm_mon = __intVal(m) - 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6310 |
tm.tm_mday = __intVal(d); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6311 |
tm.tm_isdst = -1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6312 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6313 |
t = mktime(&tm); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6314 |
osSeconds = __MKUINT((INT)t); |
5133 | 6315 |
} |
6316 |
%}. |
|
6317 |
osSeconds notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6318 |
^ osSeconds * 1000 + millis |
5133 | 6319 |
]. |
6320 |
^ self primitiveFailed |
|
6321 |
||
6322 |
" |
|
6323 |
OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 |
|
6324 |
" |
|
6325 |
||
6326 |
! |
|
6327 |
||
7533 | 6328 |
timeInfoFromSeconds:osSeconds localTime:isLocalTime |
6329 |
"return a timeInfo structure containing values for the given |
|
6330 |
OS-second value. |
|
6331 |
An internal helper" |
|
6332 |
||
7534 | 6333 |
|low hi year month day hours minutes seconds utcOffset |
6334 |
dst yDay wDay info| |
|
6335 |
||
7533 | 6336 |
%{ |
6337 |
struct tm *tmPtr; |
|
6338 |
struct tm *gmTmPtr; |
|
6339 |
INT t; |
|
6340 |
TIME_T tt; |
|
6341 |
||
6342 |
t = __longIntVal(osSeconds); |
|
6343 |
tt = (TIME_T)t; |
|
6344 |
||
6345 |
tmPtr = localtime(&tt); |
|
6346 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
|
6347 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6348 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6349 |
||
6350 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
|
6351 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6352 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
6353 |
||
6354 |
yDay = __MKSMALLINT(tmPtr->tm_yday+1); |
|
6355 |
wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday); |
|
6356 |
||
6357 |
if (tmPtr->tm_isdst == 0) { |
|
6358 |
dst = false; |
|
6359 |
utcOffset = __MKINT(TIMEZONE(tmPtr)); |
|
6360 |
} else { |
|
6361 |
dst = true; |
|
6362 |
#ifdef HAS_ALTZONE |
|
6363 |
utcOffset = __MKINT(altzone); |
|
6364 |
#else |
|
6365 |
utcOffset = __MKINT(TIMEZONE(tmPtr) + 3600); |
|
6366 |
#endif |
|
6367 |
} |
|
6368 |
%}. |
|
6369 |
info := self timeInfoClass new. |
|
6370 |
||
6371 |
info |
|
6372 |
year:year |
|
6373 |
month:month |
|
6374 |
day:day |
|
6375 |
hours:hours |
|
6376 |
minutes:minutes |
|
6377 |
seconds:seconds |
|
6378 |
utcOffset:utcOffset |
|
6379 |
dst:dst |
|
6380 |
dayInYear:yDay |
|
6381 |
dayInWeek:wDay. |
|
6382 |
^ info |
|
6383 |
||
6384 |
" |
|
6385 |
OperatingSystem timeInfoFromSeconds:0 localTime:false |
|
6386 |
" |
|
6387 |
! |
|
6388 |
||
5133 | 6389 |
computeTimePartsOf:osTime for:aBlock |
6390 |
"compute hours, minutes, seconds and milliseconds from the osTime |
|
6391 |
and evaluate the argument, a 4-arg block with these. |
|
6392 |
Conversion is to localtime including any daylight saving adjustments." |
|
6393 |
||
6394 |
|hours minutes seconds millis osSeconds| |
|
6395 |
||
6396 |
osSeconds := osTime // 1000. |
|
6397 |
millis := osTime \\ 1000. |
|
6398 |
%{ |
|
6399 |
struct tm *tmPtr; |
|
6400 |
INT t; |
|
6401 |
TIME_T tt; |
|
6402 |
||
6403 |
t = __longIntVal(osSeconds); |
|
6404 |
tt = (TIME_T)t; |
|
6405 |
||
6406 |
tmPtr = localtime(&tt); |
|
6407 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
|
6408 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6409 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6410 |
%}. |
|
6411 |
aBlock value:hours value:minutes value:seconds value:millis |
|
6412 |
||
6413 |
" |
|
6414 |
OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6415 |
h printCR. m printCR. s printCR. millis printCR |
5133 | 6416 |
] |
6417 |
" |
|
6418 |
! |
|
6419 |
||
6420 |
computeUTCTimeAndDateFrom:osTime |
|
6421 |
"given an OS-dependent time in osTime, return an Array |
|
6422 |
containing year, month, day, hour, minute and seconds, |
|
6423 |
offset to UTC, daylight savings time flag, milliseconds, |
|
6424 |
dayInYear (1..) and dayInWeek (1..). |
|
6425 |
Conversion is to UTC." |
|
6426 |
||
6427 |
|low hi year month day hours minutes seconds millis utcOffset |
|
6428 |
dst yDay wDay osSeconds ret| |
|
6429 |
||
6430 |
millis := osTime \\ 1000. |
|
6431 |
osSeconds := osTime // 1000. |
|
6432 |
%{ |
|
6433 |
struct tm *tmPtr; |
|
6434 |
struct tm *gmTmPtr; |
|
6435 |
long t; |
|
6436 |
||
6437 |
t = __longIntVal(osSeconds); |
|
6438 |
||
6439 |
tmPtr = gmtime(&t); |
|
6440 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
|
6441 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6442 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6443 |
||
6444 |
year = __MKSMALLINT(tmPtr->tm_year + 1900); |
|
6445 |
month = __MKSMALLINT(tmPtr->tm_mon + 1); |
|
6446 |
day = __MKSMALLINT(tmPtr->tm_mday); |
|
6447 |
||
6448 |
yDay = __MKSMALLINT(tmPtr->tm_yday + 1); |
|
6449 |
wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday); |
|
6450 |
||
6451 |
if (tmPtr->tm_isdst == 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6452 |
dst = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6453 |
utcOffset = __MKINT(TIMEZONE(tmPtr)); |
5133 | 6454 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6455 |
dst = true; |
5133 | 6456 |
#ifdef HAS_ALTZONE |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6457 |
utcOffset = __MKINT(altzone); |
5133 | 6458 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6459 |
utcOffset = __MKINT(TIMEZONE(tmPtr) + 3600); |
5133 | 6460 |
#endif |
6461 |
} |
|
6462 |
%}. |
|
6463 |
"I would love to have SELF-like inline objects ..." |
|
6464 |
ret := Array new:11. |
|
6465 |
ret at:1 put:year. |
|
6466 |
ret at:2 put:month. |
|
6467 |
ret at:3 put:day. |
|
6468 |
ret at:4 put:hours. |
|
6469 |
ret at:5 put:minutes. |
|
6470 |
ret at:6 put:seconds. |
|
6471 |
ret at:7 put:utcOffset. |
|
6472 |
ret at:8 put:dst. |
|
6473 |
ret at:9 put:millis. |
|
6474 |
ret at:10 put:yDay. |
|
6475 |
ret at:11 put:wDay. |
|
6476 |
^ ret |
|
6477 |
||
6478 |
" |
|
6479 |
OperatingSystem computeUTCTimeAndDateFrom:0 |
|
6480 |
" |
|
6481 |
! |
|
6482 |
||
6483 |
computeUTCTimePartsOf:osTime for:aBlock |
|
6484 |
"compute hours, minutes, seconds and milliseconds from the osTime |
|
6485 |
and evaluate the argument, a 4-arg block with these. |
|
6486 |
Conversion is to UTC." |
|
6487 |
||
6488 |
|hours minutes seconds millis osSeconds| |
|
6489 |
||
6490 |
osSeconds := osTime // 1000. |
|
6491 |
millis := osTime \\ 1000. |
|
6492 |
%{ |
|
6493 |
struct tm *tmPtr; |
|
6494 |
long t; |
|
6495 |
||
6496 |
t = __longIntVal(osSeconds); |
|
6497 |
||
6498 |
tmPtr = gmtime(&t); |
|
6499 |
hours = __MKSMALLINT(tmPtr->tm_hour); |
|
6500 |
minutes = __MKSMALLINT(tmPtr->tm_min); |
|
6501 |
seconds = __MKSMALLINT(tmPtr->tm_sec); |
|
6502 |
%}. |
|
6503 |
aBlock value:hours value:minutes value:seconds value:millis |
|
6504 |
||
6505 |
" |
|
6506 |
OperatingSystem computeUTCTimePartsOf:100 for:[:h :m :s :milli | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6507 |
h printCR. m printCR. s printCR. milli printCR |
5133 | 6508 |
] |
6509 |
" |
|
6510 |
! |
|
6511 |
||
6512 |
getMillisecondTime |
|
6513 |
"This returns the millisecond timers value. |
|
6514 |
The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid |
|
6515 |
LargeInteger arithmetic when doing timeouts and delays. |
|
6516 |
Since this value is wrapping around in regular intervals, this can only be used for |
|
6517 |
short relative time deltas. |
|
6518 |
Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap. |
|
6519 |
||
6520 |
BAD DESIGN: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6521 |
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
|
6522 |
and these computations moved there. |
5133 | 6523 |
|
6524 |
Dont use this method in application code since it is an internal (private) |
|
6525 |
interface. For compatibility with ST-80, use Time millisecondClockValue. |
|
6526 |
" |
|
6527 |
||
6528 |
%{ /* NOCONTEXT */ |
|
6529 |
||
6530 |
long t = 0; |
|
6531 |
||
6532 |
#if !defined(HAS_GETTIMEOFDAY) |
|
6533 |
# if defined(HAS_FTIME) |
|
6534 |
struct timeb timebuffer; |
|
6535 |
||
6536 |
ftime(&timebuffer); |
|
6537 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
6538 |
# define HAVE_TIME |
|
6539 |
# endif |
|
6540 |
||
6541 |
# ifndef HAVE_TIME |
|
6542 |
# ifdef WIN32 |
|
6543 |
t = GetTickCount(); |
|
6544 |
# define HAVE_TIME |
|
6545 |
# endif |
|
6546 |
# endif |
|
6547 |
||
6548 |
# ifndef HAVE_TIME |
|
6549 |
# ifdef MSDOS_LIKE |
|
6550 |
# ifdef __BORLANDC__ |
|
6551 |
struct timeb timebuffer; |
|
6552 |
ftime(&timebuffer); |
|
6553 |
# else |
|
6554 |
struct _timeb timebuffer; |
|
6555 |
_ftime(&timebuffer); |
|
6556 |
# endif |
|
6557 |
t = (timebuffer.time * 1000) + timebuffer.millitm; |
|
6558 |
# define HAVE_TIME |
|
6559 |
# endif |
|
6560 |
# endif |
|
6561 |
#endif |
|
6562 |
||
6563 |
#ifndef HAVE_TIME |
|
6564 |
/* assume HAS_GETTIMEOFDAY |
|
6565 |
* - will result in a linkage error |
|
6566 |
* if not fixed. |
|
6567 |
*/ |
|
6568 |
||
6569 |
/* |
|
6570 |
* bsd time |
|
6571 |
*/ |
|
6572 |
struct timeval tb; |
|
6573 |
struct timezone tzb; |
|
6574 |
||
6575 |
gettimeofday(&tb, &tzb); |
|
6576 |
t = tb.tv_sec*1000 + tb.tv_usec/1000; |
|
6577 |
#endif |
|
6578 |
||
6579 |
#undef HAVE_TIME |
|
6580 |
||
6581 |
RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) ); |
|
6582 |
%} |
|
6583 |
! |
|
6584 |
||
6585 |
getOSTime |
|
6586 |
"This returns the OS time. |
|
6587 |
The base of the returned value is not consistent across |
|
6588 |
different OS's - some return the number of millis since jan, 1st 1970; |
|
6589 |
others since 1900. The Time classes are prepared for this, and |
|
6590 |
converts as appropriate (by using my fromOSTime: conversion methods). |
|
6591 |
||
6592 |
Dont use this method in application code since it is an internal (private) |
|
6593 |
interface. For compatibility with ST-80, use Time>>millisecondClockValue. |
|
6594 |
or use instances of Time, Date or AbsoluteTime to work with. |
|
6595 |
" |
|
6596 |
||
6597 |
|seconds millis| |
|
6598 |
||
6599 |
%{ |
|
6600 |
||
6601 |
long t; |
|
6602 |
||
6603 |
#if !defined(HAS_GETTIMEOFDAY) |
|
6604 |
# if defined(HAS_FTIME) |
|
6605 |
struct timeb timebuffer; |
|
6606 |
||
6607 |
ftime(&timebuffer); |
|
6608 |
seconds = __MKUINT(timebuffer.time); |
|
6609 |
millis = __MKUINT(timebuffer.millitm); |
|
6610 |
# define HAVE_TIME |
|
6611 |
# endif |
|
6612 |
||
6613 |
# ifndef HAVE_TIME |
|
6614 |
# ifdef MSDOS_LIKE |
|
6615 |
# ifdef __BORLANDC__ |
|
6616 |
struct timeb timebuffer; |
|
6617 |
ftime(&timebuffer); |
|
6618 |
# else |
|
6619 |
struct _timeb timebuffer; |
|
6620 |
_ftime(&timebuffer); |
|
6621 |
# endif |
|
6622 |
seconds = __MKUINT(timebuffer.time); |
|
6623 |
millis = __MKUINT(timebuffer.millitm); |
|
6624 |
# define HAVE_TIME |
|
6625 |
# endif |
|
6626 |
# endif |
|
6627 |
#endif |
|
6628 |
||
6629 |
#ifndef HAVE_TIME |
|
6630 |
/* assume HAS_GETTIMEOFDAY |
|
6631 |
* - will result in a linkage error |
|
6632 |
* if not fixed. |
|
6633 |
*/ |
|
6634 |
/* |
|
6635 |
* bsd time |
|
6636 |
*/ |
|
6637 |
struct timeval tb; |
|
6638 |
struct timezone tzb; |
|
6639 |
||
6640 |
gettimeofday(&tb, &tzb); |
|
6641 |
||
6642 |
seconds = __MKUINT(tb.tv_sec); |
|
6643 |
millis = __MKUINT(tb.tv_usec / 1000); |
|
6644 |
#endif |
|
6645 |
||
6646 |
#undef HAVE_TIME |
|
6647 |
||
6648 |
%}. |
|
6649 |
^ (seconds * 1000) + millis |
|
6650 |
||
6651 |
" |
|
6652 |
OperatingSystem getOSTime printCR. |
|
6653 |
Delay waitForSeconds:0.2. |
|
6654 |
OperatingSystem getOSTime printCR. |
|
6655 |
" |
|
6656 |
! |
|
6657 |
||
6658 |
millisecondDelay:millis |
|
6659 |
"delay execution for millis milliseconds or until the next event |
|
6660 |
arrives. |
|
6661 |
All lower priority threads will also sleep for the duration, |
|
6662 |
interrupts (and therefore, higher prio processes) are |
|
6663 |
still handled. |
|
6664 |
Better use a Delay, to only delay the calling thread. |
|
6665 |
(however, a delay cannot be used in the event handler or scheduler)" |
|
6666 |
||
6667 |
|now then delta| |
|
6668 |
||
6669 |
now := Win32OperatingSystem getMillisecondTime. |
|
6670 |
then := Win32OperatingSystem millisecondTimeAdd:now and:millis. |
|
6671 |
||
6672 |
[Win32OperatingSystem millisecondTime:then isAfter:now] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6673 |
delta := Win32OperatingSystem millisecondTimeDeltaBetween:then and:now. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6674 |
self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6675 |
now := Win32OperatingSystem getMillisecondTime. |
5133 | 6676 |
] |
6677 |
||
6678 |
" |
|
6679 |
OperatingSystem millisecondDelay:2000 |
|
6680 |
" |
|
6681 |
! |
|
6682 |
||
6683 |
sleep:numberOfSeconds |
|
6684 |
"{ Pragma: +optSpace }" |
|
6685 |
||
6686 |
"cease ANY action for some time. This suspends the whole smalltalk |
|
6687 |
(unix-) process for some time. |
|
6688 |
Not really useful since not even low-prio processes and interrupt |
|
6689 |
handling will run during the sleep. |
|
6690 |
Use either OperatingSystem>>millisecondDelay: (which makes all |
|
6691 |
threads sleep, but handles interrupts) or use a Delay (which makes |
|
6692 |
only the calling thread sleep)." |
|
6693 |
||
6694 |
%{ /* NOCONTEXT */ |
|
6695 |
||
6696 |
if (__isSmallInteger(numberOfSeconds)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6697 |
sleep(__intVal(numberOfSeconds)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6698 |
RETURN ( self ); |
5133 | 6699 |
} |
6700 |
%}. |
|
6701 |
" |
|
6702 |
argument not integer |
|
6703 |
" |
|
6704 |
^ self primitiveFailed |
|
6705 |
||
6706 |
" |
|
6707 |
OperatingSystem sleep:2 |
|
6708 |
" |
|
6709 |
! ! |
|
6710 |
||
6711 |
!Win32OperatingSystem class methodsFor:'users & groups'! |
|
6712 |
||
6713 |
getEffectiveGroupID |
|
6714 |
"{ Pragma: +optSpace }" |
|
6715 |
||
6716 |
"return the current users (thats you) effective numeric group id. |
|
6717 |
This is only different from getGroupID, if you have ST/X running |
|
6718 |
as a setuid program (of which you should think about twice)." |
|
6719 |
||
6720 |
^ self getGroupID |
|
6721 |
||
6722 |
" |
|
6723 |
OperatingSystem getEffectiveGroupID |
|
6724 |
" |
|
6725 |
! |
|
6726 |
||
6727 |
getEffectiveUserID |
|
6728 |
"{ Pragma: +optSpace }" |
|
6729 |
||
6730 |
"return the current users (thats you) effective numeric user id. |
|
6731 |
This is only different from getUserID, if you have ST/X running |
|
6732 |
as a setuid program (of which you should think about twice)." |
|
6733 |
||
6734 |
^ self getUserID |
|
6735 |
||
6736 |
" |
|
6737 |
OperatingSystem getEffectiveUserID |
|
6738 |
" |
|
6739 |
! |
|
6740 |
||
6741 |
getFullUserNameFromID:userID |
|
6742 |
"{ Pragma: +optSpace }" |
|
6743 |
||
6744 |
"return a string with the users full name - if available. |
|
6745 |
If not, return the login name as a fallBack." |
|
6746 |
||
6747 |
|info gecos| |
|
6748 |
||
6749 |
info := self userInfoOf:userID. |
|
6750 |
(info notNil |
|
6751 |
and:[info includesKey:#gecos]) ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6752 |
gecos := info at:#gecos. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6753 |
(gecos includes:$,) ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6754 |
^ gecos copyTo:(gecos indexOf:$,) - 1 |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6755 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6756 |
^ gecos |
5133 | 6757 |
]. |
6758 |
^ self getUserNameFromID:userID |
|
6759 |
||
6760 |
" |
|
6761 |
OperatingSystem getFullUserNameFromID:0 |
|
6762 |
OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID) |
|
6763 |
||
6764 |
OperatingSystem getUserNameFromID:(OperatingSystem getUserID) |
|
6765 |
" |
|
6766 |
||
6767 |
"Modified: 15.7.1996 / 12:44:21 / cg" |
|
6768 |
! |
|
6769 |
||
6770 |
getGroupID |
|
6771 |
"{ Pragma: +optSpace }" |
|
6772 |
||
6773 |
"return the current users (thats you) numeric group id" |
|
6774 |
||
6775 |
^ 1 "just a dummy for systems which do not have groupIDs" |
|
6776 |
||
6777 |
" |
|
6778 |
OperatingSystem getGroupID |
|
6779 |
" |
|
6780 |
! |
|
6781 |
||
6782 |
getGroupNameFromID:aNumber |
|
6783 |
"{ Pragma: +optSpace }" |
|
6784 |
||
6785 |
"return the group-name-string for a given numeric group-id" |
|
6786 |
||
6787 |
^ '???' "just a dummy for systems which do not have groupIDs" |
|
6788 |
||
6789 |
" |
|
6790 |
OperatingSystem getGroupNameFromID:0 |
|
6791 |
OperatingSystem getGroupNameFromID:10 |
|
6792 |
" |
|
6793 |
! |
|
6794 |
||
6795 |
getHomeDirectory |
|
6796 |
"{ Pragma: +optSpace }" |
|
6797 |
||
5264
9a90c499e329
return the currentDir as default fallBack for the getHomeDir query.
Claus Gittinger <cg@exept.de>
parents:
5147
diff
changeset
|
6798 |
"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
|
6799 |
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
|
6800 |
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
|
6801 |
If not set, return the current directory." |
5133 | 6802 |
|
6803 |
|dir drv path| |
|
6804 |
||
6805 |
dir := self getEnvironment:'HOME'. |
|
6806 |
dir isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6807 |
"/ for NT users: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6808 |
"/ if HOME is nil, try HOMEDRIVE and HOMEPATH |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6809 |
"/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6810 |
((drv := self getEnvironment:'HOMEDRIVE') notNil |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6811 |
and:[(path := self getEnvironment:'HOMEPATH') notNil]) ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6812 |
dir := drv , path |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6813 |
] ifFalse:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6814 |
dir := '.'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6815 |
]. |
5133 | 6816 |
]. |
6817 |
^ dir |
|
6818 |
||
6819 |
" |
|
6820 |
OperatingSystem getHomeDirectory |
|
6821 |
" |
|
6822 |
||
5264
9a90c499e329
return the currentDir as default fallBack for the getHomeDir query.
Claus Gittinger <cg@exept.de>
parents:
5147
diff
changeset
|
6823 |
"Modified: / 16.2.2000 / 09:17:55 / cg" |
5133 | 6824 |
! |
6825 |
||
6826 |
getLoginName |
|
6827 |
"{ Pragma: +optSpace }" |
|
6828 |
||
6829 |
"return a string with the users login name (thats yours)" |
|
6830 |
||
6831 |
%{ /* NOCONTEXT */ |
|
6832 |
static char cachedName[64]; |
|
6833 |
static firstCall = 1; |
|
6834 |
#ifndef __BORLANDC__ |
|
6835 |
extern char *getenv(); |
|
6836 |
#endif |
|
6837 |
char *name = (char *)0; |
|
6838 |
||
6839 |
if (firstCall) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6840 |
int nameSize = sizeof(cachedName); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6841 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6842 |
if (GetUserName(cachedName, &nameSize) == TRUE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6843 |
name = cachedName; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6844 |
firstCall = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6845 |
} |
5133 | 6846 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6847 |
name = cachedName; |
5133 | 6848 |
} |
6849 |
||
6850 |
/* |
|
6851 |
* try a few common environment variables ... |
|
6852 |
*/ |
|
6853 |
if (! name || (name[0] == 0) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6854 |
name = getenv("LOGIN"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6855 |
if (! name || (name[0] == 0) ) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6856 |
name = getenv("LOGNAME"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6857 |
if (! name || (name[0] == 0) ) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6858 |
name = getenv("USER"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6859 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6860 |
} |
5133 | 6861 |
} |
6862 |
/* |
|
6863 |
* nope - I really font know who you are. |
|
6864 |
*/ |
|
6865 |
if (! name || (name[0] == 0) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6866 |
name = "you"; |
5133 | 6867 |
} |
6868 |
||
6869 |
RETURN ( __MKSTRING(name) ); |
|
6870 |
%}. |
|
6871 |
" |
|
6872 |
OperatingSystem getLoginName |
|
6873 |
" |
|
6874 |
! |
|
6875 |
||
6876 |
getUserID |
|
6877 |
"{ Pragma: +optSpace }" |
|
6878 |
||
6879 |
"return the current users (thats you) numeric user id" |
|
6880 |
||
6881 |
^ 1 "just a dummy for systems which do not have userIDs" |
|
6882 |
||
6883 |
" |
|
6884 |
OperatingSystem getUserID |
|
6885 |
" |
|
6886 |
! |
|
6887 |
||
6888 |
getUserNameFromID:aNumber |
|
6889 |
"{ Pragma: +optSpace }" |
|
6890 |
||
6891 |
"return the user-name-string for a given numeric user-id. |
|
6892 |
This is the login name, not the fullName." |
|
6893 |
||
6894 |
aNumber == self getUserID ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6895 |
^ self getLoginName |
5133 | 6896 |
]. |
6897 |
||
6898 |
^ '? (' , aNumber printString , ')' |
|
6899 |
||
6900 |
" |
|
6901 |
OperatingSystem getUserNameFromID:0 |
|
6902 |
OperatingSystem getUserNameFromID:100 |
|
6903 |
OperatingSystem getUserNameFromID:9991 |
|
6904 |
" |
|
6905 |
! |
|
6906 |
||
6907 |
userInfoOf:aNameOrID |
|
6908 |
"{ Pragma: +optSpace }" |
|
6909 |
||
6910 |
"return a dictionary filled with userinfo. The argument can be either |
|
6911 |
a string with the users name or its numeric id. |
|
6912 |
Notice, that DOS systems only provide a very limited set of information. |
|
6913 |
Portable applications may want to check the systemType and NOT depend |
|
6914 |
on all keys to be present in the returned dictionary." |
|
6915 |
||
6916 |
|info name uid gid dir| |
|
6917 |
||
6918 |
info := IdentityDictionary new. |
|
6919 |
name isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6920 |
aNameOrID == self getUserID ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6921 |
name := self getLoginName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6922 |
]. |
5133 | 6923 |
]. |
6924 |
name notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6925 |
info at:#name put:name. |
5133 | 6926 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6927 |
info at:#name put:'unknown' |
5133 | 6928 |
]. |
6929 |
dir isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6930 |
aNameOrID == self getUserID ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6931 |
dir := self getHomeDirectory |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6932 |
] |
5133 | 6933 |
]. |
6934 |
dir notNil ifTrue:[info at:#dir put:dir]. |
|
6935 |
"/ uid notNil ifTrue:[info at:#uid put:uid]. |
|
6936 |
"/ gid notNil ifTrue:[info at:#gid put:gid]. |
|
6937 |
^ info |
|
6938 |
||
6939 |
" |
|
6940 |
OperatingSystem userInfoOf:'root' |
|
6941 |
OperatingSystem userInfoOf:1 |
|
6942 |
OperatingSystem userInfoOf:'claus' |
|
6943 |
OperatingSystem userInfoOf:'fooBar' |
|
6944 |
OperatingSystem userInfoOf:(OperatingSystem getUserID) |
|
6945 |
" |
|
6946 |
! ! |
|
6947 |
||
6948 |
!Win32OperatingSystem class methodsFor:'waiting for events'! |
|
6949 |
||
6950 |
blockingChildProcessWait |
|
6951 |
"return true, if childProcessWait: blocks, if no children are ready. |
|
6952 |
On those systems, we must be somewhat careful when looking out for |
|
6953 |
a subprocesses status (to avoid blocking)." |
|
6954 |
||
6955 |
^ false |
|
6956 |
! |
|
6957 |
||
6958 |
childProcessWait:blocking pid:pidToWait |
|
6959 |
"{ Pragma: +optSpace }" |
|
6960 |
||
6961 |
"get status changes from child processes. |
|
6962 |
Return an OSProcessStatus or nil, if no process has terminated. |
|
6963 |
If blocking is true, we wait until a process changed state, |
|
6964 |
otherwise we return immediately. |
|
6965 |
Note that win32 needs to know the HANDLE of the process on which |
|
6966 |
it waits. In case of an error, THIS ALWAYS WAITS and then times out." |
|
6967 |
||
6968 |
|pid status code core| |
|
6969 |
%{ |
|
6970 |
DWORD endStatus; |
|
6971 |
||
6972 |
if (__isExternalAddress(pidToWait) ) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6973 |
HANDLE __pidToWait = _HANDLEVal(pidToWait); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6974 |
int t; |
5133 | 6975 |
|
6976 |
#ifdef PROCESS1DEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6977 |
printf("childProcessWait %x b %d\n",__pidToWait,blocking==true); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6978 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6979 |
t = blocking==true ? INFINITE : 0; |
5133 | 6980 |
|
6981 |
#ifdef DO_WRAP_CALLS |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6982 |
do { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6983 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6984 |
endStatus = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, __pidToWait, t); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6985 |
} while ((endStatus < 0) && (__threadErrno == EINTR)); |
5133 | 6986 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6987 |
endStatus = WaitForSingleObject(__pidToWait, t); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6988 |
if (endStatus < 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6989 |
__threadErrno = __WIN32_ERR(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6990 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6991 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6992 |
if ( endStatus == WAIT_TIMEOUT ) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6993 |
if (blocking==true) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6994 |
status = @symbol(timeout); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6995 |
else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6996 |
status = @symbol(continue); |
5133 | 6997 |
#ifdef PROCESS1DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6998 |
printf("ret nil\n"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
6999 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7000 |
RETURN(nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7001 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7002 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7003 |
status = @symbol(exit); |
5133 | 7004 |
#ifdef PROCESS1DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7005 |
printf("exit\n"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7006 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7007 |
if (endStatus == WAIT_OBJECT_0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7008 |
if (GetExitCodeProcess(__pidToWait, &endStatus)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7009 |
if (endStatus == STILL_ACTIVE) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7010 |
RETURN(nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7011 |
} |
5133 | 7012 |
#ifdef PROCESS1DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7013 |
printf("exit %d\n",endStatus); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7014 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7015 |
code = __MKSMALLINT(endStatus); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7016 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7017 |
code = __MKSMALLINT(GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7018 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7019 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7020 |
code = __MKSMALLINT(-1); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7021 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7022 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7023 |
core = false; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7024 |
pid = pidToWait; |
5133 | 7025 |
} |
7026 |
%}. |
|
7027 |
||
7028 |
(status isNil or:[pid isNil]) ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7029 |
^ self primitiveFailed |
5133 | 7030 |
]. |
7031 |
||
7032 |
"/ Transcript show:'pid: '; show:pid; show:' status: '; show:status; |
|
7033 |
"/ show:' code: '; show:code; show:' core:'; showCR:core. |
|
7034 |
||
7035 |
^ OSProcessStatus pid:pid status:status code:code core:core |
|
7036 |
||
7037 |
" |
|
7038 |
OperatingSystem childProcessWait:false |
|
7039 |
" |
|
7040 |
||
7041 |
"Created: 5.1.1996 / 16:39:14 / stefan" |
|
7042 |
! |
|
7043 |
||
7044 |
numAvailableForReadOn:fd |
|
7045 |
"return the number of bytes available for reading, without blocking." |
|
7046 |
||
7047 |
^ (self readCheck:fd) ifTrue:[1] ifFalse:[0] |
|
7048 |
! |
|
7049 |
||
7050 |
readCheck:fd |
|
7051 |
"return true, if data is available on a filedescriptor |
|
7052 |
(i.e. read is possible without blocking). |
|
7053 |
This depends on a working select or FIONREAD to be provided by the OS." |
|
7054 |
||
7055 |
^ super readCheck:fd |
|
7056 |
! |
|
7057 |
||
7058 |
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis |
|
7059 |
"wait for any fd in readFdArray (an Array of integers) to become ready for |
|
7060 |
reading, writeFdArray to become ready for writing, or exceptFdArray to |
|
7061 |
arrive exceptional data (i.e. out-of-band data). |
|
7062 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7063 |
Empty fd-sets will always wait. Zero time can be used to poll file- |
|
7064 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7065 |
Return first ready fd if I/O ok, nil if timed-out or interrupted." |
|
7066 |
||
7067 |
%{ |
|
7068 |
#define MAXHANDLE 128 |
|
7069 |
||
7070 |
int i; |
|
7071 |
INT t; |
|
7072 |
OBJ fd, retFd; |
|
7073 |
int ret; |
|
7074 |
int count; |
|
7075 |
int numHandles = 0; |
|
7076 |
DWORD res; |
|
7077 |
HANDLE hArray[MAXHANDLE]; |
|
7078 |
int retArray[MAXHANDLE]; |
|
7079 |
||
7080 |
if (__isNonNilObject(readFdArray)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7081 |
if (! __isArray(readFdArray)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7082 |
goto fail; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7083 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7084 |
count = __arraySize(readFdArray); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7085 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7086 |
for (i=0; (i<count) && (numHandles < MAXHANDLE);i++) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7087 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7088 |
if (fd != nil) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7089 |
HANDLE h; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7090 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7091 |
if (__isExternalAddress(fd)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7092 |
hArray[numHandles] = h = _HANDLEVal(fd); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7093 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7094 |
hArray[numHandles] = h = (HANDLE) _get_osfhandle (__intVal(fd)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7095 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7096 |
if (ioctlsocket((SOCKET)h, FIONREAD, &res)==0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7097 |
if (res > 0) { |
5133 | 7098 |
#ifdef SELECT2DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7099 |
printf("no wait result=%d (this is a Socket fd=%x h=%x)\n", res, fd, h); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7100 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7101 |
RETURN (fd); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7102 |
} |
5133 | 7103 |
#ifdef SELECT2DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7104 |
printf("readWait Handle %d (this is a Socket fd=%x h=%x)\n", i, fd, h); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7105 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7106 |
//if (!__isWinNT) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7107 |
// continue; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7108 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7109 |
if (PeekNamedPipe((HANDLE)h, 0, 0, 0, &res, 0)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7110 |
if (1 /*res > 0*/) { |
5133 | 7111 |
#ifdef SELECT1DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7112 |
printf("no wait l=%d ret this is a Pipe %x\n", res, fd); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7113 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7114 |
RETURN (fd); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7115 |
} |
5133 | 7116 |
#ifdef SELECT1DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7117 |
printf("readWait Handle %d this is a Pipe %x\n", i, fd); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7118 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7119 |
continue; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7120 |
} else { |
5133 | 7121 |
#ifdef SELECT2DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7122 |
printf("readWait Handle %d this is ??? %x\n", i, fd); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7123 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7124 |
__threadErrno = EBADF; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7125 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7126 |
RETURN ( nil ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7127 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7128 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7129 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7130 |
retArray[numHandles] = i; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7131 |
numHandles++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7132 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7133 |
} |
5133 | 7134 |
} |
7135 |
||
7136 |
if (__isNonNilObject(writeFdArray)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7137 |
if (! __isArray(writeFdArray)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7138 |
goto fail; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7139 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7140 |
count = __arraySize(writeFdArray); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7141 |
for (i=0; (i<count) && (numHandles < MAXHANDLE);i++) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7142 |
fd = __ArrayInstPtr(writeFdArray)->a_element[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7143 |
if (fd != nil) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7144 |
if (__isExternalAddress(fd)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7145 |
hArray[numHandles] = _HANDLEVal(fd); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7146 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7147 |
hArray[numHandles] = (HANDLE) _get_osfhandle (__intVal(fd)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7148 |
} |
5133 | 7149 |
#ifdef SELECTDEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7150 |
printf("select of writeFdArray %x\n",hArray[numHandles]); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7151 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7152 |
retArray[numHandles] = i + 10000; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7153 |
numHandles++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7154 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7155 |
} |
5133 | 7156 |
} |
7157 |
||
7158 |
if (__isNonNilObject(exceptFdArray)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7159 |
if (! __isArray(exceptFdArray)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7160 |
goto fail; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7161 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7162 |
count = __arraySize(exceptFdArray); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7163 |
for (i=0; (i<count) && (numHandles < MAXHANDLE);i++) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7164 |
fd = __ArrayInstPtr(exceptFdArray)->a_element[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7165 |
if (fd != nil) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7166 |
if (__isExternalAddress(fd)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7167 |
hArray[numHandles] = _HANDLEVal(fd); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7168 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7169 |
hArray[numHandles] = (HANDLE) _get_osfhandle (__intVal(fd)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7170 |
} |
5133 | 7171 |
#ifdef SELECTDEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7172 |
printf("select of exceptFdArray %x\n",hArray[numHandles]); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7173 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7174 |
retArray[numHandles] = i + 20000; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7175 |
numHandles++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7176 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7177 |
} |
5133 | 7178 |
} |
7179 |
||
7180 |
if (__isSmallInteger(millis)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7181 |
t = __intVal(millis); |
5133 | 7182 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7183 |
t = INFINITE; |
5133 | 7184 |
} |
7185 |
||
7186 |
if (numHandles) { |
|
7187 |
#ifdef SELECT3DEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7188 |
printf("wait Handles = %d timeout = %d\n",numHandles,t); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7189 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7190 |
res = __vmWait(numHandles, hArray, MAXHANDLE, t); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7191 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7192 |
if (res == WAIT_FAILED) { |
5133 | 7193 |
#ifdef SELECT2DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7194 |
printf("- error %d; ret nil\n",GetLastError()); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7195 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7196 |
if (__threadErrno == EINTR) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7197 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7198 |
@global(LastErrorNumber) = nil; |
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 |
__threadErrno = EBADF; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7201 |
if (@global(InfoPrinting) == true) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7202 |
fprintf(stderr, "OS [info]: select errno = %d\n", __threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7203 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7204 |
@global(LastErrorNumber) = __MKSMALLINT(__threadErrno); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7205 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7206 |
RETURN ( nil ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7207 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7208 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7209 |
if (res == WAIT_TIMEOUT) { |
5133 | 7210 |
#ifdef SELECT3DEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7211 |
printf("- timeOut; ret nil\n"); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7212 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7213 |
goto polling; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7214 |
// @global(LastErrorNumber) = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7215 |
// RETURN ( nil ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7216 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7217 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7218 |
if ((res < 0) || (res >= numHandles)) { |
5133 | 7219 |
#ifdef SELECTDEBUGWIN32 |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7220 |
printf("- res=%d error1 %d\n", res, GetLastError()); |
5133 | 7221 |
#endif |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7222 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7223 |
@global(LastErrorNumber) = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7224 |
RETURN ( nil ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7225 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7226 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7227 |
ret = res; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7228 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7229 |
if (ret < numHandles) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7230 |
int fd = retArray[ret]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7231 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7232 |
@global(LastErrorNumber) = nil; |
5133 | 7233 |
|
7234 |
#ifdef SELECTDEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7235 |
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
|
7236 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7237 |
if (fd < 10000) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7238 |
RETURN ( __ArrayInstPtr(readFdArray)->a_element[fd] ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7239 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7240 |
if (fd < 20000) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7241 |
RETURN ( __ArrayInstPtr(writeFdArray)->a_element[fd-10000] ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7242 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7243 |
RETURN ( __ArrayInstPtr(exceptFdArray)->a_element[fd-20000] ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7244 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7245 |
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
|
7246 |
goto fail; |
5133 | 7247 |
} else { |
7248 |
#ifdef SELECTDEBUGWIN32 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7249 |
printf("wait NoHandles timeout = %d\n",t); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7250 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7251 |
res = __vmWait(0, hArray, MAXHANDLE, t); |
5133 | 7252 |
|
7253 |
polling: |
|
7254 |
||
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7255 |
if (__isNonNilObject(readFdArray)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7256 |
HANDLE h; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7257 |
if (! __isArray(readFdArray)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7258 |
goto fail; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7259 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7260 |
count = __arraySize(readFdArray); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7261 |
for (i=0; (i<count);i++) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7262 |
fd = __ArrayInstPtr(readFdArray)->a_element[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7263 |
if (fd != nil) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7264 |
if (__isExternalAddress(fd)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7265 |
continue; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7266 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7267 |
h = (HANDLE) _get_osfhandle (__intVal(fd)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7268 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7269 |
if (ioctlsocket((SOCKET)h, FIONREAD, &res)==0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7270 |
if (1 /*res > 0*/) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7271 |
RETURN ( fd ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7272 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7273 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7274 |
if (PeekNamedPipe((HANDLE)h,0,0,0,&res,0)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7275 |
if (1 /*res > 0*/) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7276 |
RETURN ( fd ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7277 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7278 |
continue; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7279 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7280 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7281 |
if (t) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7282 |
RETURN ( fd ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7283 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7284 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7285 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7286 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7287 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7288 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7289 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7290 |
@global(LastErrorNumber) = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7291 |
RETURN ( nil ); |
5133 | 7292 |
} |
7293 |
||
7294 |
fail: ; |
|
7295 |
%}. |
|
7296 |
" |
|
7297 |
timeout argument not integer, |
|
7298 |
or any fd-array nonNil and not an array |
|
7299 |
or not supported by OS |
|
7300 |
" |
|
7301 |
^ self primitiveFailed |
|
7302 |
! |
|
7303 |
||
7304 |
setBlocking:aBoolean on:fd |
|
7305 |
"{ Pragma: +optSpace }" |
|
7306 |
||
7307 |
"set/clear the blocking attribute - if set (which is the default) |
|
7308 |
a read on the fileDescriptor will block until data is available. |
|
7309 |
If cleared, a read operation will immediately return with a value of |
|
7310 |
nil." |
|
7311 |
||
7312 |
^ self primitiveFailed |
|
7313 |
! |
|
7314 |
||
7315 |
waitForMultipleObjects:fdOrHandleArray withTimeout:millis |
|
7316 |
"wait for an fd to become ready. |
|
7317 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7318 |
Zero time can be used to poll a file- |
|
7319 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7320 |
Return the fd if I/O ok, nil if timed-out or interrupted." |
|
7321 |
||
7322 |
%{ |
|
7323 |
#ifndef MAXHANDLE |
|
7324 |
# define MAXHANDLE 128 |
|
7325 |
#endif |
|
7326 |
INT t; |
|
7327 |
DWORD res; |
|
7328 |
HANDLE hArray[MAXHANDLE]; |
|
7329 |
INT i, count; |
|
7330 |
||
7331 |
if (! __isArray(fdOrHandleArray)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7332 |
goto fail; |
5133 | 7333 |
} |
7334 |
count = __arraySize(fdOrHandleArray); |
|
7335 |
||
7336 |
for (i=0; i<count; i++) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7337 |
OBJ fdOrHandle = __ArrayInstPtr(fdOrHandleArray)->a_element[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7338 |
HANDLE h; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7339 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7340 |
if (__isExternalAddress(fdOrHandle)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7341 |
h = _HANDLEVal(fdOrHandle); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7342 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7343 |
if (__isSmallInteger(fdOrHandle)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7344 |
h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7345 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7346 |
goto fail; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7347 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7348 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7349 |
hArray[i] = h; |
5133 | 7350 |
} |
7351 |
||
7352 |
if (__isSmallInteger(millis)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7353 |
t = __intVal(millis); |
5133 | 7354 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7355 |
t = INFINITE; |
5133 | 7356 |
} |
7357 |
||
7358 |
#ifdef DO_WRAP_CALLS |
|
7359 |
do { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7360 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7361 |
res = STX_API_CALL4( "WaitForMultipleObjects", WaitForMultipleObjects, count, hArray, FALSE, t); |
5133 | 7362 |
} while ((res < 0) && (__threadErrno == EINTR)); |
7363 |
#else |
|
7364 |
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
|
7365 |
if (res < 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7366 |
__threadErrno = __WIN32_ERR(GetLastError()); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
7367 |
} |
5133 | 7368 |
#endif |
7369 |
if (res == WAIT_FAILED) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7370 |
RETURN (nil); |
5133 | 7371 |
} |
7372 |
if (res == WAIT_TIMEOUT) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7373 |
RETURN (nil); |
5133 | 7374 |
} |
7375 |
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
|
7376 |
RETURN (__ArrayInstPtr(fdOrHandleArray)->a_element[res-WAIT_OBJECT_0]); |
5133 | 7377 |
} |
7378 |
||
7379 |
RETURN (nil); |
|
7380 |
fail: ; |
|
7381 |
%}. |
|
7382 |
" |
|
7383 |
invalid arg, |
|
7384 |
" |
|
7385 |
^ self primitiveFailed |
|
7386 |
! |
|
7387 |
||
7388 |
waitForSingleObject:fdOrHandle withTimeout:millis |
|
7389 |
"wait for an fd to become ready. |
|
7390 |
Timeout after t milliseconds or, if the timeout time is 0, immediately.. |
|
7391 |
Zero time can be used to poll a file- |
|
7392 |
descriptors (i.e. to check if I/O possible without blocking). |
|
7393 |
Return the fd if I/O ok, nil if timed-out or interrupted." |
|
7394 |
||
7395 |
%{ |
|
7396 |
INT t; |
|
7397 |
DWORD res; |
|
7398 |
HANDLE h = NULL; |
|
7399 |
||
7400 |
if (__isExternalAddress(fdOrHandle)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7401 |
h = _HANDLEVal(fdOrHandle); |
5133 | 7402 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7403 |
if (__isSmallInteger(fdOrHandle)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7404 |
h = (HANDLE) _get_osfhandle (__intVal(fdOrHandle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7405 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7406 |
goto fail; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7407 |
} |
5133 | 7408 |
} |
7409 |
||
7410 |
if (__isSmallInteger(millis)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7411 |
t = __intVal(millis); |
5133 | 7412 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7413 |
t = INFINITE; |
5133 | 7414 |
} |
7415 |
||
7416 |
#ifdef DO_WRAP_CALLS |
|
7417 |
do { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7418 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7419 |
res = STX_API_CALL2( "WaitForSingleObject", WaitForSingleObject, h, t); |
5133 | 7420 |
} while ((res < 0) && (__threadErrno == EINTR)); |
7421 |
#else |
|
7422 |
res = WaitForSingleObject(h, t); |
|
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
7423 |
if (res < 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7424 |
__threadErrno = __WIN32_ERR(GetLastError()); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
6095
diff
changeset
|
7425 |
} |
5133 | 7426 |
#endif |
7427 |
if (res == WAIT_FAILED) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7428 |
RETURN (nil); |
5133 | 7429 |
} |
7430 |
if (res == WAIT_TIMEOUT) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7431 |
RETURN (nil); |
5133 | 7432 |
} |
7433 |
||
7434 |
RETURN (fdOrHandle); |
|
7435 |
fail: ; |
|
7436 |
%}. |
|
7437 |
" |
|
7438 |
invalid arg, |
|
7439 |
" |
|
7440 |
^ self primitiveFailed |
|
7441 |
! ! |
|
7442 |
||
6275 | 7443 |
!Win32OperatingSystem::FileStatusInfo class methodsFor:'instance creation'! |
7444 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7445 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP alternativeName:name2 |
6275 | 7446 |
^ self basicNew |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7447 |
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
|
7448 |
id:i accessed:aT modified:mT created:cT |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7449 |
path:lP alternativeName:name2 |
7062 | 7450 |
! |
7451 |
||
7452 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP fullName:fullName alternativeName:name2 |
|
7453 |
^ self basicNew |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7454 |
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
|
7455 |
id:i accessed:aT modified:mT created:cT |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7456 |
path:lP |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7457 |
fullName:fullName |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7458 |
alternativeName:name2 |
6275 | 7459 |
! ! |
7460 |
||
7461 |
!Win32OperatingSystem::FileStatusInfo methodsFor:'accessing'! |
|
7462 |
||
6372 | 7463 |
accessTime |
7464 |
"return accessed" |
|
7465 |
||
7466 |
^ accessed |
|
7467 |
||
7468 |
"Created: / 1.2.2002 / 11:05:49 / cg" |
|
7469 |
! |
|
7470 |
||
6275 | 7471 |
alternativeName |
7472 |
"return the files other name (DOS name on windows). |
|
7473 |
Nil if there is no other name" |
|
7474 |
||
7475 |
^ alternativeName |
|
7476 |
! |
|
7477 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7478 |
creationTime |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7479 |
^ created |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7480 |
! |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7481 |
|
6372 | 7482 |
fileSize |
7483 |
"return size" |
|
7484 |
||
7485 |
^ size |
|
7486 |
||
7487 |
"Created: / 1.2.2002 / 11:06:15 / cg" |
|
7488 |
! |
|
7489 |
||
6275 | 7490 |
fixedHeaderSize |
7491 |
"return the fixedHeaderSize (VMS only; nil everywhere else)" |
|
7492 |
||
7493 |
^ nil |
|
7494 |
! |
|
7495 |
||
7062 | 7496 |
fullName |
7497 |
"return the files real name (non-DOS name on windows). |
|
7498 |
Nil if there is no other name" |
|
7499 |
||
7500 |
^ fullName |
|
7501 |
! |
|
7502 |
||
6275 | 7503 |
gid |
7504 |
"return gid" |
|
7505 |
||
7506 |
^ gid |
|
7507 |
! |
|
7508 |
||
7509 |
id |
|
7510 |
"return id" |
|
7511 |
||
7512 |
^ id |
|
7513 |
! |
|
7514 |
||
7515 |
mode |
|
7516 |
"return mode" |
|
7517 |
||
7518 |
^ mode |
|
7519 |
! |
|
7520 |
||
6372 | 7521 |
modificationTime |
7522 |
"return modified" |
|
7523 |
||
7524 |
^ modified |
|
7525 |
||
7526 |
"Created: / 1.2.2002 / 11:06:33 / cg" |
|
7527 |
! |
|
7528 |
||
7529 |
numLinks |
|
7530 |
"DOS has no hardLinks - return 1" |
|
7531 |
||
7532 |
^ 1 |
|
7533 |
||
7534 |
"Created: / 1.2.2002 / 11:07:04 / cg" |
|
7535 |
! |
|
7536 |
||
6275 | 7537 |
path |
7538 |
"for symbolic links only: return the path where the symbolic link points to" |
|
7539 |
||
7540 |
^ path |
|
7541 |
||
7542 |
! |
|
7543 |
||
7544 |
recordAttributes |
|
7545 |
"return the recordAttributes (VMS only; nil everywhere else)" |
|
7546 |
||
7547 |
^ nil |
|
7548 |
! |
|
7549 |
||
7550 |
recordFormat |
|
7551 |
"return the recordFormat (VMS only; nil everywhere else)" |
|
7552 |
||
7553 |
^ nil |
|
7554 |
! |
|
7555 |
||
7556 |
recordFormatNumeric |
|
7557 |
"return the recordFormat as numeric (VMS only; nil everywhere else)" |
|
7558 |
||
7559 |
^ nil |
|
7560 |
! |
|
7561 |
||
7562 |
recordSize |
|
7563 |
"return the recordSize (VMS only; nil everywhere else)" |
|
7564 |
||
7565 |
^ nil |
|
7566 |
! |
|
7567 |
||
7568 |
size |
|
7569 |
"return size" |
|
7570 |
||
7571 |
^ size |
|
7572 |
! |
|
7573 |
||
6372 | 7574 |
statusChangeTime |
7575 |
"return statusChanged" |
|
7576 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7577 |
^ statusChanged ? modified |
6372 | 7578 |
|
7579 |
"Created: / 1.2.2002 / 11:07:27 / cg" |
|
7580 |
! |
|
7581 |
||
6275 | 7582 |
type |
7583 |
"return type" |
|
7584 |
||
7585 |
^ type |
|
7586 |
! |
|
7587 |
||
7588 |
uid |
|
7589 |
"return uid" |
|
7590 |
||
7591 |
^ uid |
|
7592 |
! ! |
|
7593 |
||
7594 |
!Win32OperatingSystem::FileStatusInfo methodsFor:'backward compatibility'! |
|
7595 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7596 |
accessed |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7597 |
"return accessed" |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7598 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7599 |
self obsoleteMethodWarning:'use #accessTime'. |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7600 |
^ accessed |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7601 |
! |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7602 |
|
6275 | 7603 |
at:key |
7604 |
"backward compatibility access: in previous releases, IdentityDictionaries |
|
7605 |
were used to hold my information. Allow access via key messages. |
|
7606 |
This method will vanish - use the proper access protocol." |
|
7607 |
||
7608 |
^ self perform:key |
|
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7609 |
! |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7610 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7611 |
modified |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7612 |
"return modified" |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7613 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7614 |
self obsoleteMethodWarning:'use #modificationTime'. |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7615 |
^ modified |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7616 |
! |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7617 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7618 |
statusChanged |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7619 |
"return statusChanged" |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7620 |
|
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7621 |
self obsoleteMethodWarning:'use #statusChangeTime'. |
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7622 |
^ statusChanged |
6275 | 7623 |
! ! |
7624 |
||
7625 |
!Win32OperatingSystem::FileStatusInfo methodsFor:'private accessing'! |
|
7626 |
||
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7627 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP alternativeName:name2 |
6275 | 7628 |
type := t. |
7629 |
mode := m. |
|
7630 |
uid := u. |
|
7631 |
gid := g. |
|
7632 |
size := s. |
|
7633 |
id := i. |
|
7634 |
accessed := aT. |
|
7635 |
modified := mT. |
|
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
7636 |
created := cT. |
6275 | 7637 |
path := lP. |
7638 |
alternativeName := name2. |
|
7062 | 7639 |
! |
7640 |
||
7641 |
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT created:cT path:lP fullName:name1 alternativeName:name2 |
|
7642 |
type := t. |
|
7643 |
mode := m. |
|
7644 |
uid := u. |
|
7645 |
gid := g. |
|
7646 |
size := s. |
|
7647 |
id := i. |
|
7648 |
accessed := aT. |
|
7649 |
modified := mT. |
|
7650 |
created := cT. |
|
7651 |
path := lP. |
|
7652 |
fullName := name1. |
|
7653 |
alternativeName := name2. |
|
6275 | 7654 |
! ! |
7655 |
||
6799 | 7656 |
!Win32OperatingSystem::FileStatusInfo methodsFor:'queries'! |
7657 |
||
7658 |
isDirectory |
|
7659 |
^ type == #directory |
|
7660 |
! |
|
7661 |
||
7662 |
isSymbolicLink |
|
7663 |
^ type == #symbolicLink |
|
7664 |
! ! |
|
7665 |
||
6275 | 7666 |
!Win32OperatingSystem::OSProcessStatus class methodsFor:'documentation'! |
7667 |
||
7668 |
documentation |
|
7669 |
" |
|
7670 |
This is an auxillary class, that holds information about status changes of |
|
7671 |
operating system processes (these are no smalltalk processes!!). |
|
7672 |
||
7673 |
[Instance variables:] |
|
7674 |
||
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7675 |
pid <Integer> OS-Process identifier |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7676 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7677 |
status <Symbol> either #exit #signal #stop #continue |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7678 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7679 |
code <Integer> either exitcode or signalnumber |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7680 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7681 |
core <Boolean> true if core has been dumped |
6275 | 7682 |
|
7683 |
||
7684 |
[author:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7685 |
Stefan Vogel |
6275 | 7686 |
|
7687 |
[see also:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7688 |
OperatingSystem |
6275 | 7689 |
" |
7690 |
! ! |
|
7691 |
||
7692 |
!Win32OperatingSystem::OSProcessStatus class methodsFor:'instance creation'! |
|
7693 |
||
7694 |
pid:pid status:status code:code core:core |
|
7695 |
"private interface for Win32OperatingSystem" |
|
7696 |
||
7697 |
^ self new pid:pid status:status code:code core:core |
|
7698 |
||
7699 |
"Created: 28.12.1995 / 14:16:14 / stefan" |
|
7700 |
"Modified: 30.4.1996 / 18:25:00 / cg" |
|
7701 |
! |
|
7702 |
||
7703 |
processCreationFailure |
|
7704 |
"private interface for Win32OperatingSystem" |
|
7705 |
||
7706 |
^ self new pid:-1 status:#failure code:-1 core:false |
|
7707 |
||
7708 |
"Created: 28.12.1995 / 14:35:29 / stefan" |
|
7709 |
"Modified: 30.4.1996 / 18:25:05 / cg" |
|
7710 |
! ! |
|
7711 |
||
7712 |
!Win32OperatingSystem::OSProcessStatus methodsFor:'accessing'! |
|
7713 |
||
7714 |
code |
|
7715 |
"return the exitcode / signalNumber" |
|
7716 |
||
7717 |
^ code |
|
7718 |
||
7719 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7720 |
"Modified: 30.4.1996 / 18:26:23 / cg" |
|
7721 |
! |
|
7722 |
||
7723 |
core |
|
7724 |
"return true if core has been dumped, false otherwise" |
|
7725 |
||
7726 |
^ core == true |
|
7727 |
||
7728 |
"Modified: 28.12.1995 / 14:14:38 / stefan" |
|
7729 |
! |
|
7730 |
||
7731 |
pid |
|
7732 |
"return the pid" |
|
7733 |
||
7734 |
^ pid |
|
7735 |
||
7736 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7737 |
"Modified: 30.4.1996 / 18:26:30 / cg" |
|
7738 |
! |
|
7739 |
||
7740 |
status |
|
7741 |
"return status as a Symbol; |
|
7742 |
one of #exit #signal #stop #continue" |
|
7743 |
||
7744 |
^ status |
|
7745 |
||
7746 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7747 |
"Modified: 30.4.1996 / 18:26:54 / cg" |
|
7748 |
! ! |
|
7749 |
||
7750 |
!Win32OperatingSystem::OSProcessStatus methodsFor:'initialization'! |
|
7751 |
||
7752 |
pid:newPid status:newStatus code:newCode core:newCore |
|
7753 |
pid := newPid. |
|
7754 |
status := newStatus. |
|
7755 |
code := newCode. |
|
7756 |
core := newCore. |
|
7757 |
||
7758 |
"Created: 28.12.1995 / 14:18:22 / stefan" |
|
7759 |
! ! |
|
7760 |
||
7761 |
!Win32OperatingSystem::OSProcessStatus methodsFor:'private-OS interface'! |
|
7762 |
||
7763 |
code:something |
|
7764 |
"set the exitCode" |
|
7765 |
||
7766 |
code := something. |
|
7767 |
||
7768 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7769 |
"Modified: 30.4.1996 / 18:25:18 / cg" |
|
7770 |
! |
|
7771 |
||
7772 |
core:something |
|
7773 |
"set core" |
|
7774 |
||
7775 |
core := something. |
|
7776 |
||
7777 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7778 |
! |
|
7779 |
||
7780 |
pid:something |
|
7781 |
"set pid" |
|
7782 |
||
7783 |
pid := something. |
|
7784 |
||
7785 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7786 |
! |
|
7787 |
||
7788 |
status:something |
|
7789 |
"set status" |
|
7790 |
||
7791 |
status := something. |
|
7792 |
||
7793 |
"Created: 28.12.1995 / 14:05:07 / stefan" |
|
7794 |
! ! |
|
7795 |
||
7796 |
!Win32OperatingSystem::OSProcessStatus methodsFor:'queries'! |
|
7797 |
||
7798 |
couldNotExecute |
|
7799 |
"return true when a command could not be executed" |
|
7800 |
||
7801 |
^ status == #exit and:[code = 127]. |
|
7802 |
||
7803 |
"Created: 28.12.1995 / 15:43:17 / stefan" |
|
7804 |
"Modified: 30.4.1996 / 18:27:03 / cg" |
|
7805 |
! |
|
7806 |
||
7807 |
stillAlive |
|
7808 |
"true if process is still alive" |
|
7809 |
||
7810 |
^ status == #stop or:[status == #continue] |
|
7811 |
||
7812 |
"Created: 28.12.1995 / 14:27:26 / stefan" |
|
7813 |
! |
|
7814 |
||
7815 |
success |
|
7816 |
"true if process terminated successfully" |
|
7817 |
||
7818 |
^ status == #exit and:[code = 0] |
|
7819 |
||
7820 |
"Created: 28.12.1995 / 14:13:05 / stefan" |
|
7821 |
"Modified: 28.12.1995 / 14:13:41 / stefan" |
|
7822 |
! ! |
|
7823 |
||
5133 | 7824 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'defaults'! |
7825 |
||
7826 |
rootKeyNames |
|
7827 |
^ #( |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7828 |
'HKEY_CLASSES_ROOT' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7829 |
'HKEY_CURRENT_USER' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7830 |
'HKEY_LOCAL_MACHINE' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7831 |
'HKEY_USERS' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7832 |
'HKEY_PERFORMANCE_DATA' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7833 |
'HKEY_CURRENT_CONFIG' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7834 |
'HKEY_DYN_DATA' |
5133 | 7835 |
) |
7836 |
! |
|
7837 |
||
7838 |
separator |
|
7839 |
^$\ |
|
7840 |
! ! |
|
7841 |
||
7842 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'documentation'! |
|
7843 |
||
7844 |
documentation |
|
7845 |
" |
|
7846 |
Interface to a WIN32 registry. |
|
7847 |
||
7848 |
[author:] |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7849 |
Claus Gittinger (initial version & cleanup) |
5133 | 7850 |
" |
7851 |
||
7852 |
||
7853 |
! |
|
7854 |
||
7855 |
examples |
|
7856 |
" |
|
7857 |
create a key (if not already present): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7858 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7859 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7860 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7861 |
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
|
7862 |
[exEnd] |
5133 | 7863 |
|
7864 |
||
7865 |
ask a keys value: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7866 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7867 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7868 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7869 |
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
|
7870 |
Transcript show:'Windows serial NR:'; showCR:(k valueNamed:'ProductId'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7871 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7872 |
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
|
7873 |
Transcript showCR:(k valueNamed:'CurrentVersion'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7874 |
[exEnd] |
5133 | 7875 |
|
7876 |
||
7877 |
create a sub-key (if not already present): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7878 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7879 |
|k subKey| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7880 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7881 |
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
|
7882 |
subKey := k createSubKeyNamed:'RegistryDemo' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7883 |
[exEnd] |
5133 | 7884 |
|
7885 |
||
7886 |
change a keys value: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7887 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7888 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7889 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7890 |
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
|
7891 |
k valueNamed:'FooBarBaz' put:'a foo bar baz string'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7892 |
[exEnd] |
5133 | 7893 |
|
7894 |
delete a value: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7895 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7896 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7897 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7898 |
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
|
7899 |
k deleteValueNamed:'FooBarBaz'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7900 |
[exEnd] |
5133 | 7901 |
|
7902 |
delete a key: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7903 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7904 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7905 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7906 |
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
|
7907 |
k deleteSubKeyNamed:'RegistryDemo'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7908 |
[exEnd] |
5133 | 7909 |
|
7910 |
enumerate keys: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7911 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7912 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7913 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7914 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7915 |
k subKeysDo:[:subKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7916 |
Transcript showCR:subKey path |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7917 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7918 |
[exEnd] |
5133 | 7919 |
|
7920 |
enumerate all keys (recursive): |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7921 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7922 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7923 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7924 |
k := Win32OperatingSystem::RegistryEntry key:'HKEY_LOCAL_MACHINE\Software'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7925 |
k allSubKeysDo:[:subKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7926 |
Transcript showCR:subKey path |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7927 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7928 |
[exEnd] |
5133 | 7929 |
|
7930 |
fetch value by index: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7931 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7932 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7933 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7934 |
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
|
7935 |
Transcript showCR:(k valueNameAtIndex:0) |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7936 |
[exEnd] |
5133 | 7937 |
|
7938 |
||
7939 |
enumerate value names: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7940 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7941 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7942 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7943 |
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
|
7944 |
k valueNamesDo:[:nm | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7945 |
Transcript showCR:nm. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7946 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7947 |
[exEnd] |
5133 | 7948 |
|
7949 |
enumerate values: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7950 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7951 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7952 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7953 |
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
|
7954 |
k valueNamesAndValuesDo:[:nm :val | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7955 |
Transcript showCR:(nm , ' -> ' , val storeString). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7956 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7957 |
[exEnd] |
5133 | 7958 |
|
7959 |
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
|
7960 |
[exBegin] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7961 |
|k| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7962 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7963 |
k := self key:'HKEY_LOCAL_MACHINE\System'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7964 |
k subKeysDo:[:subKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7965 |
subKey subKeysDo:[:subSubKey | |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7966 |
|tcp params| |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7967 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7968 |
(subSubKey path asLowercase endsWith:'services') ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7969 |
tcp := subSubKey subKeyNamed:'tcpip'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7970 |
tcp notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7971 |
params := tcp subKeyNamed:'parameters'. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7972 |
params notNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7973 |
Transcript showCR:'Domain is found in ' , params path , |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7974 |
' value: ' , (params valueNamed:'Domain'). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7975 |
params close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7976 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7977 |
tcp close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7978 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7979 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7980 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7981 |
] |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
7982 |
[exEnd] |
5133 | 7983 |
|
7984 |
||
7985 |
" |
|
7986 |
! ! |
|
7987 |
||
7988 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'initialization'! |
|
7989 |
||
7990 |
initialize |
|
7991 |
Lobby := Registry new. |
|
7992 |
||
7993 |
HKEY_CLASSES_ROOT := %{ __MKEXTERNALADDRESS(HKEY_CLASSES_ROOT) %}. |
|
7994 |
HKEY_CURRENT_USER := %{ __MKEXTERNALADDRESS(HKEY_CURRENT_USER) %}. |
|
7995 |
HKEY_LOCAL_MACHINE := %{ __MKEXTERNALADDRESS(HKEY_LOCAL_MACHINE) %}. |
|
7996 |
HKEY_USERS := %{ __MKEXTERNALADDRESS(HKEY_USERS) %}. |
|
7997 |
HKEY_PERFORMANCE_DATA := %{ __MKEXTERNALADDRESS(HKEY_PERFORMANCE_DATA) %}. |
|
7998 |
HKEY_CURRENT_CONFIG := %{ __MKEXTERNALADDRESS(HKEY_CURRENT_CONFIG) %}. |
|
7999 |
HKEY_DYN_DATA := %{ __MKEXTERNALADDRESS(HKEY_DYN_DATA) %}. |
|
8000 |
||
8001 |
"Created: / 19.5.1999 / 21:39:57 / cg" |
|
8002 |
"Modified: / 19.5.1999 / 22:45:31 / cg" |
|
8003 |
! |
|
8004 |
||
8005 |
rootKeyValueFor:specialKeyStringOrSymbol |
|
5142 | 8006 |
HKEY_CLASSES_ROOT isNil ifTrue:[self initialize]. |
8007 |
||
5133 | 8008 |
specialKeyStringOrSymbol = 'HKEY_CLASSES_ROOT' ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8009 |
^ HKEY_CLASSES_ROOT. |
5133 | 8010 |
]. |
8011 |
specialKeyStringOrSymbol = 'HKEY_CURRENT_USER' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8012 |
^ HKEY_CURRENT_USER. |
5133 | 8013 |
]. |
8014 |
specialKeyStringOrSymbol = 'HKEY_LOCAL_MACHINE' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8015 |
^ HKEY_LOCAL_MACHINE. |
5133 | 8016 |
]. |
8017 |
specialKeyStringOrSymbol = 'HKEY_USERS' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8018 |
^ HKEY_USERS. |
5133 | 8019 |
]. |
8020 |
specialKeyStringOrSymbol = 'HKEY_PERFORMANCE_DATA' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8021 |
^ HKEY_PERFORMANCE_DATA. |
5133 | 8022 |
]. |
8023 |
specialKeyStringOrSymbol = 'HKEY_CURRENT_CONFIG' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8024 |
^ HKEY_CURRENT_CONFIG. |
5133 | 8025 |
]. |
8026 |
specialKeyStringOrSymbol = 'HKEY_DYN_DATA' ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8027 |
^ HKEY_DYN_DATA. |
5133 | 8028 |
]. |
8029 |
||
8030 |
^ nil |
|
8031 |
||
8032 |
"Created: / 19.5.1999 / 21:40:30 / cg" |
|
5142 | 8033 |
"Modified: / 24.12.1999 / 00:02:06 / cg" |
5133 | 8034 |
! ! |
8035 |
||
8036 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'instance creation'! |
|
8037 |
||
8038 |
key:aKeyNamePath |
|
8039 |
"retrieve an entry by full path name (starting at a root)" |
|
8040 |
||
8041 |
|idx first rest root| |
|
8042 |
||
5142 | 8043 |
HKEY_CLASSES_ROOT isNil ifTrue:[self initialize]. |
8044 |
||
5133 | 8045 |
idx := |
8046 |
idx := aKeyNamePath indexOf:(self separator). |
|
8047 |
idx == 0 ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8048 |
first := aKeyNamePath. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8049 |
rest := nil. |
5133 | 8050 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8051 |
first := aKeyNamePath copyTo:idx-1. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8052 |
rest := aKeyNamePath copyFrom:idx+1 |
5133 | 8053 |
]. |
8054 |
||
8055 |
first := first asUppercase. |
|
8056 |
||
8057 |
"/ the first is a pseudo name |
|
8058 |
root := self rootKey:first. |
|
8059 |
root isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8060 |
^ nil |
5133 | 8061 |
]. |
8062 |
||
8063 |
rest size == 0 ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8064 |
^ root |
5133 | 8065 |
]. |
8066 |
||
8067 |
^ root subKeyNamed:rest. |
|
8068 |
||
8069 |
" |
|
8070 |
self key:'HKEY_LOCAL_MACHINE' |
|
8071 |
self key:'HKEY_LOCAL_MACHINE\Software' |
|
8072 |
self key:'HKEY_LOCAL_MACHINE\Software\Borland\' |
|
8073 |
self key:'HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\3.2.5\Directory' |
|
8074 |
" |
|
5142 | 8075 |
|
8076 |
"Modified: / 24.12.1999 / 00:01:52 / cg" |
|
5133 | 8077 |
! |
8078 |
||
8079 |
rootKey:aRootKeyStringOrSymbol |
|
8080 |
"retrieve one of the root entries by name" |
|
8081 |
||
8082 |
|keyVal| |
|
8083 |
||
8084 |
keyVal := self rootKeyValueFor:aRootKeyStringOrSymbol. |
|
8085 |
keyVal isNil ifTrue:[^ nil]. |
|
8086 |
"/ rootKeys are not registered for RegClose ... |
|
8087 |
^ self basicNew setHandle:keyVal path:aRootKeyStringOrSymbol. |
|
8088 |
||
8089 |
" |
|
8090 |
RegistryEntry rootKey:#'HKEY_LOCAL_MACHINE' |
|
8091 |
" |
|
8092 |
! ! |
|
8093 |
||
8094 |
!Win32OperatingSystem::RegistryEntry class methodsFor:'registry access'! |
|
8095 |
||
8096 |
stringValueFor:valueName atKey:keyPath |
|
8097 |
"convenient accessing method; |
|
8098 |
Looks for a string value under keyPath; |
|
8099 |
returns nil if either not found, or no string value" |
|
8100 |
||
8101 |
|k v| |
|
8102 |
||
8103 |
k := self key:keyPath. |
|
8104 |
k isNil ifTrue:[^ nil]. |
|
8105 |
v := k valueNamed:valueName. |
|
8106 |
k close. |
|
8107 |
v isString ifFalse:[^ nil]. |
|
8108 |
^ v |
|
8109 |
||
8110 |
" |
|
8111 |
self |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8112 |
stringValueFor:'Content Type' |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8113 |
atKey:'HKEY_CLASSES_ROOT\.au' |
5133 | 8114 |
" |
8115 |
! ! |
|
8116 |
||
8117 |
!Win32OperatingSystem::RegistryEntry methodsFor:'accessing'! |
|
8118 |
||
8119 |
name |
|
8120 |
"return the keys name component (subKey name within my |
|
8121 |
parent key)" |
|
8122 |
||
8123 |
|idx| |
|
8124 |
||
8125 |
idx := path lastIndexOf:(self class separator). |
|
8126 |
idx == 0 ifTrue:[^ path]. |
|
8127 |
^ path copyFrom:idx+1 |
|
8128 |
! |
|
8129 |
||
8130 |
path |
|
8131 |
"return the keys full key path name" |
|
8132 |
||
8133 |
^ path. |
|
8134 |
! ! |
|
8135 |
||
8136 |
!Win32OperatingSystem::RegistryEntry methodsFor:'accessing subkeys'! |
|
8137 |
||
8138 |
createSubKeyNamed:subKeyString |
|
8139 |
"create a new key below mySelf and return a new registry entry for it. |
|
8140 |
If it already exists, return it. |
|
8141 |
Return nil if the new key cannot be created." |
|
8142 |
||
8143 |
|newEntry subHandle| |
|
8144 |
||
8145 |
%{ |
|
8146 |
HKEY myKey, subKey = 0; |
|
8147 |
||
8148 |
if (__isExternalAddress(__INST(handle)) |
|
8149 |
&& (__isString(subKeyString) || __isSymbol(subKeyString))) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8150 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8151 |
if (RegCreateKey(myKey, __stringVal(subKeyString), &subKey) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8152 |
subHandle = __MKEXTERNALADDRESS(subKey); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8153 |
} |
5133 | 8154 |
} |
8155 |
%}. |
|
8156 |
subHandle notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8157 |
newEntry := self class basicNew |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8158 |
setHandle:subHandle |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8159 |
path:(path , self class separator asString , subKeyString). |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8160 |
Lobby register:newEntry. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8161 |
^ newEntry. |
5133 | 8162 |
]. |
8163 |
^ nil |
|
8164 |
||
8165 |
" |
|
8166 |
|top sub| |
|
8167 |
||
8168 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8169 |
sub := top createSubKeyNamed:'FooBarBaz'. |
|
8170 |
" |
|
8171 |
! |
|
8172 |
||
8173 |
deleteSubKeyNamed:subKeyString |
|
8174 |
"delete a key below mySelf. |
|
8175 |
Return true on success." |
|
8176 |
||
8177 |
%{ |
|
8178 |
HKEY myKey; |
|
8179 |
||
8180 |
if (__isExternalAddress(__INST(handle)) |
|
8181 |
&& (__isString(subKeyString) || __isSymbol(subKeyString))) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8182 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8183 |
if (RegDeleteKey(myKey, __stringVal(subKeyString)) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8184 |
RETURN (true); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8185 |
} |
5133 | 8186 |
} |
8187 |
%}. |
|
8188 |
^ false |
|
8189 |
||
8190 |
" |
|
8191 |
|top sub| |
|
8192 |
||
8193 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8194 |
sub := top createSubKeyNamed:'FooBarBaz'. |
|
8195 |
top deleteSubKeyNamed:'FooBarBaz'. |
|
8196 |
" |
|
8197 |
! |
|
8198 |
||
8199 |
remoteKeyOnHost:hostName |
|
8200 |
"return the corresponding registry entry from |
|
8201 |
a remote computers registry." |
|
8202 |
||
8203 |
|newEntry remoteHandle| |
|
8204 |
||
8205 |
%{ |
|
8206 |
HKEY myKey, remoteKey = 0; |
|
8207 |
||
8208 |
if (__isExternalAddress(__INST(handle)) && __isString(hostName)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8209 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8210 |
if (RegConnectRegistry(__stringVal(hostName), myKey, &remoteKey) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8211 |
remoteHandle = __MKEXTERNALADDRESS(remoteKey); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8212 |
} |
5133 | 8213 |
} |
8214 |
%}. |
|
8215 |
remoteHandle notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8216 |
newEntry := self class basicNew setHandle:remoteHandle path:path. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8217 |
Lobby register:newEntry. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8218 |
^ newEntry. |
5133 | 8219 |
]. |
8220 |
^ nil |
|
8221 |
||
8222 |
" |
|
8223 |
|top remote| |
|
8224 |
||
8225 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8226 |
remote := top remoteKeyOnHost:'BETTI' |
|
8227 |
" |
|
8228 |
" |
|
8229 |
|top remote| |
|
8230 |
||
8231 |
top := self key:'HKEY_USERS'. |
|
8232 |
remote := top remoteKeyOnHost:'BETTI' |
|
8233 |
" |
|
8234 |
" |
|
8235 |
|top remote| |
|
8236 |
||
8237 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8238 |
remote := top remoteKeyOnHost:'JOSHUA' |
|
8239 |
" |
|
8240 |
" |
|
8241 |
|top remote| |
|
8242 |
||
8243 |
top := self key:'HKEY_USERS'. |
|
8244 |
remote := top remoteKeyOnHost:'JOSHUA' |
|
8245 |
" |
|
8246 |
||
8247 |
! |
|
8248 |
||
8249 |
subKeyAtIndex:subKeyIndex |
|
8250 |
"return a new registry entry below mySelf for the given subKey index. |
|
8251 |
Return nil if no such key exists" |
|
8252 |
||
8253 |
|subKeyName subKeyClassName| |
|
8254 |
||
8255 |
%{ |
|
8256 |
HKEY myKey, subKey = 0; |
|
8257 |
char nameBuffer[256]; |
|
8258 |
DWORD nameSize = sizeof(nameBuffer) - 1; |
|
8259 |
char classNameBuffer[256]; |
|
8260 |
DWORD classNameSize = sizeof(classNameBuffer) - 1; |
|
8261 |
FILETIME modificationTime; |
|
8262 |
||
8263 |
if (__isExternalAddress(__INST(handle)) |
|
8264 |
&& __isSmallInteger(subKeyIndex)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8265 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8266 |
if (RegEnumKeyEx(myKey, __intVal(subKeyIndex), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8267 |
nameBuffer, &nameSize, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8268 |
NULL, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8269 |
classNameBuffer, &classNameSize, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8270 |
&modificationTime) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8271 |
nameBuffer[nameSize] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8272 |
classNameBuffer[classNameSize] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8273 |
subKeyName = __MKSTRING(nameBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8274 |
subKeyClassName = __MKSTRING(classNameBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8275 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8276 |
} |
5133 | 8277 |
} |
8278 |
%}. |
|
8279 |
subKeyName isNil ifTrue:[^ nil]. |
|
8280 |
^ self subKeyNamed:subKeyName. |
|
8281 |
||
8282 |
" |
|
8283 |
|top sub| |
|
8284 |
||
8285 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8286 |
sub := top subKeyAtIndex:0 |
|
8287 |
" |
|
8288 |
! |
|
8289 |
||
8290 |
subKeyNamed:subKeyString |
|
8291 |
"return a new registry entry below mySelf with the given subKey. |
|
8292 |
Return nil if no such key exists" |
|
8293 |
||
8294 |
|newEntry subHandle| |
|
8295 |
||
8296 |
%{ |
|
8297 |
HKEY myKey, subKey = 0; |
|
8298 |
||
8299 |
if (__isExternalAddress(__INST(handle)) |
|
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 (RegOpenKey(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 subKeyNamed:'Software' |
|
8321 |
" |
|
8322 |
! ! |
|
8323 |
||
8324 |
!Win32OperatingSystem::RegistryEntry methodsFor:'accessing values'! |
|
8325 |
||
8326 |
deleteValueNamed:aValueName |
|
8327 |
"delete a value. |
|
8328 |
Return true on success." |
|
8329 |
||
8330 |
%{ |
|
8331 |
HKEY myKey; |
|
8332 |
||
8333 |
if (__isExternalAddress(__INST(handle)) |
|
8334 |
&& (__isString(aValueName) || __isSymbol(aValueName))) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8335 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8336 |
if (RegDeleteValue(myKey, __stringVal(aValueName)) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8337 |
RETURN (true); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8338 |
} |
5133 | 8339 |
} |
8340 |
%}. |
|
8341 |
^ false |
|
8342 |
! |
|
8343 |
||
8344 |
valueNameAtIndex:valueIndex |
|
8345 |
"return a values name for the given value index. |
|
8346 |
Return nil if no such value exists" |
|
8347 |
||
8348 |
|valueName| |
|
8349 |
||
8350 |
%{ |
|
8351 |
HKEY myKey; |
|
8352 |
char nameBuffer[256]; |
|
8353 |
DWORD nameSize = sizeof(nameBuffer) - 1; |
|
8354 |
DWORD valueType; |
|
8355 |
||
8356 |
if (__isExternalAddress(__INST(handle)) |
|
8357 |
&& __isSmallInteger(valueIndex)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8358 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8359 |
if (RegEnumValue(myKey, __intVal(valueIndex), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8360 |
nameBuffer, &nameSize, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8361 |
NULL, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8362 |
&valueType, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8363 |
NULL, NULL) == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8364 |
nameBuffer[nameSize] = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8365 |
valueName = __MKSTRING(nameBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8366 |
} |
5133 | 8367 |
} |
8368 |
%}. |
|
8369 |
^ valueName |
|
8370 |
||
8371 |
" |
|
8372 |
|top sub| |
|
8373 |
||
8374 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8375 |
sub := top subKeyAtIndex:0 |
|
8376 |
" |
|
8377 |
! |
|
8378 |
||
8379 |
valueNamed:aValueName |
|
8380 |
"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
|
8381 |
REG_BINARY -> ByteArray |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8382 |
REG_SZ -> String |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8383 |
REG_MULTI_SZ -> Array of strings |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8384 |
REG_DWORD -> Integer |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8385 |
REG_NONE -> nil |
5133 | 8386 |
" |
8387 |
||
8388 |
|data stringArray| |
|
8389 |
%{ |
|
8390 |
HKEY myKey; |
|
8391 |
DWORD valueType; |
|
8392 |
union { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8393 |
DWORD dWord; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8394 |
unsigned char dWordBytes[4]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8395 |
unsigned char smallDataBuffer[256]; |
5133 | 8396 |
} quickData; |
8397 |
int val; |
|
8398 |
DWORD dataSize = sizeof(quickData); |
|
8399 |
unsigned char *dataBuffer = NULL; |
|
8400 |
||
8401 |
if (__isExternalAddress(__INST(handle)) |
|
8402 |
&& (__isString(aValueName) || __isSymbol(aValueName))) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8403 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8404 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8405 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8406 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8407 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8408 |
* try to get it with one call ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8409 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8410 |
ret = RegQueryValueEx(myKey, __stringVal(aValueName), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8411 |
NULL, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8412 |
&valueType, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8413 |
&quickData, &dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8414 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8415 |
if (ret == ERROR_MORE_DATA) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8416 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8417 |
* nope - need another one ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8418 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8419 |
switch (valueType) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8420 |
case REG_BINARY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8421 |
case REG_MULTI_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8422 |
data = __BYTEARRAY_UNINITIALIZED_NEW_INT(dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8423 |
dataBuffer = __ByteArrayInstPtr(data)->ba_element; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8424 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8425 |
case REG_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8426 |
data = __MKEMPTYSTRING(dataSize-1); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8427 |
dataBuffer = __stringVal(data); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8428 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8429 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8430 |
if (dataBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8431 |
ret = RegQueryValueEx(myKey, __stringVal(aValueName), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8432 |
NULL, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8433 |
&valueType, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8434 |
dataBuffer, &dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8435 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8436 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8437 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8438 |
if (ret == ERROR_SUCCESS) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8439 |
switch (valueType) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8440 |
case REG_NONE: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8441 |
/* RETURN (@symbol(none)); */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8442 |
RETURN (nil); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8443 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8444 |
case REG_BINARY: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8445 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8446 |
* did we get it with the first call ? |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8447 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8448 |
if (! dataBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8449 |
data = __MKBYTEARRAY(quickData.smallDataBuffer, dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8450 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8451 |
RETURN (data); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8452 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8453 |
case REG_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8454 |
case REG_EXPAND_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8455 |
/* |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8456 |
* did we get it with the first call ? |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8457 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8458 |
if (! dataBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8459 |
data = __MKSTRING_L(quickData.smallDataBuffer, dataSize-1); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8460 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8461 |
RETURN (data); |
5133 | 8462 |
|
8463 |
#if 0 |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8464 |
case REG_DWORD: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8465 |
/* int in native format */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8466 |
RETURN (__MKUINT(quickData.dWord)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8467 |
#endif |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8468 |
case REG_DWORD_LITTLE_ENDIAN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8469 |
val = quickData.dWordBytes[3]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8470 |
val = (val << 8) | quickData.dWordBytes[2]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8471 |
val = (val << 8) | quickData.dWordBytes[1]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8472 |
val = (val << 8) | quickData.dWordBytes[0]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8473 |
RETURN (__MKUINT(val)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8474 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8475 |
case REG_DWORD_BIG_ENDIAN: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8476 |
val = quickData.dWordBytes[0]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8477 |
val = (val << 8) | quickData.dWordBytes[1]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8478 |
val = (val << 8) | quickData.dWordBytes[2]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8479 |
val = (val << 8) | quickData.dWordBytes[3]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8480 |
RETURN (__MKUINT(val)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8481 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8482 |
case REG_MULTI_SZ: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8483 |
{ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8484 |
char *cp, *cp0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8485 |
int ns = 0, i; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8486 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8487 |
cp0 = dataBuffer ? dataBuffer : quickData.smallDataBuffer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8488 |
cp = cp0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8489 |
while (*cp) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8490 |
while (*cp++) ;; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8491 |
ns++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8492 |
cp++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8493 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8494 |
stringArray = __ARRAY_NEW_INT(ns); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8495 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8496 |
i = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8497 |
while (*cp0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8498 |
OBJ s; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8499 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8500 |
cp = cp0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8501 |
while (*cp++) ;; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8502 |
s = __MKSTRING(cp0); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8503 |
__ArrayInstPtr(stringArray)->a_element[i] = s; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8504 |
__STORE(stringArray, s); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8505 |
cp++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8506 |
cp0 = cp; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8507 |
i++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8508 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8509 |
RETURN (stringArray); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8510 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8511 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8512 |
} |
5133 | 8513 |
} |
8514 |
%}. |
|
8515 |
^ nil |
|
8516 |
||
8517 |
" |
|
8518 |
|key| |
|
8519 |
||
8520 |
key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'. |
|
8521 |
key valueNamed:'CurrentVersion' |
|
8522 |
" |
|
8523 |
! |
|
8524 |
||
8525 |
valueNamed:aValueName put:datum |
|
8526 |
"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
|
8527 |
ByteArray -> REG_BINARY |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8528 |
String -> REG_SZ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8529 |
Array of string -> REG_MULTI_SZ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8530 |
Integer -> REG_DWORD |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8531 |
nil -> REG_NONE |
5133 | 8532 |
" |
8533 |
||
8534 |
|data stringArray| |
|
8535 |
%{ |
|
8536 |
HKEY myKey; |
|
8537 |
DWORD valueType = -1; |
|
8538 |
int val; |
|
8539 |
DWORD dataSize = -1; |
|
8540 |
unsigned char *dataPointer = NULL; |
|
8541 |
int datumOk = 1, mustFreeData = 0; |
|
8542 |
||
8543 |
if (__isExternalAddress(__INST(handle)) |
|
8544 |
&& (__isString(aValueName) || __isSymbol(aValueName))) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8545 |
int ret; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8546 |
OBJ cls; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8547 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8548 |
myKey = (HKEY)__externalAddressVal(__INST(handle)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8549 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8550 |
if (datum == nil) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8551 |
valueType = REG_NONE; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8552 |
dataSize = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8553 |
} else if (__isSmallInteger(datum)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8554 |
valueType = REG_DWORD; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8555 |
val = __intVal(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8556 |
dataPointer = (unsigned char *)(&val); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8557 |
dataSize = sizeof(val); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8558 |
} else if (__isString(datum) || __isSymbol(datum)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8559 |
valueType = REG_SZ; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8560 |
dataPointer = __stringVal(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8561 |
dataSize = __stringSize(datum) + 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8562 |
} else if (__Class(datum) == ByteArray) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8563 |
valueType = REG_BINARY; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8564 |
dataPointer = __ByteArrayInstPtr(datum)->ba_element; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8565 |
dataSize = __byteArraySize(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8566 |
} else if (__Class(datum) == LargeInteger) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8567 |
valueType = REG_DWORD; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8568 |
val = __longIntVal(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8569 |
if (val) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8570 |
dataPointer = (unsigned char *)(&val); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8571 |
dataSize = sizeof(val); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8572 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8573 |
datumOk = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8574 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8575 |
} else if (__Class(datum) == Array) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8576 |
int i = 0, ns = 0, totalSize = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8577 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8578 |
valueType = REG_MULTI_SZ; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8579 |
|
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 |
* must allocate a local buffer |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8582 |
* find size ... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8583 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8584 |
for (i=0; i<__arraySize(datum); i++) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8585 |
OBJ s = __ArrayInstPtr(datum)->a_element[i]; |
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 |
if (__isString(datum) || __isSymbol(datum)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8588 |
totalSize += __stringSize(datum) + 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8589 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8590 |
datumOk = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8591 |
break; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8592 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8593 |
ns++; |
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 |
if (datumOk) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8596 |
char *cp; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8597 |
|
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 |
* allocate and fill... |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8600 |
*/ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8601 |
totalSize ++; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8602 |
dataPointer = (char *)(malloc(totalSize)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8603 |
mustFreeData = 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8604 |
cp = dataPointer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8605 |
for (i=0; i<__arraySize(datum); i++) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8606 |
OBJ s = __ArrayInstPtr(datum)->a_element[i]; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8607 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8608 |
strcpy(cp, __stringVal(s)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8609 |
cp += __stringSize(datum); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8610 |
*cp++ = '\0'; |
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 |
*cp++ = '\0'; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8613 |
dataSize = totalSize; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8614 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8615 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8616 |
datumOk = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8617 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8618 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8619 |
if (datumOk) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8620 |
ret = RegSetValueEx(myKey, __stringVal(aValueName), |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8621 |
0, valueType, |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8622 |
dataPointer, dataSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8623 |
if (mustFreeData) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8624 |
free(dataPointer); |
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 |
RETURN ((ret == ERROR_SUCCESS) ? true : false); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8627 |
} |
5133 | 8628 |
} |
8629 |
%}. |
|
8630 |
^ false |
|
8631 |
||
8632 |
" |
|
8633 |
|key| |
|
8634 |
||
8635 |
key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'. |
|
8636 |
key valueNamed:'CurrentVersion' put:'3.5.2' |
|
8637 |
" |
|
8638 |
! ! |
|
8639 |
||
8640 |
!Win32OperatingSystem::RegistryEntry methodsFor:'enumeration'! |
|
8641 |
||
8642 |
allSubKeysDo:aBlock |
|
8643 |
"recursively evaluate aBlock for all subKeys below the receiver" |
|
8644 |
||
8645 |
|idx subEntry| |
|
8646 |
||
8647 |
idx := 0. |
|
8648 |
[true] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8649 |
subEntry := self subKeyAtIndex:idx. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8650 |
subEntry isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8651 |
^self |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8652 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8653 |
aBlock value:subEntry. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8654 |
subEntry allSubKeysDo:aBlock. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8655 |
subEntry close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8656 |
idx := idx + 1. |
5133 | 8657 |
] |
8658 |
||
8659 |
" |
|
8660 |
|top sub| |
|
8661 |
||
8662 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8663 |
top allSubKeysDo:[:subEntry | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8664 |
Transcript showCR:subEntry path |
5133 | 8665 |
] |
8666 |
" |
|
8667 |
! |
|
8668 |
||
5135 | 8669 |
subKeys |
8670 |
"return a collection of subKeys below the receiver" |
|
8671 |
||
8672 |
|idx subEntry subKeys| |
|
8673 |
||
8674 |
subKeys := OrderedCollection new. |
|
8675 |
self subKeysDo:[:k | subKeys add:k]. |
|
8676 |
^ subKeys |
|
8677 |
||
8678 |
" |
|
8679 |
|top sub| |
|
8680 |
||
8681 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8682 |
top subKeys |
|
8683 |
" |
|
8684 |
||
8685 |
"Created: / 23.12.1999 / 22:15:22 / cg" |
|
8686 |
"Modified: / 23.12.1999 / 22:15:44 / cg" |
|
8687 |
! |
|
8688 |
||
5133 | 8689 |
subKeysDo:aBlock |
8690 |
"evaluate aBlock for all subKeys below the receiver" |
|
8691 |
||
8692 |
|idx subEntry| |
|
8693 |
||
8694 |
idx := 0. |
|
8695 |
[true] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8696 |
subEntry := self subKeyAtIndex:idx. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8697 |
subEntry isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8698 |
^self |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8699 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8700 |
aBlock value:subEntry. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8701 |
subEntry close. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8702 |
idx := idx + 1. |
5133 | 8703 |
] |
8704 |
||
8705 |
" |
|
8706 |
|top sub| |
|
8707 |
||
8708 |
top := self key:'HKEY_LOCAL_MACHINE'. |
|
8709 |
top subKeysDo:[:subEntry | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8710 |
Transcript showCR:subEntry path |
5133 | 8711 |
] |
8712 |
" |
|
8713 |
! |
|
8714 |
||
8715 |
valueNamesAndValuesDo:aBlock |
|
8716 |
"evaluate aBlock for all value names" |
|
8717 |
||
8718 |
self valueNamesDo:[:nm | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8719 |
aBlock value:nm value:(self valueNamed:nm) |
5133 | 8720 |
] |
8721 |
||
8722 |
" |
|
8723 |
|key| |
|
8724 |
||
8725 |
key := self key:'HKEY_LOCAL_MACHINE\SOFTWARE\eXept\Smalltalk/X'. |
|
8726 |
key valueNamesAndValuesDo:[:nm :val | |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8727 |
Transcript showCR:(nm , ' -> ' , val storeString). |
5133 | 8728 |
] |
8729 |
" |
|
8730 |
! |
|
8731 |
||
8732 |
valueNamesDo:aBlock |
|
8733 |
"evaluate aBlock for all value names" |
|
8734 |
||
8735 |
|idx valueName| |
|
8736 |
||
8737 |
idx := 0. |
|
8738 |
[true] whileTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8739 |
valueName := self valueNameAtIndex:idx. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8740 |
valueName isNil ifTrue:[ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8741 |
^self |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8742 |
]. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8743 |
aBlock value:valueName. |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8744 |
idx := idx + 1. |
5133 | 8745 |
] |
8746 |
! ! |
|
8747 |
||
8748 |
!Win32OperatingSystem::RegistryEntry methodsFor:'instance release'! |
|
8749 |
||
8750 |
close |
|
8751 |
"close mySelf" |
|
8752 |
||
8753 |
self closeKey. |
|
8754 |
Lobby unregister:self. |
|
8755 |
||
8756 |
"Modified: / 19.5.1999 / 22:44:44 / cg" |
|
8757 |
! |
|
8758 |
||
8759 |
closeKey |
|
8760 |
"close mySelf" |
|
8761 |
||
8762 |
%{ |
|
8763 |
HKEY myKey; |
|
8764 |
||
8765 |
if (__isExternalAddress(__INST(handle))) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8766 |
myKey = (HKEY)(__externalAddressVal(__INST(handle))); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8767 |
__INST(handle) = nil; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8768 |
RegCloseKey(myKey); |
5133 | 8769 |
} |
8770 |
%} |
|
8771 |
! |
|
8772 |
||
8773 |
disposed |
|
8774 |
"some entry has been collected - close it" |
|
8775 |
||
8776 |
handle notNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8777 |
self closeKey. |
5133 | 8778 |
] |
8779 |
||
8780 |
"Created: / 19.5.1999 / 22:39:52 / cg" |
|
8781 |
"Modified: / 19.5.1999 / 22:44:50 / cg" |
|
8782 |
! ! |
|
8783 |
||
8784 |
!Win32OperatingSystem::RegistryEntry methodsFor:'private'! |
|
8785 |
||
8786 |
setHandle:aHandle path:aPathString |
|
8787 |
handle := aHandle. |
|
8788 |
path := aPathString. |
|
8789 |
||
8790 |
"Created: / 19.5.1999 / 22:27:05 / cg" |
|
8791 |
! |
|
8792 |
||
8793 |
setupForHandleValue:integerHandleValue |
|
8794 |
"not normally used - given an integer address, |
|
8795 |
return a registry entry. This is provided to |
|
8796 |
allow for future root keys to be added at the smalltalk level" |
|
8797 |
||
8798 |
%{ |
|
8799 |
HKEY key; |
|
8800 |
OBJ t; |
|
8801 |
||
8802 |
key = __longIntVal(integerHandleValue); |
|
8803 |
if (! key) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8804 |
RETURN (nil); |
5133 | 8805 |
} |
8806 |
||
8807 |
__INST(handle) = t = __MKEXTERNALADDRESS(key); __STORE(self, t); |
|
8808 |
%}. |
|
8809 |
||
8810 |
"Created: / 19.5.1999 / 21:45:05 / cg" |
|
8811 |
! ! |
|
8812 |
||
6293 | 8813 |
!Win32OperatingSystem::Win32FILEHandle class methodsFor:'documentation'! |
8814 |
||
8815 |
documentation |
|
8816 |
" |
|
8817 |
I represent a FILE*, as used in the stdio library. |
|
8818 |
Since most stdio libs are inherently buggy, thread-unsave |
|
8819 |
and hard to use in a multithreading environment, |
|
8820 |
these will no longer be used in future ST/X versions. |
|
8821 |
However, they may be useful when interfacing to external |
|
8822 |
libraries... |
|
8823 |
" |
|
8824 |
! |
|
8825 |
||
8826 |
version |
|
7535 | 8827 |
^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.132 2003-07-25 20:19:01 cg Exp $' |
6293 | 8828 |
! ! |
8829 |
||
8830 |
!Win32OperatingSystem::Win32FILEHandle methodsFor:'release'! |
|
8831 |
||
8832 |
closeFile |
|
8833 |
"close the file" |
|
8834 |
||
8835 |
%{ |
|
8836 |
FILE *f = (FILE *)(__externalAddressVal(self)); |
|
8837 |
||
8838 |
if (f) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8839 |
__externalAddressVal(self) = NULL; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8840 |
fclose(f); |
6293 | 8841 |
} |
8842 |
%}. |
|
8843 |
! ! |
|
8844 |
||
8845 |
!Win32OperatingSystem::Win32Handle class methodsFor:'documentation'! |
|
8846 |
||
8847 |
documentation |
|
8848 |
" |
|
8849 |
I represent a generic HANDLE, which can be closed via CloseHandle. |
|
8850 |
" |
|
8851 |
! |
|
8852 |
||
8853 |
version |
|
7535 | 8854 |
^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.132 2003-07-25 20:19:01 cg Exp $' |
6293 | 8855 |
! ! |
8856 |
||
8857 |
!Win32OperatingSystem::Win32Handle methodsFor:'io'! |
|
8858 |
||
8859 |
readBytes:count into:aByteBuffer startingAt:firstIndex |
|
8860 |
"read count bytes into a byte-buffer; |
|
8861 |
Return the number of bytes read (negative on error)" |
|
8862 |
||
6304 | 8863 |
|errSym errorNumber| |
8864 |
||
6293 | 8865 |
%{ |
8866 |
unsigned char *extPtr; |
|
6336 | 8867 |
int bufferIsExternalBytes; |
8868 |
int mustFreeBuffer = 0; |
|
6293 | 8869 |
int nRead = -1; |
6304 | 8870 |
HANDLE hFile = (HANDLE)(__externalAddressVal(self)); |
8871 |
DWORD cntWanted, offs, cntRead; |
|
8872 |
int bufferSize; |
|
6336 | 8873 |
char miniBuffer[32]; |
8874 |
BOOL ok; |
|
6304 | 8875 |
|
8876 |
if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8877 |
errSym = @symbol(errorNotOpen); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8878 |
goto bad; |
6293 | 8879 |
} |
6304 | 8880 |
if (! __bothSmallInteger(count, firstIndex)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8881 |
errSym = @symbol(badArgument); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8882 |
goto bad; |
6304 | 8883 |
} |
8884 |
cntWanted = __smallIntegerVal(count); |
|
6336 | 8885 |
if (cntWanted <= 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8886 |
errSym = @symbol(badCount); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8887 |
goto bad; |
6293 | 8888 |
} |
6336 | 8889 |
offs = __smallIntegerVal(firstIndex) - 1; |
8890 |
if (offs < 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8891 |
errSym = @symbol(badOffset); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8892 |
goto bad; |
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 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8895 |
bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer); |
6336 | 8896 |
if (! bufferIsExternalBytes) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8897 |
if (__isByteArray(aByteBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8898 |
bufferSize = __byteArraySize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8899 |
} else if (__isString(aByteBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8900 |
bufferSize = __stringSize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8901 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8902 |
errSym = @symbol(badBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8903 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8904 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8905 |
if (bufferSize < (cntWanted + offs)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8906 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8907 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8908 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8909 |
if (cntWanted <= sizeof(miniBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8910 |
extPtr = miniBuffer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8911 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8912 |
extPtr = malloc(cntWanted); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8913 |
mustFreeBuffer = 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8914 |
} |
6336 | 8915 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8916 |
OBJ sz; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8917 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8918 |
extPtr = (char *)(__externalBytesAddress(aByteBuffer)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8919 |
sz = __externalBytesSize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8920 |
if (! __isSmallInteger(sz)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8921 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8922 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8923 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8924 |
bufferSize = __smallIntegerVal(sz); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8925 |
if (bufferSize < (cntWanted + offs)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8926 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8927 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8928 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8929 |
extPtr = extPtr + offs; |
6336 | 8930 |
} |
8931 |
||
6337 | 8932 |
do { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8933 |
__threadErrno = 0; |
6338 | 8934 |
#ifndef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8935 |
ok = ReadFile(hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */); |
6338 | 8936 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8937 |
ok = __STX_API_CALL5( "ReadFile", ReadFile, hFile, extPtr, cntWanted, &cntRead, 0 /* lpOverlapped */); |
6338 | 8938 |
#endif |
6337 | 8939 |
} while(__threadErrno == EINTR); |
8940 |
||
6336 | 8941 |
if (ok == TRUE) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8942 |
if (! bufferIsExternalBytes) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8943 |
/* copy over */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8944 |
memcpy(__byteArrayVal(aByteBuffer)+offs, extPtr, cntRead); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8945 |
if (mustFreeBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8946 |
free(extPtr); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8947 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8948 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8949 |
RETURN (__mkSmallInteger(cntRead)); |
6336 | 8950 |
} |
8951 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
|
8952 |
||
6293 | 8953 |
bad: ; |
6336 | 8954 |
if (mustFreeBuffer) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8955 |
free(extPtr); |
6336 | 8956 |
} |
6293 | 8957 |
%}. |
6304 | 8958 |
|
8959 |
errorNumber isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8960 |
self error:'invalid argument(s): ', errSym. |
6304 | 8961 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8962 |
(OperatingSystem errorHolderForNumber:errorNumber) reportError |
6304 | 8963 |
]. |
6293 | 8964 |
|
8965 |
" |
|
8966 |
|h buff n| |
|
8967 |
||
8968 |
h := self basicNew. |
|
6304 | 8969 |
buff := ByteArray new:10. |
6293 | 8970 |
n := h readBytes:10 into:buff startingAt:1. |
8971 |
Transcript show:n; space; showCR:buff. |
|
8972 |
" |
|
8973 |
! |
|
8974 |
||
6337 | 8975 |
readWaitWithTimeoutMs:millis |
8976 |
"return true if a timeout occurred" |
|
8977 |
||
8978 |
|errSym errorNumber| |
|
8979 |
||
8980 |
%{ |
|
8981 |
HANDLE hFile = (HANDLE)(__externalAddressVal(self)); |
|
8982 |
DWORD res; |
|
8983 |
INT t; |
|
8984 |
||
8985 |
if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8986 |
errSym = @symbol(errorNotOpen); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8987 |
goto bad; |
6337 | 8988 |
} |
8989 |
||
8990 |
#if 0 |
|
8991 |
if (ioctlsocket((SOCKET)hFile, FIONREAD, &res)==0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8992 |
/* its a socket */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8993 |
if (res > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8994 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8995 |
} |
6337 | 8996 |
} |
8997 |
if (PeekNamedPipe(hFile, 0, 0, 0, &res, 0)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8998 |
/* its a namedPipe */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
8999 |
if (res > 0) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9000 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9001 |
} |
6337 | 9002 |
} |
9003 |
#endif |
|
9004 |
if (__isSmallInteger(millis)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9005 |
t = __intVal(millis); |
6337 | 9006 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9007 |
t = INFINITE; |
6337 | 9008 |
} |
9009 |
||
9010 |
do { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9011 |
__threadErrno = 0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9012 |
res = WaitForSingleObject(hFile, t); |
6337 | 9013 |
} while (__threadErrno == EINTR); |
9014 |
||
9015 |
switch (res) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9016 |
case WAIT_OBJECT_0: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9017 |
/* signalled */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9018 |
RETURN ( false ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9019 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9020 |
case WAIT_TIMEOUT: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9021 |
/* signalled */ |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9022 |
RETURN ( true ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9023 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9024 |
default: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9025 |
case WAIT_ABANDONED: |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9026 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9027 |
goto bad; |
6337 | 9028 |
} |
9029 |
||
9030 |
bad: ; |
|
9031 |
%}. |
|
9032 |
" |
|
9033 |
timeout argument not integer, |
|
9034 |
or any fd-array nonNil and not an array |
|
9035 |
or not supported by OS |
|
9036 |
" |
|
9037 |
^ self primitiveFailed |
|
9038 |
! |
|
9039 |
||
6336 | 9040 |
seekTo:newPosition from:whence |
9041 |
"whence is one of: |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9042 |
#begin |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9043 |
#current |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9044 |
#end |
6336 | 9045 |
" |
9046 |
||
9047 |
|errSym errorNumber| |
|
9048 |
||
9049 |
%{ |
|
9050 |
HANDLE hFile = (HANDLE)(__externalAddressVal(self)); |
|
9051 |
DWORD moveHow; |
|
9052 |
LONG posLo, posHi = 0; |
|
9053 |
__uint64__ pos64, newPos64; |
|
9054 |
||
9055 |
if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9056 |
errSym = @symbol(errorNotOpen); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9057 |
goto bad; |
6336 | 9058 |
} |
9059 |
||
9060 |
if (whence == @symbol(begin)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9061 |
moveHow = FILE_BEGIN; |
6336 | 9062 |
} else if (whence == @symbol(current)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9063 |
moveHow = FILE_CURRENT; |
6336 | 9064 |
} else if (whence == @symbol(end)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9065 |
moveHow = FILE_END; |
6336 | 9066 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9067 |
errSym = @symbol(badArgument2); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9068 |
goto bad; |
6336 | 9069 |
} |
9070 |
||
9071 |
if (__signedLong64IntVal(newPosition, &pos64) == 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9072 |
errSym = @symbol(badArgument); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9073 |
goto bad; |
6336 | 9074 |
} |
9075 |
posLo = pos64.lo; |
|
9076 |
posHi = pos64.hi; |
|
9077 |
||
9078 |
posLo = SetFilePointer(hFile, posLo, &posHi, moveHow); |
|
9079 |
if (posLo == 0xFFFFFFFF) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9080 |
int lastError; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9081 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9082 |
/* 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
|
9083 |
lastError = GetLastError(); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9084 |
if (lastError != NO_ERROR) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9085 |
errorNumber = __mkSmallInteger( __WIN32_ERR(lastError) ); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9086 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9087 |
} |
6336 | 9088 |
} |
9089 |
||
9090 |
if (posHi == 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9091 |
RETURN (__MKUINT( posLo )); |
6336 | 9092 |
} |
9093 |
newPos64.lo = posLo; |
|
9094 |
newPos64.hi = posHi; |
|
9095 |
||
9096 |
RETURN ( __MKUINT64(&newPos64) ); |
|
9097 |
||
9098 |
bad: ; |
|
9099 |
%}. |
|
9100 |
||
9101 |
errorNumber isNil ifTrue:[ |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9102 |
self error:'invalid argument(s): ', errSym. |
6336 | 9103 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9104 |
(OperatingSystem errorHolderForNumber:errorNumber) reportError |
6336 | 9105 |
]. |
9106 |
! |
|
9107 |
||
6293 | 9108 |
writeBytes:count from:aByteBuffer startingAt:firstIndex |
9109 |
"write count bytes from a byte-buffer; |
|
9110 |
Return the number of bytes written (negative on error)" |
|
9111 |
||
6304 | 9112 |
|errSym errorNumber| |
6293 | 9113 |
%{ |
9114 |
unsigned char *extPtr; |
|
6338 | 9115 |
int bufferIsExternalBytes; |
9116 |
int mustFreeBuffer = 0; |
|
6293 | 9117 |
int nWritten = -1; |
6304 | 9118 |
HANDLE hFile = (HANDLE)(__externalAddressVal(self)); |
9119 |
DWORD cntWanted, offs, cntWritten; |
|
9120 |
int bufferSize; |
|
6338 | 9121 |
char miniBuffer[32]; |
9122 |
BOOL ok; |
|
6304 | 9123 |
|
9124 |
if ((hFile == 0) || (hFile == INVALID_HANDLE_VALUE)) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9125 |
errSym = @symbol(errorNotOpen); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9126 |
goto bad; |
6293 | 9127 |
} |
6304 | 9128 |
if (! __bothSmallInteger(count, firstIndex)) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9129 |
errSym = @symbol(badArgument); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9130 |
goto bad; |
6304 | 9131 |
} |
9132 |
cntWanted = __smallIntegerVal(count); |
|
6338 | 9133 |
if (cntWanted <= 0) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9134 |
errSym = @symbol(badCount); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9135 |
goto bad; |
6293 | 9136 |
} |
6338 | 9137 |
offs = __smallIntegerVal(firstIndex) - 1; |
9138 |
if (offs < 0) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9139 |
errSym = @symbol(badOffset); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9140 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9141 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9142 |
|
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9143 |
bufferIsExternalBytes = __isExternalBytesLike(aByteBuffer); |
6338 | 9144 |
if (! bufferIsExternalBytes) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9145 |
if (__isByteArray(aByteBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9146 |
bufferSize = __byteArraySize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9147 |
} else if (__isString(aByteBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9148 |
bufferSize = __stringSize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9149 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9150 |
errSym = @symbol(badBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9151 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9152 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9153 |
if (bufferSize < (cntWanted + offs)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9154 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9155 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9156 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9157 |
if (cntWanted <= sizeof(miniBuffer)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9158 |
extPtr = miniBuffer; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9159 |
} else { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9160 |
extPtr = malloc(cntWanted); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9161 |
mustFreeBuffer = 1; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9162 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9163 |
memcpy(extPtr, __byteArrayVal(aByteBuffer)+offs, cntWanted); |
6338 | 9164 |
} else { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9165 |
extPtr = (char *)(__externalBytesAddress(aByteBuffer)); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9166 |
bufferSize = __externalBytesSize(aByteBuffer); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9167 |
if (! __isSmallInteger(bufferSize)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9168 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9169 |
goto bad; |
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 |
bufferSize = __smallIntegerVal(bufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9172 |
if (bufferSize < (cntWanted + offs)) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9173 |
errSym = @symbol(badBufferSize); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9174 |
goto bad; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9175 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9176 |
extPtr = extPtr + offs; |
6338 | 9177 |
} |
9178 |
||
9179 |
do { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9180 |
__threadErrno = 0; |
6338 | 9181 |
#ifndef DO_WRAP_CALLS |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9182 |
ok = WriteFile(hFile, extPtr, cntWanted, &cntWritten, 0 /* lpOverlapped */); |
6338 | 9183 |
#else |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9184 |
ok = __STX_API_CALL5( "WriteFile", WriteFile, hFile, extPtr, cntWanted, &cntWritten, 0 /* lpOverlapped */); |
6338 | 9185 |
#endif |
9186 |
} while(__threadErrno == EINTR); |
|
9187 |
||
9188 |
if (ok == TRUE) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9189 |
if (mustFreeBuffer) { |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9190 |
free(extPtr); |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9191 |
} |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9192 |
RETURN (__mkSmallInteger(cntWritten)); |
6338 | 9193 |
} |
9194 |
errorNumber = __mkSmallInteger( __WIN32_ERR(GetLastError()) ); |
|
9195 |
||
6293 | 9196 |
bad: ; |
6338 | 9197 |
if (mustFreeBuffer) { |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9198 |
free(extPtr); |
6338 | 9199 |
} |
6293 | 9200 |
%}. |
6304 | 9201 |
errorNumber isNil ifTrue:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9202 |
self error:'invalid argument(s): ', errSym. |
6304 | 9203 |
] ifFalse:[ |
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9204 |
(OperatingSystem errorHolderForNumber:errorNumber) reportError |
6304 | 9205 |
]. |
6293 | 9206 |
|
9207 |
" |
|
9208 |
|h buff n| |
|
9209 |
||
9210 |
h := self basicNew. |
|
9211 |
h setFileDescriptor:1. |
|
9212 |
buff := '12345678901234567890'. |
|
9213 |
n := h writeBytes:10 from:buff startingAt:1. |
|
9214 |
" |
|
9215 |
! ! |
|
9216 |
||
6297 | 9217 |
!Win32OperatingSystem::Win32Handle methodsFor:'queries'! |
9218 |
||
9219 |
isValid |
|
9220 |
^ self address ~~0 |
|
9221 |
! ! |
|
9222 |
||
6293 | 9223 |
!Win32OperatingSystem::Win32Handle methodsFor:'release'! |
9224 |
||
9225 |
closeFile |
|
9226 |
"close the handle" |
|
9227 |
||
9228 |
%{ |
|
9229 |
HANDLE h = (HANDLE)(__externalAddressVal(self)); |
|
9230 |
||
9231 |
if (h) { |
|
7199
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9232 |
__externalAddressVal(self) = (HANDLE)0; |
922f78e7eb72
also handle subclasses of externalBytes
Claus Gittinger <cg@exept.de>
parents:
7158
diff
changeset
|
9233 |
CloseHandle(h); |
6293 | 9234 |
} |
9235 |
%}. |
|
9236 |
! ! |
|
9237 |
||
5133 | 9238 |
!Win32OperatingSystem class methodsFor:'documentation'! |
9239 |
||
9240 |
version |
|
7535 | 9241 |
^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.132 2003-07-25 20:19:01 cg Exp $' |
5133 | 9242 |
! ! |
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
9243 |
|
5135 | 9244 |
Win32OperatingSystem initialize! |
6791
ecc0ee933ef8
statusChangeTime is really creationTime
Claus Gittinger <cg@exept.de>
parents:
6740
diff
changeset
|
9245 |
Win32OperatingSystem::RegistryEntry initialize! |