forked from pool/fdupes
ebd601a9d7
- update to 1.5.0-PR2 * new "--summarize" option * new "--recurse:" selective recursion option * new "--noprompt" option for totally automated deletion of duplicate files. * sorts duplicates (old to new) for consistent order when listing or deleteing duplicate files. * tests for early matching of files, which should help speed up the matching process when large files are involved. * warns whenever a file cannot be deleted. * bugfixes (proper file closing, zero-length files, ...) - add -p/--permissions switch so files with different permissions or uid/gid are not considered as duplicates (bnc#784670) * this mode is a default one for fdupes macro - refresh all patches - drop the fdupes-sort-output.diff - use the upstream mtime sorting - add the debian patches - see spec file for details OBS-URL: https://build.opensuse.org/request/show/138346 OBS-URL: https://build.opensuse.org/package/show/utilities/fdupes?expand=0&rev=6
109 lines
3.1 KiB
Diff
109 lines
3.1 KiB
Diff
From 1e15ced9c10a04b6f4ae816ced687fd982760dbc Mon Sep 17 00:00:00 2001
|
|
From: maxy <maxy@debian.org>
|
|
Date: Fri, 12 Oct 2012 15:02:49 +0200
|
|
Subject: [PATCH 06/10] add --nohidden support (bts511702)
|
|
|
|
---
|
|
fdupes.1 | 3 +++
|
|
fdupes.c | 21 ++++++++++++++++++++-
|
|
2 files changed, 23 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/fdupes.1 b/fdupes.1
|
|
index f12945b..5f7c526 100644
|
|
--- a/fdupes.1
|
|
+++ b/fdupes.1
|
|
@@ -38,6 +38,9 @@ exclude zero-length files from consideration
|
|
.B -f --omitfirst
|
|
omit the first file in each set of matches
|
|
.TP
|
|
+.B -A --nohidden
|
|
+exclude hidden files from consideration
|
|
+.TP
|
|
.B -1 --sameline
|
|
list each set of matches on a single line
|
|
.TP
|
|
diff --git a/fdupes.c b/fdupes.c
|
|
index 4ecf51b..fe540e6 100644
|
|
--- a/fdupes.c
|
|
+++ b/fdupes.c
|
|
@@ -31,6 +31,7 @@
|
|
#endif
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
+#include <libgen.h>
|
|
|
|
#ifndef EXTERNAL_MD5
|
|
#include "md5/md5.h"
|
|
@@ -51,6 +52,7 @@
|
|
#define F_RECURSEAFTER 0x0200
|
|
#define F_NOPROMPT 0x0400
|
|
#define F_SUMMARIZEMATCHES 0x0800
|
|
+#define F_EXCLUDEHIDDEN 0x1000
|
|
|
|
char *program_name;
|
|
|
|
@@ -240,6 +242,7 @@ int grokdir(char *dir, file_t **filelistp)
|
|
struct stat linfo;
|
|
static int progress = 0;
|
|
static char indicator[] = "-\\|/";
|
|
+ char *fullname, *name;
|
|
|
|
cd = opendir(dir);
|
|
|
|
@@ -285,6 +288,17 @@ int grokdir(char *dir, file_t **filelistp)
|
|
strcat(newfile->d_name, "/");
|
|
strcat(newfile->d_name, dirinfo->d_name);
|
|
|
|
+ if (ISFLAG(flags, F_EXCLUDEHIDDEN)) {
|
|
+ fullname = strdup(newfile->d_name);
|
|
+ name = basename(fullname);
|
|
+ if (name[0] == '.' && strcmp(name, ".") && strcmp(name, "..") ) {
|
|
+ free(newfile->d_name);
|
|
+ free(newfile);
|
|
+ continue;
|
|
+ }
|
|
+ free(fullname);
|
|
+ }
|
|
+
|
|
if (filesize(newfile->d_name) == 0 && ISFLAG(flags, F_EXCLUDEEMPTY)) {
|
|
free(newfile->d_name);
|
|
free(newfile);
|
|
@@ -945,6 +959,7 @@ void help_text()
|
|
printf(" \tdisk area they are treated as non-duplicates; this\n");
|
|
printf(" \toption will change this behavior\n");
|
|
printf(" -n --noempty \texclude zero-length files from consideration\n");
|
|
+ printf(" -A --nohidden \texclude hidden files from consideration\n");
|
|
printf(" -f --omitfirst \tomit the first file in each set of matches\n");
|
|
printf(" -1 --sameline \tlist each set of matches on a single line\n");
|
|
printf(" -S --size \tshow size of duplicate files\n");
|
|
@@ -996,6 +1011,7 @@ int main(int argc, char **argv) {
|
|
{ "hardlinks", 0, 0, 'H' },
|
|
{ "relink", 0, 0, 'l' },
|
|
{ "noempty", 0, 0, 'n' },
|
|
+ { "nohidden", 0, 0, 'A' },
|
|
{ "delete", 0, 0, 'd' },
|
|
{ "version", 0, 0, 'v' },
|
|
{ "help", 0, 0, 'h' },
|
|
@@ -1013,7 +1029,7 @@ int main(int argc, char **argv) {
|
|
|
|
oldargv = cloneargs(argc, argv);
|
|
|
|
- while ((opt = GETOPT(argc, argv, "frRq1Ss::HlndvhNm"
|
|
+ while ((opt = GETOPT(argc, argv, "frRq1Ss::HlnAdvhNm"
|
|
#ifndef OMIT_GETOPT_LONG
|
|
, long_options, NULL
|
|
#endif
|
|
@@ -1046,6 +1062,9 @@ int main(int argc, char **argv) {
|
|
case 'n':
|
|
SETFLAG(flags, F_EXCLUDEEMPTY);
|
|
break;
|
|
+ case 'A':
|
|
+ SETFLAG(flags, F_EXCLUDEHIDDEN);
|
|
+ break;
|
|
case 'd':
|
|
SETFLAG(flags, F_DELETEFILES);
|
|
break;
|
|
--
|
|
1.7.11.5
|
|
|