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/>.
18 /** @file plugins/fs.c
19 * @brief Plugin to find tracks in a filesystem
25 #include <sys/types.h>
35 void disorder_scan(const char *path
) {
41 if(stat(path
, &sb
) < 0) {
42 disorder_error(errno
, "cannot stat %s", path
);
45 if(S_ISDIR(sb
.st_mode
)) {
46 if(!(dp
= opendir(path
))) {
47 disorder_error(errno
, "cannot open directory %s", path
);
52 if(de
->d_name
[0] != '.') {
53 disorder_asprintf(&np
, "%s/%s", path
, de
->d_name
);
58 disorder_error(errno
, "error reading directory %s", path
);
60 } else if(S_ISREG(sb
.st_mode
)) {
61 if(access(path
, R_OK
) < 0) {
62 disorder_error(errno
, "cannot access file %s", path
);
65 if(printf("%s%c", path
, 0) < 0)
66 disorder_fatal(errno
, "error writing to scanner output pipe");
70 int disorder_check(const char attribute((unused
)) *root
, const char *path
) {
71 if(access(path
, R_OK
) == 0)
73 else if(errno
== ENOENT
)
76 disorder_error(errno
, "cannot access %s", path
);