New -find test -size
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
|
||||
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
|
||||
|
||||
Copyright 2007-2021 Thomas Schmitt, <scdbackup@gmx.net>
|
||||
Copyright 2007-2022 Thomas Schmitt, <scdbackup@gmx.net>
|
||||
|
||||
Provided under GPL version 2 or later.
|
||||
|
||||
@ -836,11 +836,12 @@ int Xorriso_option_find(struct XorrisO *xorriso, int argc, char **argv,
|
||||
int *idx, int flag)
|
||||
{
|
||||
int ret, i, end_idx, type= 0, action, deleter= 0, start_lba, count;
|
||||
int list_extattr_head= 0, bsl_mem, disk_path, name_space;
|
||||
int list_extattr_head= 0, bsl_mem, disk_path, name_space, prefix_code;
|
||||
struct FindjoB *job, *first_job= NULL, *new_job;
|
||||
char *start_path, *path= NULL, *cpt, *other_path_start= NULL, *cd_pt;
|
||||
char *access_acl_text= NULL, *default_acl_text= NULL, *list_extattr_mode;
|
||||
char *arg1_pt, *namept;
|
||||
char *arg1_pt, *namept, *suffix_pt, *value_pt, size_text[40];
|
||||
off_t size_value, suffix_factor= 1;
|
||||
|
||||
struct stat dir_stbuf;
|
||||
uid_t user= 0;
|
||||
@ -1121,6 +1122,59 @@ not_enough_arguments:;
|
||||
count, 0, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
} else if(strcmp(argv[i], "-size") == 0) {
|
||||
if(i + 1 >= end_idx)
|
||||
goto not_enough_arguments;
|
||||
i++;
|
||||
if(strlen(argv[i]) >= sizeof(size_text) - 1) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-findi: Number text after -size is much too long");
|
||||
goto sorry_ex;
|
||||
}
|
||||
strcpy(size_text, argv[i]);
|
||||
value_pt= size_text;
|
||||
prefix_code= 0;
|
||||
if(*value_pt == 0)
|
||||
goto size_value_bad;
|
||||
if(*value_pt == '-') {
|
||||
prefix_code= -1;
|
||||
value_pt++;
|
||||
} else if(*value_pt == '+') {
|
||||
prefix_code= 1;
|
||||
value_pt++;
|
||||
}
|
||||
if(*value_pt == 0)
|
||||
goto size_value_bad;
|
||||
if(*value_pt == '=') {
|
||||
prefix_code*= 2;
|
||||
value_pt++;
|
||||
}
|
||||
if(*value_pt == 0) {
|
||||
size_value_bad:;
|
||||
sprintf(xorriso->info_text,
|
||||
"-findi: Number text after -size is not suitable");
|
||||
}
|
||||
/* Convert "find -size" suffix to Scanf_io_size suffix */
|
||||
suffix_pt= value_pt + strlen(value_pt) - 1;
|
||||
if(*suffix_pt == 'b' || *suffix_pt == 'B') {
|
||||
*suffix_pt= 'd'; /* 512 bytes */
|
||||
} else if(*suffix_pt == 'c' || *suffix_pt == 'C') {
|
||||
*suffix_pt= 0; /* 1 byte */
|
||||
} else if(*suffix_pt == 'w'|| *suffix_pt == 'W') {
|
||||
*suffix_pt= 0; /* 2 byte */
|
||||
suffix_factor= 2;
|
||||
} else if(*suffix_pt >= '0' && *suffix_pt <= '9') {
|
||||
suffix_pt++;
|
||||
*suffix_pt= 'd'; /* 512 bytes */
|
||||
*(suffix_pt + 1)= 0;
|
||||
}
|
||||
size_value= (off_t) Scanf_io_size(value_pt, 1) * (off_t) suffix_factor;
|
||||
if(size_value < 0)
|
||||
goto size_value_bad;
|
||||
ret= Findjob_set_size_filter(job, 27, size_value, prefix_code, 0);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
|
||||
} else if(strcmp(argv[i], "-exec")==0) {
|
||||
if(i+1>=end_idx) {
|
||||
not_enough_exec_arguments:;
|
||||
@ -2140,7 +2194,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" -lba_range start count, -damaged, -has_acl, -has_xattr,",
|
||||
" -has_aaip, -has_filter, -has_md5, -has_any_xattr,",
|
||||
" -has_hfs_crtp, -has_hfs_bless, -bad_outname,",
|
||||
" -name_limit_blocker, -maxdepth, -mindepth,",
|
||||
" -name_limit_blocker, -maxdepth, -mindepth, -size,",
|
||||
" -prune, -decision yes|no, -true, -false",
|
||||
" Operators: -not, -or, -and, -sub, (, -subend, ),",
|
||||
" -if, -then, -elseif, -else, -endif",
|
||||
|
Reference in New Issue
Block a user