idevicecrashreport: Allow removing crash logs without copying.

Can also be used with `-f` to only remove matching files.
diff --git a/tools/idevicecrashreport.c b/tools/idevicecrashreport.c
index 09bd537..e900fe8 100644
--- a/tools/idevicecrashreport.c
+++ b/tools/idevicecrashreport.c
@@ -54,6 +54,7 @@
 const char* target_directory = NULL;
 static int extract_raw_crash_reports = 0;
 static int keep_crash_reports = 0;
+static int remove_all = 0;
 
 static int file_exists(const char* path)
 {
@@ -202,7 +203,7 @@
 				stbuf.st_nlink = atoi(fileinfo[i+1]);
 			} else if (!strcmp(fileinfo[i], "st_mtime")) {
 				stbuf.st_mtime = (time_t)(atoll(fileinfo[i+1]) / 1000000000);
-			} else if (!strcmp(fileinfo[i], "LinkTarget")) {
+			} else if (!strcmp(fileinfo[i], "LinkTarget") && !remove_all) {
 				/* report latest crash report filename */
 				printf("Link: %s\n", (char*)target_filename + strlen(target_directory));
 
@@ -238,21 +239,29 @@
 
 		/* recurse into child directories */
 		if (S_ISDIR(stbuf.st_mode)) {
+			if (!remove_all) {
 #ifdef WIN32
-			mkdir(target_filename);
+				mkdir(target_filename);
 #else
-			mkdir(target_filename, 0755);
+				mkdir(target_filename, 0755);
 #endif
+			}
 			res = afc_client_copy_and_remove_crash_reports(afc, source_filename, target_filename, filename_filter);
 
 			/* remove directory from device */
-			if (!keep_crash_reports)
+			if (!remove_all && !keep_crash_reports)
 				afc_remove_path(afc, source_filename);
 		} else if (S_ISREG(stbuf.st_mode)) {
 			if (filename_filter != NULL && strstr(source_filename, filename_filter) == NULL) {
 				continue;
 			}
 
+			if (remove_all) {
+				printf("Remove: %s\n", source_filename);
+				afc_remove_path(afc, source_filename);
+				continue;
+			}
+
 			/* copy file to host */
 			afc_error = afc_file_open(afc, source_filename, AFC_FOPEN_RDONLY, &handle);
 			if(afc_error != AFC_E_SUCCESS) {
@@ -331,6 +340,7 @@
 		"  -f, --filter NAME     filter crash reports by NAME (case sensitive)\n"
 		"  -h, --help            prints usage information\n"
 		"  -v, --version         prints version information\n"
+		"  --remove-all          remove all crash logs found\n"
 		"\n"
 		"Homepage:    <" PACKAGE_URL ">\n"
 		"Bug Reports: <" PACKAGE_BUGREPORT ">\n"
@@ -361,6 +371,7 @@
 		{ "filter", required_argument, NULL, 'f' },
 		{ "extract", no_argument, NULL, 'e' },
 		{ "keep", no_argument, NULL, 'k' },
+		{ "remove-all", no_argument, NULL, 1 },
 		{ NULL, 0, NULL, 0}
 	};
 
@@ -405,6 +416,9 @@
 		case 'k':
 			keep_crash_reports = 1;
 			break;
+		case 1:
+			remove_all = 1;
+			break;
 		default:
 			print_usage(argc, argv, 1);
 			return 2;
@@ -414,12 +428,16 @@
 	argv += optind;
 
 	/* ensure a target directory was supplied */
-	if (!argv[0]) {
-		fprintf(stderr, "ERROR: missing target directory.\n");
-		print_usage(argc+optind, argv-optind, 1);
-		return 2;
+	if (!remove_all) {
+		if (!argv[0]) {
+			fprintf(stderr, "ERROR: missing target directory.\n");
+			print_usage(argc+optind, argv-optind, 1);
+			return 2;
+		}
+		target_directory = argv[0];
+	} else {
+		target_directory = ".";
 	}
-	target_directory = argv[0];
 
 	/* check if target directory exists */
 	if (!file_exists(target_directory)) {