this option re-includes files which would otherwise be excluded. If the option
is used without \-\-exclude, only files matched by the pattern are included.
.TP
-.B \-s or \-\-minimum\-size
+.B \-s or \-\-minimum\-size \fIsize\fP
The minimum size to consider. By default this is 1, so empty files will not
-be linked. An optional suffix of K,M,G,T may be provided, indicating that the
-file size is KiB,MiB,GiB,TiB.
-
+be linked. The \fIsize\fR argument may be followed by the multiplicative
+suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB
+and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB").
.SH ARGUMENTS
.B hardlink
takes one or more directories which will be searched for files to be linked.
#include "nls.h"
#include "c.h"
#include "xalloc.h"
+#include "strutils.h"
/* Use libpcre2posix if it's available */
#ifdef HAVE_PCRE2_POSIX
unsigned int minimise:1;
unsigned int keep_oldest:1;
unsigned int dry_run:1;
- unsigned long long min_size;
+ uintmax_t min_size;
} opts = {
/* default setting */
.respect_mode = TRUE,
stats.files++;
- if (sb->st_size < opts.min_size) {
+ if ((uintmax_t) sb->st_size < opts.min_size) {
jlog(JLOG_DEBUG1, "Skipped %s (smaller than configured size)", fpath);
return 0;
}
{"content", no_argument, NULL, 'c'},
{NULL, 0, NULL, 0}
};
+ int c;
- int opt;
- char unit = '\0';
-
-
- while ((opt = getopt_long(argc, argv, optstr, long_options, NULL)) != -1) {
- switch (opt) {
+ while ((c = getopt_long(argc, argv, optstr, long_options, NULL)) != -1) {
+ switch (c) {
case 'p':
opts.respect_mode = FALSE;
break;
return 1;
break;
case 's':
- if (sscanf(optarg, "%llu%c", &opts.min_size, &unit) < 1) {
- jlog(JLOG_ERROR, "Invalid option given to -s: %s", optarg);
- return 1;
- }
- switch (tolower(unit)) {
- case '\0':
- break;
- case 't':
- opts.min_size *= 1024;
- case 'g':
- opts.min_size *= 1024;
- case 'm':
- opts.min_size *= 1024;
- case 'k':
- opts.min_size *= 1024;
- break;
- default:
- jlog(JLOG_ERROR, "Unknown unit indicator %c.", unit);
- return 1;
- }
- jlog(JLOG_DEBUG1, "Using minimum size of %lld bytes.",
- opts.min_size);
+ opts.min_size = strtosize_or_err(optarg, _("failed to parse size"));
break;
case 'h':