2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2007, 2008 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 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU 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, see <http://www.gnu.org/licenses/>.
23 #include <sys/types.h>
33 void disorder_scan(const char *path) {
39 if(stat(path, &sb) < 0) {
40 disorder_error(errno, "cannot stat %s", path);
43 if(S_ISDIR(sb.st_mode)) {
44 if(!(dp = opendir(path))) {
45 disorder_error(errno, "cannot open directory %s", path);
50 if(de->d_name[0] != '.') {
51 disorder_asprintf(&np, "%s/%s", path, de->d_name);
56 disorder_error(errno, "error reading directory %s", path);
58 } else if(S_ISREG(sb.st_mode)) {
59 if(access(path, R_OK) < 0) {
60 disorder_error(errno, "cannot access file %s", path);
63 if(printf("%s%c", path, 0) < 0)
64 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);