-
Notifications
You must be signed in to change notification settings - Fork 1
/
afsrm.c
40 lines (39 loc) · 960 Bytes
/
afsrm.c
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
#include "acorn-fs.h"
#include <string.h>
#include <locale.h>
int main(int argc, char *argv[])
{
if (--argc) {
int status = 0;
setlocale(LC_ALL, "");
do {
acorn_fs *fs;
char *fsname = *++argv;
char *sep = strchr(fsname, ':');
if (sep) {
*sep++ = 0;
if ((fs = acorn_fs_open(fsname, true))) {
int astat = fs->remove(fs, NULL, sep);
if (astat != AFS_OK) {
fprintf(stderr, "afsrm: %s: %s\n", fsname, acorn_fs_strerr(astat));
status++;
}
acorn_fs_close_all();
}
else {
fprintf(stderr, "afsrm: %s: %s\n", fsname, acorn_fs_strerr(errno));
status++;
}
}
else {
fprintf(stderr, "afsrm: name '%s' invalid, ':' required\n", fsname);
status++;
}
} while (--argc);
return status;
}
else {
fputs("Usage: afsrm <img-file:pattern> [...]\n", stderr);
return 1;
}
}