3212a044b2d2e94433092490f884a7b5088643f1
2 * This file is part of DisOrder.
3 * Copyright (C) 2004 Richard Kettlewell
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 #include <sys/types.h>
35 void disorder_scan(const char *path
) {
41 if(stat(path
, &sb
) < 0) {
42 disorder_error(errno
, "cannot lstat %s", path
);
45 /* skip files that aren't world-readable */
46 if(!(sb
.st_mode
& 0004))
48 if(S_ISDIR(sb
.st_mode
)) {
49 if(!(dp
= opendir(path
))) {
50 disorder_error(errno
, "cannot open directory %s", path
);
55 if(de
->d_name
[0] != '.') {
56 disorder_asprintf(&np
, "%s/%s", path
, de
->d_name
);
61 disorder_error(errno
, "error reading directory %s", path
);
63 } else if(S_ISREG(sb
.st_mode
))
64 if(printf("%s%c", path
, 0) < 0)
65 disorder_fatal(errno
, "error writing to scanner output pipe");
68 int disorder_check(const char attribute((unused
)) *root
, const char *path
) {
69 if(access(path
, R_OK
) == 0)
71 else if(errno
== ENOENT
)
74 disorder_error(errno
, "cannot access %s", path
);
85 /* arch-tag:070e62d92ebc26329f0a3961d615476f */