diff --git a/src/exclude.c b/src/exclude.c index d7b679d81040af335cdfe6163b043866d15f822e..97975c04fd3d03aaafbd3dddbd30e8154be41e2b 100644 --- a/src/exclude.c +++ b/src/exclude.c @@ -104,21 +104,20 @@ void exclude_clear() { * Exclusion of directories that contain only cached information. * See http://www.brynosaurus.com/cachedir/ */ -static const char cachedir_tag_signature[] = - "Signature: 8a477f597d28d172789f06886806bc55"; +#define CACHEDIR_TAG_SIGNATURE "Signature: 8a477f597d28d172789f06886806bc55" int has_cachedir_tag(const char *name) { - char buf[1024]; - FILE *f; - int match = 0; - const int signature_l = strlen(cachedir_tag_signature); - - snprintf(buf, sizeof(buf), "%s/CACHEDIR.TAG", name); - f = fopen(buf, "rb"); - if (f != NULL) { - match = ((fread(buf, 1, signature_l, f) == signature_l) && - !strncmp(buf, cachedir_tag_signature, signature_l)); - fclose(f); - } - return match; + char buf[1024]; + FILE *f; + int match = 0; + const int signature_l = sizeof CACHEDIR_TAG_SIGNATURE - 1; + + snprintf(buf, sizeof(buf), "%s/CACHEDIR.TAG", name); + f = fopen(buf, "rb"); + if(f != NULL) { + match = ((fread(buf, 1, signature_l, f) == signature_l) && + !memcmp(buf, CACHEDIR_TAG_SIGNATURE, signature_l)); + fclose(f); + } + return match; } diff --git a/src/exclude.h b/src/exclude.h index d3516b6c2caaf4b52b9fb770d6d27b41466d1804..2064466d013627ab9d7d0738b11cdf0199646228 100644 --- a/src/exclude.h +++ b/src/exclude.h @@ -30,5 +30,6 @@ void exclude_add(char *); int exclude_addfile(char *); int exclude_match(char *); void exclude_clear(); +int has_cachedir_tag(const char *name); #endif diff --git a/src/main.c b/src/main.c index 54771b223fd212af9732b5b4a0dbb30be0cf8fb5..6084edcf0d1c39c4f082bd639bdd0c78673ad2e0 100644 --- a/src/main.c +++ b/src/main.c @@ -126,7 +126,7 @@ static void argv_parse(int argc, char **argv) { { '2', 0, "-2" }, { 1, 1, "--exclude" }, { 'X', 1, "-X,--exclude-from" }, - { 'C', 0, "-C,--cachedir-tag" }, + { 'C', 0, "--exclude-caches" }, {0,0,NULL} }; @@ -148,7 +148,7 @@ static void argv_parse(int argc, char **argv) { printf(" -0,-1,-2 UI to use when scanning (0=none,2=full ncurses)\n"); printf(" --exclude PATTERN Exclude files that match PATTERN\n"); printf(" -X, --exclude-from FILE Exclude files that match any pattern in FILE\n"); - printf(" -C, --cachedir-tag Exclude directories containing CACHEDIR.TAG\n"); + printf(" --exclude-caches Exclude directories containing CACHEDIR.TAG\n"); exit(0); case 'q': update_delay = 2000; break; case 'v':