aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2021-06-03 16:18:10 +0200
committerlonkaars <loek@pipeframe.xyz>2021-06-03 16:18:10 +0200
commitc4e0b767338a63e797cdceb771358eb5aab8fc4f (patch)
treed4e97b13e9978dbd3a088e307a7d06db856434e3
parentf1fb88e48a6407ee5451ce0f05f8d201c132a715 (diff)
filter working
-rw-r--r--musicopy.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/musicopy.c b/musicopy.c
index 589aa80..3a85331 100644
--- a/musicopy.c
+++ b/musicopy.c
@@ -100,23 +100,23 @@ void fix_include_exclude(char*** listv, int listc) {
}
void copy(const char* path) {
- printf("copying %s... to %s\n", path, target_music_dir);
+ printf("copying %s to %s...\n", path, target_music_dir);
}
int dir_callback(const char* path, const struct stat *sb, int tflag) {
if (include_length > 0) {
- bool allowed = false;
+ bool includes = false;
for(int i = 0; i < include_length; i++) {
- if(allowed) {
- copy(path);
- return 0;
- } else {
- allowed = fnmatch(exclude[i], path, 0) == 0;
- }
+ includes = fnmatch(include[i], path, 0) == 0;
+ if(includes) break;
}
- return 0;
+ if (!includes) return 0;
}
+ if (exclude_length > 0)
+ for(int i = 0; i < exclude_length; i++)
+ if(fnmatch(exclude[i], path, 0) == 0) return 0;
+
copy(path);
return 0;
@@ -155,7 +155,7 @@ int main() {
print_opts();
- ftw(music_dir, dir_callback, 0);
+ ftw(music_dir, dir_callback, FTW_F);
return 0;
}