1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/
#include <string.h>
#include "bootlib.h"
/*
* OS_DIR -- A package for accessing a directory as a list of files.
*/
#ifndef NOVOS
/* OS_DIROPEN -- Open the directory.
*/
int
os_diropen (char *dirname)
{
PKCHAR osfn[SZ_PATHNAME+1];
XINT chan;
extern int ZOPDIR();
strcpy ((char *)osfn, dirname);
ZOPDIR (osfn, &chan);
return (chan);
}
/* OS_DIRCLOSE -- Close the directory.
*/
int
os_dirclose (int chan)
{
XINT x_chan=chan, status;
extern int ZCLDIR();
ZCLDIR (&x_chan, &status);
return (status);
}
/* OS_GFDIR -- Get the next filename from the directory.
*/
int
os_gfdir (
int chan,
char *fname,
int maxch
)
{
PKCHAR osfn[SZ_PATHNAME+1];
XINT x_chan=chan, x_maxch=maxch, status;
extern int ZGFDIR();
for (;;) {
ZGFDIR (&x_chan, osfn, &x_maxch, &status);
if (status > 0) {
/* Omit the self referential directory files "." and ".."
* or recursion may result.
*/
if (strcmp ((char *)osfn, ".") == 0)
continue;
if (strcmp ((char *)osfn, "..") == 0)
continue;
strncpy (fname, osfn2vfn ((char *)osfn), maxch);
return (status);
} else {
/* End of directory.
*/
*fname = EOS;
return (0);
}
}
}
#else
/* NOVOS bootsrap. Just stub these out until we re-boostrap using the
* VOS libs, which provide zopdir.
*/
int os_dirclose (int chan) { return (-1); }
int os_diropen (char *dirname) { return (-1); }
int os_gfdir (int chan, char *fname, int maxch) { return (0); }
#endif
|