forked from lclevy/ADFlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_dir.html
274 lines (163 loc) · 5.22 KB
/
api_dir.html
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<HTML>
<HEAD><TITLE> Directory </TITLE></HEAD>
<BODY>
<H1 ALIGN=CENTER>the Directory API</H1>
<HR>
<H1>Data structures</H1>
<PRE>
/* entry types */
#define ST_DIR 2
#define ST_FILE -3
struct Entry{
int type; /* type of the entry */
char *name; /* name */
SECTNUM sector; /* sector pointer */
char *comment; /* optional comment */
unsigned long size; /* file size, 0 for a directory */
long access; /* RWEDAPSH access rights */
int year, month, day; /* date */
int hour, min, sec; /* hour */
}
/* general purpose list used to stored directory entries */
struct List{
void *content; /* Filled with struct Entry* type */
struct List *subdir; /* If the cell content is a dir, its entries list */
/* is stored here, else filled with NULL */
struct List *next; /* Next cell */
}
</PRE>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> adfGetDirEnt() </FONT></P>
<H2>Syntax</H2>
<B>struct List*</B> adfGetDirEnt(<B>struct Volume*</B> vol, <B>SECTNUM</B> dir )<BR>
equivalent to <BR>
<B>struct List*</B> adfGetRDirEnt(<B>struct Volume*</B> vol, <B>SECTNUM</B> dir, FALSE )<BR>
<H2>Description</H2>
Returns a linked list which contains the entries of one directory.
<H2>Return values</H2>
The list, NULL in case of error.
<H2>Examples</H2>
<PRE>
struct List *list, *cell;
struct Entry *entry;
/* saves the head of the list */
cell = list = adfGetDirEnt(vol,vol->curDirPtr);
/* while cell->next is NULL, the last cell */
while(cell) {
entry = (struct Entry*)cell->content;
printf("%s %ld\n", entry->name, entry->sector);
cell = cell->next;
}
/* frees the list and the content */
adfFreeDirList(list);
</PRE>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> adfGetRDirEnt() </FONT></P>
<H2>Syntax</H2>
<B>struct List*</B> adfGetRDirEnt(<B>struct Volume*</B> vol, <B>SECTNUM</B> dir, <B>BOOL</B> recursive )<BR>
<H2>Description</H2>
Returns a linked list which contains the entries of one directory.
<H2>Return values</H2>
The list, NULL in case of error.
<H2>Examples</H2>
<PRE>
#define TRUE 1
int main()
{
struct List *list, *cell;
struct Entry *entry;
...
/* saves the head of the list */
cell = list = adfGetRDirEnt(vol,vol->curDirPtr,TRUE);
/* prints the tree */
printTree(cell);
/* frees the list and the content */
adfFreeDirList(list);
...
}
/* print the directories tree. recursive */
printTree(struct List* tree)
{
while(tree) {
entry = (struct Entry*)cell->content;
printf("%s %ld\n", entry->name, entry->sector);
if (tree->subdir!=NULL)
printTree(tree->subdir)
tree = tree->next;
}
}
</PRE>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> adfChangeDir() </FONT></P>
<H2>Syntax</H2>
<B>RETCODE</B> adfChangeDir(<B>struct Volume*</B> vol, <B>char *</B>dirName)
<H2>Description</H2>
Change the current working directory to the new one (dirName).
<H2>Return values</H2>
RC_OK, something different in case of error.
<P>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> adfParentDir() </FONT></P>
<H2>Syntax</H2>
<B>RETCODE</B> adfParentDir(<B>struct Volume*</B> vol)
<H2>Description</H2>
Change the current working directory to its parent directory. If the current
directory is the root of the filesystem ('/'), nothing happens.
<H2>Return values</H2>
RC_OK, something different in case of error.
<P>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> adfCreateDir() </FONT></P>
<H2>Syntax</H2>
<B>RETCODE</B> adfCreateDir(<B>struct Volume*</B> vol,
<B>SECTNUM</B> parent, <B>char*</B> dirName)
<H2>Description</H2>
Creates a new directory (dirName) into the specified directory (parent).
<H2>Return values</H2>
RC_OK, something different in case of error.
<P>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> adfRemoveEntry() </FONT></P>
<H2>Syntax</H2>
<B>RETCODE</B> adfRemoveEntry(<B>struct Volume *</B>vol,
<B>SECTNUM</B> parent, <B>char *</B>name)
<H2>Description</H2>
Removes a entry (a file or an empty directory) from one directory (parent).
<H2>Return values</H2>
RC_OK, something different in case of error.
<P>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> adfFreeDirList() </FONT></P>
<H2>Syntax</H2>
<B>void</B> adfFreeDirList(<B>struct List*</B> list)
<H2>Description</H2>
Frees a linked list or a tree of directory entries.
<P>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> adfAccess2String() </FONT></P>
<H2>Syntax</H2>
<B>char*</B> adfAccess2String(<B>long</B> access)
<H2>Description</H2>
Converts the access rights from <I>long</I> to <I>char*</I>.
<H2>Return values</H2>
A C string which represents the access rights.
<P>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> adfRenameEntry() </FONT></P>
<H2>Syntax</H2>
<B>RETCODE</B> adfRenameEntry(<B>struct Volume*</B> vol, <B>SECTNUM</B> oldDir, <B>char*</B> old, <B>SECTNUM</B> newDir, <B>char*</B> new)
<H2>Description</H2>
Changes the name of the entry <I>old</I> located in the <I>oldDir</I> into
the name <I>new</I>, located into the <I>newDir</I> directory.
<P>
<HR>
<P ALIGN=CENTER><FONT SIZE=+2> printEntry() </FONT></P>
<H2>Syntax</H2>
<B>void</B> printEntry(<B>struct Entry*</B> entry)
<H2>Description</H2>
Do no use this function (not an adf one), but you can use its code to learn
how to display a directory entry (in adf_dir.c).
<P>
<HR>
</BODY>
</HTML>