author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 29 Sep 2011 16:44:37 +0100 | |
branch | jv |
changeset 17869 | 9610c6c94e71 |
parent 17865 | 598963c6ff8e |
child 17892 | d86c8bd5ece3 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
155 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
7826 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
1 | 14 |
FileStream subclass:#DirectoryStream |
1664 | 15 |
instanceVariableNames:'dirPointer readAheadEntry' |
1281
b4b3abffdf32
Support optional signal generation on end of stream.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
16 |
classVariableNames:'' |
b4b3abffdf32
Support optional signal generation on end of stream.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
17 |
poolDictionaries:'' |
b4b3abffdf32
Support optional signal generation on end of stream.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
18 |
category:'Streams-External' |
1 | 19 |
! |
20 |
||
217 | 21 |
!DirectoryStream primitiveDefinitions! |
1 | 22 |
%{ |
437 | 23 |
|
1631 | 24 |
#define UNIX_LIKE |
2609 | 25 |
|
1631 | 26 |
#if defined(WIN32) |
27 |
# undef UNIX_LIKE |
|
28 |
#endif |
|
437 | 29 |
|
2896 | 30 |
#if defined(transputer) |
31 |
# undef UNIX_LIKE |
|
32 |
#endif |
|
33 |
||
1631 | 34 |
#ifdef UNIX_LIKE |
7955
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
35 |
# if defined(__GLIBC__) && (__GLIBC__ == 2) |
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
36 |
# if defined(__GLIBC_MINOR__) && (__GLIBC_MINOR__ == 1) |
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
37 |
/* there is a bug there, preventing 64bit readdir. */ |
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
38 |
# undef __USE_FILE_OFFSET64 |
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
39 |
# undef __USE_LARGEFILE64 |
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
40 |
# endif |
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
41 |
# endif |
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
42 |
|
1631 | 43 |
# include <stdio.h> |
44 |
# define _STDIO_H_INCLUDED_ |
|
45 |
||
46 |
# include <errno.h> |
|
47 |
# define _ERRNO_H_INCLUDED_ |
|
10 | 48 |
|
2896 | 49 |
# include <sys/types.h> |
50 |
# include <sys/stat.h> |
|
1631 | 51 |
|
2896 | 52 |
# ifdef HAS_OPENDIR |
53 |
# include <sys/types.h> |
|
54 |
# ifdef NEXT |
|
55 |
# include <sys/dir.h> |
|
8881
53e94478133f
STORE macro fix (gcc3.4 bug)
Claus Gittinger <cg@exept.de>
parents:
8775
diff
changeset
|
56 |
# define DIRENT_STRUCT struct direct |
2896 | 57 |
# else |
58 |
# include <dirent.h> |
|
8881
53e94478133f
STORE macro fix (gcc3.4 bug)
Claus Gittinger <cg@exept.de>
parents:
8775
diff
changeset
|
59 |
# define DIRENT_STRUCT struct dirent |
1 | 60 |
# endif |
61 |
# endif |
|
223 | 62 |
|
63 |
/* |
|
64 |
* on some systems errno is a macro ... check for it here |
|
65 |
*/ |
|
1631 | 66 |
# ifndef errno |
67 |
extern errno; |
|
68 |
# endif |
|
2896 | 69 |
|
1631 | 70 |
#endif /* UNIX_LIKE */ |
71 |
||
2896 | 72 |
|
1631 | 73 |
#ifdef WIN32 |
74 |
||
8901
824a89d0b5c7
alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents:
8881
diff
changeset
|
75 |
# ifdef __i386__ |
1631 | 76 |
# define _X86_ |
77 |
# endif |
|
78 |
||
79 |
# undef INT |
|
80 |
# undef Array |
|
81 |
# undef Number |
|
82 |
# undef Method |
|
83 |
# undef Point |
|
84 |
# undef Context |
|
85 |
# undef Rectangle |
|
1989 | 86 |
# undef Block |
4298 | 87 |
# undef Time |
88 |
# undef Date |
|
10342 | 89 |
# undef Message |
90 |
# undef Process |
|
91 |
# undef Processor |
|
92 |
# undef INT |
|
1631 | 93 |
|
2685 | 94 |
/* # include <types.h> /* */ |
1989 | 95 |
# include <stdarg.h> /* */ |
5120
13143fbcbdf8
introduced __threadErrno (for native threads)
Claus Gittinger <cg@exept.de>
parents:
4526
diff
changeset
|
96 |
# include <errno.h> |
13143fbcbdf8
introduced __threadErrno (for native threads)
Claus Gittinger <cg@exept.de>
parents:
4526
diff
changeset
|
97 |
# define _ERRNO_H_INCLUDED_ |
1989 | 98 |
# include <windef.h> /* */ |
99 |
# include <winbase.h> /* */ |
|
4298 | 100 |
/* # include <wingdi.h> /* */ |
101 |
/* # include <winuser.h> /* */ |
|
1631 | 102 |
|
103 |
# ifdef __DEF_Array |
|
104 |
# define Array __DEF_Array |
|
105 |
# endif |
|
106 |
# ifdef __DEF_Number |
|
107 |
# define Number __DEF_Number |
|
108 |
# endif |
|
109 |
# ifdef __DEF_Method |
|
110 |
# define Method __DEF_Method |
|
111 |
# endif |
|
112 |
# ifdef __DEF_Point |
|
113 |
# define Point __DEF_Point |
|
114 |
# endif |
|
1989 | 115 |
# ifdef __DEF_Block |
116 |
# define Block __DEF_Block |
|
117 |
# endif |
|
1631 | 118 |
# ifdef __DEF_Context |
119 |
# define Context __DEF_Context |
|
120 |
# endif |
|
4298 | 121 |
# ifdef __DEF_Date |
122 |
# define Date __DEF_Date |
|
123 |
# endif |
|
124 |
# ifdef __DEF_Time |
|
125 |
# define Time __DEF_Time |
|
126 |
# endif |
|
10342 | 127 |
# ifdef __DEF_Message |
128 |
# define Message __DEF_Message |
|
129 |
# endif |
|
130 |
# ifdef __DEF_Process |
|
131 |
# define Process __DEF_Process |
|
132 |
# endif |
|
133 |
# ifdef __DEF_Processor |
|
134 |
# define Processor __DEF_Processor |
|
135 |
# endif |
|
136 |
# define INT int |
|
1631 | 137 |
|
2999
b0e55440cf12
eliminate MKOBJ & MKCP (use MKEXTERNALADDRESS & externalAddressVal)
Claus Gittinger <cg@exept.de>
parents:
2982
diff
changeset
|
138 |
# define __HANDLEVal(o) (HANDLE)__externalAddressVal(o) |
17751 | 139 |
#endif /* WIN32 */ |
1631 | 140 |
|
17751 | 141 |
#include "stxOSDefs.h" |
223 | 142 |
|
1 | 143 |
%} |
206 | 144 |
! ! |
1 | 145 |
|
438 | 146 |
!DirectoryStream primitiveFunctions! |
147 |
%{ |
|
2896 | 148 |
|
149 |
#ifndef HAS_OPENDIR |
|
7955
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
150 |
|
2896 | 151 |
# if defined(__VMS__) |
152 |
||
3816
af3f917c7759
use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
Claus Gittinger <cg@exept.de>
parents:
3164
diff
changeset
|
153 |
# define lib$find_file LIB$FIND_FILE |
438 | 154 |
|
155 |
/* |
|
156 |
** VMS readdir() routines. |
|
157 |
** Written by Rich $alz, <rsalz@bbn.com> in August, 1990. |
|
158 |
** This code has no copyright. |
|
159 |
*/ |
|
160 |
||
8881
53e94478133f
STORE macro fix (gcc3.4 bug)
Claus Gittinger <cg@exept.de>
parents:
8775
diff
changeset
|
161 |
/* 12-NOV-1990 added d_namlen field and special case "." name -GJC@MITECH.COM |
438 | 162 |
*/ |
163 |
||
2896 | 164 |
# ifndef _STDIO_H_INCLUDED_ |
165 |
# include <stdio.h> |
|
166 |
# define _STDIO_H_INCLUDED_ |
|
167 |
# endif |
|
438 | 168 |
|
2896 | 169 |
# ifndef _CTYPE_H_INCLUDED_ |
170 |
# include <ctype.h> |
|
171 |
# define _CTYPE_H_INCLUDED_ |
|
172 |
# endif |
|
438 | 173 |
|
2896 | 174 |
# ifndef _ERRNO_H_INCLUDED_ |
175 |
# include <errno.h> |
|
176 |
# define _ERRNO_H_INCLUDED_ |
|
177 |
# endif |
|
438 | 178 |
|
2896 | 179 |
# ifndef _DESCRIP_H_INCLUDED_ |
180 |
# include <descrip.h> |
|
181 |
# define _DESCRIP_H_INCLUDED_ |
|
182 |
# endif |
|
438 | 183 |
|
2896 | 184 |
# ifndef _RMSDEF_H_INCLUDED_ |
185 |
# include <rmsdef.h> |
|
186 |
# define _RMSDEF_H_INCLUDED_ |
|
187 |
# endif |
|
438 | 188 |
|
189 |
/* |
|
190 |
* actually, the following has to go into dirent.h ... |
|
191 |
*/ |
|
2896 | 192 |
/* BEGIN included dirent.h |
438 | 193 |
* |
194 |
** Header file for VMS readdir() routines. |
|
195 |
** Written by Rich $alz, <rsalz@bbn.com> in August, 1990. |
|
196 |
** This code has no copyright. |
|
197 |
** |
|
198 |
** You must #include <descrip.h> before this file. |
|
199 |
*/ |
|
200 |
||
201 |
/* 12-NOV-1990 added d_namlen field -GJC@MITECH.COM */ |
|
202 |
||
203 |
/* Data structure returned by READDIR(). */ |
|
204 |
struct dirent { |
|
205 |
char d_name[100]; /* File name */ |
|
206 |
int d_namlen; |
|
2957 | 207 |
int vms_verscount; /* Number of versions */ |
208 |
int vms_versions[20]; /* Version numbers */ |
|
438 | 209 |
}; |
210 |
||
211 |
/* Handle returned by opendir(), used by the other routines. You |
|
212 |
* are not supposed to care what's inside this structure. */ |
|
213 |
typedef struct _dirdesc { |
|
214 |
long context; |
|
2957 | 215 |
int vms_wantversions; |
438 | 216 |
char *pattern; |
217 |
struct dirent entry; |
|
218 |
struct dsc$descriptor_s pat; |
|
219 |
} DIR; |
|
220 |
||
221 |
||
222 |
#define rewinddir(dirp) seekdir((dirp), 0L) |
|
223 |
||
224 |
||
225 |
extern DIR *opendir(); |
|
226 |
extern struct dirent *readdir(); |
|
227 |
extern long telldir(); |
|
228 |
extern void seekdir(); |
|
229 |
extern void closedir(); |
|
230 |
extern void vmsreaddirversions(); |
|
231 |
/* |
|
232 |
* END dirent.h |
|
233 |
*/ |
|
2896 | 234 |
#define _DIRENT_H_INCLUDED_ |
438 | 235 |
|
236 |
||
237 |
/* Number of elements in vms_versions array */ |
|
238 |
#define VERSIZE(e) (sizeof e->vms_versions / sizeof e->vms_versions[0]) |
|
239 |
||
240 |
/* Linked in later. */ |
|
241 |
extern char *strrchr(); |
|
242 |
extern char *strcpy(); |
|
243 |
/* Don't need this when all these programs are lumped together. RLD |
|
244 |
extern char *malloc(); |
|
245 |
*/ |
|
246 |
||
247 |
/* |
|
248 |
** Open a directory, return a handle for later use. |
|
249 |
*/ |
|
250 |
DIR * |
|
251 |
opendir(name) |
|
252 |
char *name; |
|
253 |
{ |
|
254 |
DIR *dd; |
|
255 |
||
256 |
/* Get memory for the handle, and the pattern. */ |
|
257 |
if ((dd = (DIR *)malloc(sizeof *dd)) == NULL) { |
|
5120
13143fbcbdf8
introduced __threadErrno (for native threads)
Claus Gittinger <cg@exept.de>
parents:
4526
diff
changeset
|
258 |
__threadErrno = ENOMEM; |
438 | 259 |
return NULL; |
260 |
} |
|
261 |
||
262 |
if (strcmp(".",name) == 0) name = ""; |
|
263 |
||
264 |
dd->pattern = malloc((unsigned int)(strlen(name) + sizeof "*.*" + 1)); |
|
265 |
if (dd->pattern == NULL) { |
|
266 |
free((char *)dd); |
|
5120
13143fbcbdf8
introduced __threadErrno (for native threads)
Claus Gittinger <cg@exept.de>
parents:
4526
diff
changeset
|
267 |
__threadErrno = ENOMEM; |
438 | 268 |
return NULL; |
269 |
} |
|
270 |
||
271 |
/* Fill in the fields; mainly playing with the descriptor. */ |
|
272 |
(void)sprintf(dd->pattern, "%s*.*", name); |
|
273 |
dd->context = 0; |
|
274 |
dd->vms_wantversions = 0; |
|
275 |
dd->pat.dsc$a_pointer = dd->pattern; |
|
276 |
dd->pat.dsc$w_length = strlen(dd->pattern); |
|
277 |
dd->pat.dsc$b_dtype = DSC$K_DTYPE_T; |
|
278 |
dd->pat.dsc$b_class = DSC$K_CLASS_S; |
|
279 |
||
280 |
return dd; |
|
281 |
} |
|
282 |
||
283 |
/* |
|
284 |
** Set the flag to indicate we want versions or not. |
|
285 |
*/ |
|
286 |
void |
|
287 |
vmsreaddirversions(dd, flag) |
|
288 |
DIR *dd; |
|
289 |
int flag; |
|
290 |
{ |
|
291 |
dd->vms_wantversions = flag; |
|
292 |
} |
|
293 |
||
294 |
/* |
|
295 |
** Free up an opened directory. |
|
296 |
*/ |
|
297 |
void |
|
298 |
closedir(dd) |
|
299 |
DIR *dd; |
|
300 |
{ |
|
301 |
free(dd->pattern); |
|
302 |
free((char *)dd); |
|
303 |
} |
|
304 |
||
305 |
/* |
|
306 |
** Collect all the version numbers for the current file. |
|
307 |
*/ |
|
308 |
static void |
|
309 |
collectversions(dd) |
|
310 |
DIR *dd; |
|
311 |
{ |
|
312 |
struct dsc$descriptor_s pat; |
|
313 |
struct dsc$descriptor_s res; |
|
314 |
struct dirent *e; |
|
315 |
char *p; |
|
316 |
char buff[sizeof dd->entry.d_name]; |
|
317 |
int i; |
|
318 |
char *text; |
|
319 |
long context; |
|
320 |
||
321 |
/* Convenient shorthand. */ |
|
322 |
e = &dd->entry; |
|
323 |
||
324 |
/* Add the version wildcard, ignoring the "*.*" put on before */ |
|
325 |
i = strlen(dd->pattern); |
|
326 |
text = malloc((unsigned int)(i + strlen(e->d_name)+ 2 + 1)); |
|
327 |
if (text == NULL) |
|
328 |
return; |
|
329 |
(void)strcpy(text, dd->pattern); |
|
330 |
(void)sprintf(&text[i - 3], "%s;*", e->d_name); |
|
331 |
||
332 |
/* Set up the pattern descriptor. */ |
|
333 |
pat.dsc$a_pointer = text; |
|
334 |
pat.dsc$w_length = strlen(text); |
|
335 |
pat.dsc$b_dtype = DSC$K_DTYPE_T; |
|
336 |
pat.dsc$b_class = DSC$K_CLASS_S; |
|
337 |
||
338 |
/* Set up result descriptor. */ |
|
339 |
res.dsc$a_pointer = buff; |
|
340 |
res.dsc$w_length = sizeof buff - 2; |
|
341 |
res.dsc$b_dtype = DSC$K_DTYPE_T; |
|
342 |
res.dsc$b_class = DSC$K_CLASS_S; |
|
343 |
||
344 |
/* Read files, collecting versions. */ |
|
345 |
for (context = 0; e->vms_verscount < VERSIZE(e); e->vms_verscount++) { |
|
346 |
if (lib$find_file(&pat, &res, &context) == RMS$_NMF || context == 0) |
|
347 |
break; |
|
348 |
buff[sizeof buff - 1] = '\0'; |
|
349 |
if (p = strchr(buff, ';')) |
|
350 |
e->vms_versions[e->vms_verscount] = atoi(p + 1); |
|
351 |
else |
|
352 |
e->vms_versions[e->vms_verscount] = -1; |
|
353 |
} |
|
354 |
||
355 |
free(text); |
|
356 |
} |
|
357 |
||
358 |
/* |
|
359 |
** Read the next entry from the directory. |
|
360 |
*/ |
|
361 |
struct dirent * |
|
362 |
readdir(dd) |
|
2957 | 363 |
DIR *dd; |
438 | 364 |
{ |
2957 | 365 |
struct dsc$descriptor_s res; |
366 |
char *p; |
|
2982 | 367 |
char buff[sizeof dd->entry.d_name + 10]; |
2957 | 368 |
int i; |
438 | 369 |
|
370 |
/* Set up result descriptor, and get next file. */ |
|
371 |
res.dsc$a_pointer = buff; |
|
372 |
res.dsc$w_length = sizeof buff - 2; |
|
373 |
res.dsc$b_dtype = DSC$K_DTYPE_T; |
|
374 |
res.dsc$b_class = DSC$K_CLASS_S; |
|
375 |
if (lib$find_file(&dd->pat, &res, &dd->context) == RMS$_NMF |
|
376 |
|| dd->context == 0L) |
|
377 |
/* None left... */ |
|
378 |
return NULL; |
|
379 |
||
380 |
/* Force the buffer to end with a NUL. */ |
|
381 |
buff[sizeof buff - 1] = '\0'; |
|
382 |
for (p = buff; !isspace(*p); p++) |
|
383 |
; |
|
384 |
*p = '\0'; |
|
385 |
||
386 |
/* Skip any directory component and just copy the name. */ |
|
387 |
if (p = strchr(buff, ']')) |
|
388 |
(void)strcpy(dd->entry.d_name, p + 1); |
|
389 |
else |
|
390 |
(void)strcpy(dd->entry.d_name, buff); |
|
391 |
||
392 |
/* Clobber the version. */ |
|
393 |
if (p = strchr(dd->entry.d_name, ';')) |
|
394 |
*p = '\0'; |
|
395 |
||
2982 | 396 |
/* claus: empty dirs seems to leave *.* in the buffer ... */ |
397 |
if (strcmp(dd->entry.d_name, "*.*") == 0) { |
|
398 |
return NULL; |
|
399 |
} |
|
400 |
||
438 | 401 |
dd->entry.d_namlen = strlen(dd->entry.d_name); |
402 |
||
403 |
dd->entry.vms_verscount = 0; |
|
404 |
if (dd->vms_wantversions) |
|
405 |
collectversions(dd); |
|
406 |
return &dd->entry; |
|
407 |
} |
|
408 |
||
409 |
/* |
|
410 |
** Return something that can be used in a seekdir later. |
|
411 |
*/ |
|
412 |
long |
|
413 |
telldir(dd) |
|
2957 | 414 |
DIR *dd; |
438 | 415 |
{ |
416 |
return dd->context; |
|
417 |
} |
|
418 |
||
419 |
/* |
|
420 |
** Return to a spot where we used to be. |
|
421 |
*/ |
|
422 |
void |
|
423 |
seekdir(dd, pos) |
|
2957 | 424 |
DIR *dd; |
425 |
long pos; |
|
438 | 426 |
{ |
427 |
dd->context = pos; |
|
428 |
} |
|
429 |
||
2896 | 430 |
# define HAS_OPENDIR |
431 |
||
432 |
# endif /* __VMS__ */ |
|
433 |
#endif /* not HAS_OPENDIR */ |
|
438 | 434 |
%} |
435 |
! ! |
|
436 |
||
613 | 437 |
!DirectoryStream class methodsFor:'documentation'! |
438 |
||
439 |
copyright |
|
440 |
" |
|
441 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
442 |
All Rights Reserved |
|
1 | 443 |
|
613 | 444 |
This software is furnished under a license and may be used |
445 |
only in accordance with the terms of that license and with the |
|
446 |
inclusion of the above copyright notice. This software may not |
|
447 |
be provided or otherwise made available to, or used by, any |
|
448 |
other person. No title to or ownership of the software is |
|
449 |
hereby transferred. |
|
450 |
" |
|
451 |
! |
|
360 | 452 |
|
613 | 453 |
documentation |
454 |
" |
|
455 |
Instances of DirectoryStream allow reading a file-directory, |
|
456 |
as if it was a stream of filenames. |
|
457 |
Basically, its an interface to opendir, readdir and closedir. |
|
8881
53e94478133f
STORE macro fix (gcc3.4 bug)
Claus Gittinger <cg@exept.de>
parents:
8775
diff
changeset
|
458 |
Notice: |
53e94478133f
STORE macro fix (gcc3.4 bug)
Claus Gittinger <cg@exept.de>
parents:
8775
diff
changeset
|
459 |
DirectoryStream is an ST/X special; |
2957 | 460 |
for portability, we recommend the use of Filename protocol. |
1295 | 461 |
|
462 |
[author:] |
|
1631 | 463 |
Claus Gittinger |
2957 | 464 |
|
465 |
[see also:] |
|
466 |
Filename |
|
613 | 467 |
" |
1 | 468 |
! ! |
469 |
||
470 |
!DirectoryStream class methodsFor:'instance creation'! |
|
471 |
||
472 |
directoryNamed:dirName |
|
7826 | 473 |
"return a DirectoryStream for directory named dirName, aString |
474 |
Raises an openError, if the directory does not exists." |
|
1 | 475 |
|
476 |
|newStream| |
|
477 |
||
8775 | 478 |
newStream := (self basicNew) text; pathName:dirName. |
1 | 479 |
newStream openForReading isNil ifTrue:[^nil]. |
480 |
^ newStream |
|
7826 | 481 |
|
482 |
" |
|
8881
53e94478133f
STORE macro fix (gcc3.4 bug)
Claus Gittinger <cg@exept.de>
parents:
8775
diff
changeset
|
483 |
self directoryNamed:'adadasd' |
53e94478133f
STORE macro fix (gcc3.4 bug)
Claus Gittinger <cg@exept.de>
parents:
8775
diff
changeset
|
484 |
self directoryNamed:'.' |
7826 | 485 |
" |
1 | 486 |
! ! |
487 |
||
5245 | 488 |
!DirectoryStream methodsFor:'access-reading'! |
1 | 489 |
|
17763 | 490 |
contents |
491 |
"answer all of the directory entries as an OrderedCollection" |
|
492 |
||
493 |
|contents| |
|
494 |
||
495 |
contents := OrderedCollection new. |
|
496 |
[self atEnd] whileFalse:[ |
|
497 |
|l| |
|
498 |
l := self nextLine. |
|
499 |
l isNil ifTrue:[ |
|
500 |
^ contents |
|
501 |
]. |
|
502 |
contents add:l |
|
503 |
]. |
|
504 |
^ contents |
|
505 |
! |
|
506 |
||
1 | 507 |
nextLine |
508 |
"return the next filename as a string" |
|
509 |
||
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
510 |
|prevEntry nextEntry isUnix| |
1 | 511 |
%{ |
77 | 512 |
#ifdef HAS_OPENDIR |
1 | 513 |
DIR *d; |
7955
f3a24f9588ee
64bit readdir bug workaround
Claus Gittinger <cg@exept.de>
parents:
7826
diff
changeset
|
514 |
DIRENT_STRUCT *dp; |
92 | 515 |
OBJ dirP; |
1 | 516 |
|
1281
b4b3abffdf32
Support optional signal generation on end of stream.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
517 |
if (__INST(hitEOF) != true && (dirP = __INST(dirPointer)) != nil) { |
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
518 |
__INST(lastErrorNumber) = nil; |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
519 |
d = (DIR *)__FILEVal(dirP); |
92 | 520 |
|
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
521 |
__BEGIN_INTERRUPTABLE__ |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
522 |
do { |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
523 |
do { |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
524 |
__threadErrno = 0; |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
525 |
dp = readdir(d); |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
526 |
/* |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
527 |
* for compatibility with ST-80, |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
528 |
* skip entries for '.' and '..'. |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
529 |
* If wanted, these must be added synthetically. |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
530 |
*/ |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
531 |
} while (dp && ((strcmp(dp->d_name, ".")==0) || (strcmp(dp->d_name, "..")==0))); |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
532 |
} while ((dp == NULL) && (__threadErrno == EINTR)); |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
533 |
__END_INTERRUPTABLE__ |
92 | 534 |
|
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
535 |
if (dp != NULL) { |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
536 |
nextEntry = __MKSTRING((char *)(dp->d_name)); |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
537 |
} else { |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
538 |
if (__threadErrno) { |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
539 |
__INST(lastErrorNumber) = __mkSmallInteger(__threadErrno); |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
540 |
} else { |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
541 |
__INST(hitEOF) = true; |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
542 |
} |
1281
b4b3abffdf32
Support optional signal generation on end of stream.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
543 |
} |
1 | 544 |
} |
1631 | 545 |
#else /* no HAS_OPENDIR */ |
546 |
# ifdef WIN32 |
|
547 |
HANDLE d; |
|
11288 | 548 |
WIN32_FIND_DATAW data; |
1631 | 549 |
OBJ dirP; |
3816
af3f917c7759
use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
Claus Gittinger <cg@exept.de>
parents:
3164
diff
changeset
|
550 |
int rslt; |
1631 | 551 |
|
552 |
if (__INST(hitEOF) != true && (dirP = __INST(dirPointer)) != nil) { |
|
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
553 |
__INST(lastErrorNumber) = nil; |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
554 |
d = __HANDLEVal(dirP); |
1631 | 555 |
|
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
556 |
do { |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
557 |
__threadErrno = 0; |
17751 | 558 |
rslt = STX_API_NOINT_CALL2( "FindNextFileW", FindNextFileW, d, &data ); |
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
559 |
} while ((rslt < 0) && (__threadErrno == EINTR)); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
5245
diff
changeset
|
560 |
|
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
561 |
if (rslt > 0) { |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
562 |
nextEntry = __MKU16STRING( data.cFileName ); |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
563 |
} else { |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
564 |
__INST(hitEOF) = true; |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
565 |
} |
1631 | 566 |
} |
567 |
# endif /* WIN32 */ |
|
568 |
#endif /* HAS_OPENDIR */ |
|
17734
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
569 |
|
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
570 |
#ifdef unix |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
571 |
isUnix = true; |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
572 |
#endif |
406b1590afe8
Merged with trunk r10476
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
573 |
|
155 | 574 |
%}. |
575 |
lastErrorNumber notNil ifTrue:[^ self ioError]. |
|
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
576 |
nextEntry notNil ifTrue:[ |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
577 |
isUnix == true ifTrue:[ |
11327
37b813ab86e9
changed #nextLine - handle utf8 decoding errors
Stefan Vogel <sv@exept.de>
parents:
11317
diff
changeset
|
578 |
"linux strings are in UTF8 (in contemporary linux versions)" |
37b813ab86e9
changed #nextLine - handle utf8 decoding errors
Stefan Vogel <sv@exept.de>
parents:
11317
diff
changeset
|
579 |
[ |
37b813ab86e9
changed #nextLine - handle utf8 decoding errors
Stefan Vogel <sv@exept.de>
parents:
11317
diff
changeset
|
580 |
nextEntry := nextEntry utf8Decoded. |
37b813ab86e9
changed #nextLine - handle utf8 decoding errors
Stefan Vogel <sv@exept.de>
parents:
11317
diff
changeset
|
581 |
] on:InvalidEncodingError do:[:ex| |
17747 | 582 |
"maybe there are old filenames in ISO8859-x, |
11327
37b813ab86e9
changed #nextLine - handle utf8 decoding errors
Stefan Vogel <sv@exept.de>
parents:
11317
diff
changeset
|
583 |
just keep them untranslated" |
37b813ab86e9
changed #nextLine - handle utf8 decoding errors
Stefan Vogel <sv@exept.de>
parents:
11317
diff
changeset
|
584 |
]. |
11317
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
585 |
] ifFalse:[ |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
586 |
nextEntry := nextEntry asSingleByteStringIfPossible. |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
587 |
] |
c634e925111f
Care for UTF8 filenams in linux/unix
Stefan Vogel <sv@exept.de>
parents:
11302
diff
changeset
|
588 |
]. |
1664 | 589 |
prevEntry := readAheadEntry. |
590 |
readAheadEntry := nextEntry. |
|
8614 | 591 |
prevEntry isNil ifTrue:[^ self pastEndRead]. |
1 | 592 |
^ prevEntry |
593 |
! ! |
|
594 |
||
613 | 595 |
!DirectoryStream methodsFor:'closing'! |
596 |
||
597 |
close |
|
598 |
"close the stream - tell operating system" |
|
599 |
||
600 |
dirPointer notNil ifTrue:[ |
|
601 |
Lobby unregister:self. |
|
602 |
self closeFile. |
|
603 |
dirPointer := nil |
|
604 |
] |
|
605 |
! ! |
|
606 |
||
8519 | 607 |
!DirectoryStream protectedMethodsFor:'instance release'! |
613 | 608 |
|
609 |
closeFile |
|
610 |
"low level close of a directoryStream" |
|
611 |
%{ |
|
612 |
#ifdef HAS_OPENDIR |
|
613 |
OBJ dp; |
|
614 |
||
1133 | 615 |
if ((dp = __INST(dirPointer)) != nil) { |
616 |
__INST(dirPointer) = nil; |
|
613 | 617 |
closedir( (DIR *)(__FILEVal(dp)) ); |
618 |
} |
|
1631 | 619 |
#else |
620 |
# ifdef WIN32 |
|
621 |
OBJ dp; |
|
622 |
||
623 |
if ((dp = __INST(dirPointer)) != nil) { |
|
624 |
__INST(dirPointer) = nil; |
|
625 |
FindClose( __HANDLEVal(dp) ); |
|
626 |
} |
|
627 |
# endif |
|
613 | 628 |
#endif |
629 |
%} |
|
630 |
! ! |
|
631 |
||
1 | 632 |
!DirectoryStream methodsFor:'private'! |
633 |
||
634 |
openForReading |
|
635 |
"open the file for readonly" |
|
636 |
||
1631 | 637 |
|ok entry| |
1 | 638 |
|
639 |
mode := #readonly. |
|
640 |
%{ |
|
77 | 641 |
#ifdef HAS_OPENDIR |
1 | 642 |
DIR *d; |
477
8710aba7876b
oops - making id's real objects requires a store macro
Claus Gittinger <cg@exept.de>
parents:
475
diff
changeset
|
643 |
OBJ path, dp; |
1 | 644 |
|
155 | 645 |
ok = false; |
1133 | 646 |
if (__INST(dirPointer) == nil) { |
17735 | 647 |
path = __INST(pathName); |
648 |
if (__isStringLike(path)) { |
|
649 |
__BEGIN_INTERRUPTABLE__ |
|
650 |
__threadErrno = 0; |
|
651 |
do { |
|
652 |
path = __INST(pathName); |
|
653 |
d = opendir((char *) __stringVal(path)); |
|
654 |
} while ((d == NULL) && (__threadErrno == EINTR)); |
|
655 |
__END_INTERRUPTABLE__ |
|
92 | 656 |
|
17735 | 657 |
if (d == NULL) { |
658 |
__INST(lastErrorNumber) = __mkSmallInteger(__threadErrno); |
|
659 |
} else { |
|
660 |
dp = __MKEXTERNALADDRESS(d); __INST(dirPointer) = dp; __STORE(self, dp); |
|
661 |
ok = true; |
|
662 |
} |
|
663 |
} |
|
1 | 664 |
} |
1631 | 665 |
#else |
666 |
# ifdef WIN32 |
|
11302 | 667 |
# ifndef MAXPATHLEN |
11294 | 668 |
# define MAXPATHLEN 1024 |
669 |
# endif |
|
1631 | 670 |
HANDLE d; |
671 |
OBJ path, dp; |
|
11294 | 672 |
union { |
17735 | 673 |
char pattern[MAXPATHLEN]; |
674 |
wchar_t wpattern[MAXPATHLEN]; |
|
11294 | 675 |
} uP; |
676 |
union { |
|
17735 | 677 |
WIN32_FIND_DATAA data; |
678 |
WIN32_FIND_DATAW wdata; |
|
11294 | 679 |
} uD; |
1631 | 680 |
|
681 |
ok = false; |
|
682 |
if (__INST(dirPointer) == nil) { |
|
17735 | 683 |
path = __INST(pathName); |
684 |
if (__isStringLike(path)) { |
|
685 |
int l = __stringSize(path); |
|
3164
4f37ae9c8961
use strncpy to avoid buffer-overruns
Claus Gittinger <cg@exept.de>
parents:
2999
diff
changeset
|
686 |
|
17735 | 687 |
if (l < (MAXPATHLEN-4)) { |
688 |
strncpy(uP.pattern, __stringVal(path), l); |
|
689 |
strcpy(uP.pattern+l, "\\*"); |
|
11294 | 690 |
|
17735 | 691 |
do { |
692 |
__threadErrno = 0; |
|
17751 | 693 |
d = STX_API_NOINT_CALL2( "FindFirstFileA", FindFirstFileA, uP.pattern, &uD.data ); |
17735 | 694 |
} while ((d < 0) && (__threadErrno == EINTR)); |
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
5245
diff
changeset
|
695 |
|
17735 | 696 |
if (d == INVALID_HANDLE_VALUE) { |
697 |
__INST(lastErrorNumber) = __mkSmallInteger(GetLastError()); |
|
698 |
} else { |
|
699 |
dp = __MKEXTERNALADDRESS(d); __INST(dirPointer) = dp; __STORE(self, dp); |
|
700 |
entry = __MKSTRING( uD.data.cFileName ); |
|
701 |
ok = true; |
|
702 |
} |
|
703 |
} |
|
704 |
} |
|
705 |
else if (__isUnicode16String(path)) { |
|
706 |
int l = __unicode16StringSize(path); |
|
707 |
int i; |
|
6259
164d7efc1eb2
api call stuff (more calls wrapped; care for EINTR)
Claus Gittinger <cg@exept.de>
parents:
5245
diff
changeset
|
708 |
|
17735 | 709 |
if (l < (MAXPATHLEN-4)) { |
710 |
for (i=0; i<l; i++) { |
|
711 |
uP.wpattern[i] = __unicode16StringVal(path)[i]; |
|
712 |
} |
|
713 |
uP.wpattern[i++] = '\\'; |
|
714 |
uP.wpattern[i++] = '*'; |
|
715 |
uP.wpattern[i] = 0; |
|
11294 | 716 |
|
17735 | 717 |
do { |
718 |
__threadErrno = 0; |
|
17751 | 719 |
d = STX_API_NOINT_CALL2( "FindFirstFileW", FindFirstFileW, uP.wpattern, &uD.wdata ); |
17735 | 720 |
} while ((d < 0) && (__threadErrno == EINTR)); |
11294 | 721 |
|
17735 | 722 |
if (d == INVALID_HANDLE_VALUE) { |
723 |
__INST(lastErrorNumber) = __mkSmallInteger(GetLastError()); |
|
724 |
} else { |
|
725 |
dp = __MKEXTERNALADDRESS(d); __INST(dirPointer) = dp; __STORE(self, dp); |
|
726 |
entry = __MKU16STRING( uD.wdata.cFileName ); |
|
727 |
ok = true; |
|
728 |
} |
|
729 |
} |
|
730 |
} |
|
1631 | 731 |
} |
732 |
# endif |
|
1 | 733 |
#endif |
155 | 734 |
%}. |
735 |
ok isNil ifTrue:[ |
|
17735 | 736 |
" |
737 |
opendir not avalable - use slower pipe |
|
738 |
" |
|
739 |
^ PipeStream readingFrom:('cd ' , pathName , '; ls -a') |
|
1 | 740 |
]. |
155 | 741 |
|
742 |
(ok == true) ifTrue:[ |
|
17735 | 743 |
Lobby register:self. |
744 |
entry isNil ifTrue:[ |
|
745 |
self nextLine. "read 1st entry into readAheadEntry buffer" |
|
746 |
] ifFalse:[ |
|
747 |
readAheadEntry := entry. |
|
748 |
]. |
|
749 |
^ self |
|
1 | 750 |
]. |
4526
a42dc8e09586
errorOpen renamed to errorAlreadyOpen
Claus Gittinger <cg@exept.de>
parents:
4298
diff
changeset
|
751 |
dirPointer notNil ifTrue:[^ self errorAlreadyOpen]. |
155 | 752 |
lastErrorNumber notNil ifTrue:[^ self openError]. |
1 | 753 |
^ nil |
754 |
! |
|
755 |
||
756 |
reOpen |
|
8604 | 757 |
"USERS WILL NEVER INVOKE THIS METHOD |
758 |
sent after snapin to reopen streams." |
|
38 | 759 |
|
2 | 760 |
dirPointer := nil. |
761 |
super reOpen |
|
1 | 762 |
! ! |
763 |
||
764 |
!DirectoryStream methodsFor:'testing'! |
|
765 |
||
766 |
atEnd |
|
767 |
"return true, if position is at end" |
|
768 |
||
1664 | 769 |
^ readAheadEntry == nil |
2945
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
770 |
! |
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
771 |
|
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
772 |
isEmpty |
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
773 |
"test for if the unread portion of the directory stream is empty. |
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
774 |
This query changes the readPointer of the DirectoryStream" |
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
775 |
|
2957 | 776 |
|entry| |
2945
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
777 |
|
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
778 |
[self atEnd] whileFalse:[ |
3816
af3f917c7759
use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
Claus Gittinger <cg@exept.de>
parents:
3164
diff
changeset
|
779 |
entry := self nextLine. |
af3f917c7759
use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
Claus Gittinger <cg@exept.de>
parents:
3164
diff
changeset
|
780 |
entry asFilename isImplicit ifFalse:[ |
af3f917c7759
use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
Claus Gittinger <cg@exept.de>
parents:
3164
diff
changeset
|
781 |
^ false. |
af3f917c7759
use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
Claus Gittinger <cg@exept.de>
parents:
3164
diff
changeset
|
782 |
] |
2945
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
783 |
]. |
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
784 |
^ true |
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
785 |
|
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
786 |
|
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
787 |
" |
3816
af3f917c7759
use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
Claus Gittinger <cg@exept.de>
parents:
3164
diff
changeset
|
788 |
(DirectoryStream directoryNamed:'/') isEmpty |
af3f917c7759
use wrapCalls for FindFirstFile & FindNextFile (win32 - dir-reading)
Claus Gittinger <cg@exept.de>
parents:
3164
diff
changeset
|
789 |
(DirectoryStream directoryNamed:'/var/tmp') isEmpty |
2945
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
790 |
" |
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
791 |
|
1a4f2e0d9f1b
Add #isEmpty, to check for an empty directory.
Stefan Vogel <sv@exept.de>
parents:
2896
diff
changeset
|
792 |
"Modified: 18.9.1997 / 18:05:31 / stefan" |
1 | 793 |
! ! |
794 |
||
1281
b4b3abffdf32
Support optional signal generation on end of stream.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
795 |
!DirectoryStream class methodsFor:'documentation'! |
b4b3abffdf32
Support optional signal generation on end of stream.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
796 |
|
b4b3abffdf32
Support optional signal generation on end of stream.
Stefan Vogel <sv@exept.de>
parents:
1133
diff
changeset
|
797 |
version |
17869 | 798 |
^ '$Id: DirectoryStream.st 10700 2011-09-29 15:44:37Z vranyj1 $' |
17735 | 799 |
! |
800 |
||
801 |
version_CVS |
|
17845 | 802 |
^ '§Header: /cvs/stx/stx/libbasic/DirectoryStream.st,v 1.74 2010/04/30 16:48:14 stefan Exp §' |
17865 | 803 |
! |
804 |
||
805 |
version_SVN |
|
17869 | 806 |
^ '$Id: DirectoryStream.st 10700 2011-09-29 15:44:37Z vranyj1 $' |
17846 | 807 |
! ! |