New action estimate_size for -find and -findx
This commit is contained in:
parent
f755fcd56d
commit
dd5cd516d7
@ -1087,6 +1087,7 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
time_t date= 0;
|
||||
mode_t mode_or= 0, mode_and= ~1;
|
||||
char *target, *text_2, sfe[5*SfileadrL], *disk_prefix, iso_path[SfileadrL];
|
||||
char *basename;
|
||||
struct FindjoB *subjob;
|
||||
struct stat stbuf;
|
||||
|
||||
@ -1167,6 +1168,16 @@ int Xorriso_findx_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
Xorriso_result(xorriso,0);
|
||||
}
|
||||
{ret= 1; goto ex;}
|
||||
} else if(action == 40) { /* estimate_size */
|
||||
basename= strrchr(abs_path, '/');
|
||||
if(basename != NULL)
|
||||
basename++;
|
||||
else
|
||||
basename= abs_path;
|
||||
ret= lstat(abs_path, &stbuf);
|
||||
if(ret != -1)
|
||||
ret= Xorriso_estimate_file_size(xorriso, job, basename, stbuf.st_mode,
|
||||
stbuf.st_size, 0);
|
||||
} else {
|
||||
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
|
||||
Xorriso_result(xorriso, 0);
|
||||
|
@ -377,6 +377,8 @@ int Findjob_new(struct FindjoB **o, char *start_path, int flag)
|
||||
if(m->start_path==NULL)
|
||||
goto failed;
|
||||
m->found_path= NULL;
|
||||
m->estim_upper_size= 0;
|
||||
m->estim_lower_size= 0;
|
||||
m->subjob= NULL;
|
||||
m->errmsg[0]= 0;
|
||||
m->errn= 0;
|
||||
|
@ -154,6 +154,7 @@ struct FindjoB {
|
||||
37= mkisofs_r
|
||||
38= sort_weight number
|
||||
39= hide on|iso_rr|joliet|off
|
||||
40= estimate_size
|
||||
*/
|
||||
int action;
|
||||
int prune;
|
||||
@ -167,6 +168,8 @@ struct FindjoB {
|
||||
int type; /* see Xorriso_set_time flag, also used as weight */
|
||||
time_t date;
|
||||
char *found_path;
|
||||
off_t estim_upper_size;
|
||||
off_t estim_lower_size;
|
||||
struct FindjoB *subjob;
|
||||
|
||||
/* Errors */
|
||||
|
@ -1688,6 +1688,29 @@ int Xorriso_set_hidden(struct XorrisO *xorriso, void *in_node, char *path,
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= increase only upper estimation
|
||||
*/
|
||||
int Xorriso_estimate_file_size(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
char *basename, mode_t st_mode, off_t st_size, int flag)
|
||||
{
|
||||
off_t upper, lower, size;
|
||||
|
||||
lower = 3 * strlen(basename) + 34; /* >>> + minimum RR ? */
|
||||
upper = 3 * strlen(basename) + 2048;
|
||||
if(S_ISREG(st_mode)) {
|
||||
size= ((st_size + (off_t) 2047) / (off_t) 2048) * (off_t) 2048;
|
||||
lower+= size;
|
||||
upper+= size;
|
||||
} else if(S_ISDIR(st_mode)) {
|
||||
upper+= 4096;
|
||||
}
|
||||
job->estim_upper_size+= upper;
|
||||
if(!(flag & 1))
|
||||
job->estim_lower_size+= lower;
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag)
|
||||
{
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
@ -1823,9 +1846,9 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
gid_t group= 0;
|
||||
time_t date= 0;
|
||||
mode_t mode_or= 0, mode_and= ~1;
|
||||
char *target, *text_2, sfe[5*SfileadrL], *iso_prefix, md5[16];
|
||||
char *target, *text_2, sfe[5*SfileadrL], *iso_prefix, md5[16], *basename;
|
||||
struct FindjoB *subjob;
|
||||
struct stat dir_stbuf;
|
||||
struct stat dir_stbuf, stbuf;
|
||||
|
||||
action= Findjob_get_action_parms(job, &target, &text_2, &user, &group,
|
||||
&mode_and, &mode_or, &type, &date, &subjob, 0);
|
||||
@ -1937,6 +1960,16 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
iso_node_set_sort_weight(node, type);
|
||||
} else if(action == 39) { /* hide */
|
||||
Xorriso_set_hidden(xorriso, node, NULL, type, 0);
|
||||
} else if(action == 40) { /* estimate_size */
|
||||
basename= strrchr(abs_path, '/');
|
||||
if(basename != NULL)
|
||||
basename++;
|
||||
else
|
||||
basename= abs_path;
|
||||
ret= Xorriso_fake_stbuf(xorriso, "", &stbuf, &node, 1);
|
||||
if(ret > 0)
|
||||
ret= Xorriso_estimate_file_size(xorriso, job, basename, stbuf.st_mode,
|
||||
stbuf.st_size, 0);
|
||||
} else { /* includes : 15 in_iso */
|
||||
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
|
||||
Xorriso_result(xorriso, 0);
|
||||
|
@ -1007,6 +1007,8 @@ not_enough_exec_arguments:;
|
||||
goto sorry_ex;
|
||||
}
|
||||
Findjob_set_action_type(job, 39, type, 0);
|
||||
} else if(strcmp(cpt, "estimate_size")==0) {
|
||||
Findjob_set_action_target(job, 40, NULL, 0);
|
||||
} else {
|
||||
sprintf(xorriso->info_text, "-find -exec: unknown action %s",
|
||||
Text_shellsafe(argv[i], sfe, 0));
|
||||
@ -1041,6 +1043,15 @@ ex:;
|
||||
xorriso->pacifier_count, 0, "", 1);
|
||||
if(first_job->action == 35 && !(flag & 1))
|
||||
Xorriso_report_md5_outcome(xorriso, first_job->target, 0);
|
||||
if(first_job->action == 40) {
|
||||
sprintf(xorriso->result_line,"Size lower : %lus\n",
|
||||
(unsigned long) (job->estim_lower_size / (off_t) 2048));
|
||||
Xorriso_result(xorriso,0);
|
||||
sprintf(xorriso->result_line,"Size upper : %lus\n",
|
||||
(unsigned long) ((job->estim_upper_size / (off_t) 2048) +
|
||||
!!(job->estim_upper_size % 2048)));
|
||||
Xorriso_result(xorriso,0);
|
||||
}
|
||||
if(access_acl_text != NULL)
|
||||
free(access_acl_text);
|
||||
if(default_acl_text != NULL)
|
||||
|
@ -1712,6 +1712,12 @@ E.g.:
|
||||
.br
|
||||
-find / -disk_name *_secret -exec hide on
|
||||
.br
|
||||
\fBestimate_size\fR
|
||||
prints a lower and an upper estimation of the number of blocks which the
|
||||
found files together will occupy in the emering ISO image.
|
||||
This does not account for the superblock,
|
||||
for the directories in the -find path, or for image padding.
|
||||
.br
|
||||
\fBfind\fR
|
||||
performs another run of -find on the matching file address.
|
||||
It accepts the same params as -find, except iso_rr_path.
|
||||
|
@ -1538,6 +1538,11 @@ File: xorriso.info, Node: CmdFind, Next: Filter, Prev: Manip, Up: Options
|
||||
"joliet", "off".
|
||||
E.g.:
|
||||
-find / -disk_name *_secret -exec hide on
|
||||
estimate_size
|
||||
prints a lower and an upper estimation of the number of
|
||||
blocks which the found files together will occupy in the
|
||||
emering ISO image. This does not account for the superblock,
|
||||
for the directories in the -find path, or for image padding.
|
||||
find
|
||||
performs another run of -find on the matching file address.
|
||||
It accepts the same params as -find, except iso_rr_path.
|
||||
@ -4370,42 +4375,42 @@ Node: Insert40593
|
||||
Node: SetInsert48950
|
||||
Node: Manip57517
|
||||
Node: CmdFind66198
|
||||
Node: Filter76149
|
||||
Node: Writing80498
|
||||
Node: SetWrite86787
|
||||
Node: Bootable98738
|
||||
Node: Jigdo111045
|
||||
Node: Charset115303
|
||||
Node: Exception118054
|
||||
Node: DialogCtl122569
|
||||
Node: Inquiry124914
|
||||
Node: Navigate129044
|
||||
Node: Verify136642
|
||||
Node: Restore145062
|
||||
Node: Emulation151718
|
||||
Node: Scripting160007
|
||||
Node: Frontend165569
|
||||
Node: Examples166864
|
||||
Node: ExDevices168033
|
||||
Node: ExCreate168667
|
||||
Node: ExDialog169941
|
||||
Node: ExGrowing171203
|
||||
Node: ExModifying172005
|
||||
Node: ExBootable172506
|
||||
Node: ExCharset173053
|
||||
Node: ExPseudo173881
|
||||
Node: ExCdrecord174775
|
||||
Node: ExMkisofs175090
|
||||
Node: ExGrowisofs176093
|
||||
Node: ExException177217
|
||||
Node: ExTime177671
|
||||
Node: ExIncBackup178130
|
||||
Node: ExRestore181602
|
||||
Node: ExRecovery182571
|
||||
Node: Files183137
|
||||
Node: Seealso184365
|
||||
Node: Legal184889
|
||||
Node: CommandIdx185811
|
||||
Node: ConceptIdx200036
|
||||
Node: Filter76443
|
||||
Node: Writing80792
|
||||
Node: SetWrite87081
|
||||
Node: Bootable99032
|
||||
Node: Jigdo111339
|
||||
Node: Charset115597
|
||||
Node: Exception118348
|
||||
Node: DialogCtl122863
|
||||
Node: Inquiry125208
|
||||
Node: Navigate129338
|
||||
Node: Verify136936
|
||||
Node: Restore145356
|
||||
Node: Emulation152012
|
||||
Node: Scripting160301
|
||||
Node: Frontend165863
|
||||
Node: Examples167158
|
||||
Node: ExDevices168327
|
||||
Node: ExCreate168961
|
||||
Node: ExDialog170235
|
||||
Node: ExGrowing171497
|
||||
Node: ExModifying172299
|
||||
Node: ExBootable172800
|
||||
Node: ExCharset173347
|
||||
Node: ExPseudo174175
|
||||
Node: ExCdrecord175069
|
||||
Node: ExMkisofs175384
|
||||
Node: ExGrowisofs176387
|
||||
Node: ExException177511
|
||||
Node: ExTime177965
|
||||
Node: ExIncBackup178424
|
||||
Node: ExRestore181896
|
||||
Node: ExRecovery182865
|
||||
Node: Files183431
|
||||
Node: Seealso184659
|
||||
Node: Legal185183
|
||||
Node: CommandIdx186105
|
||||
Node: ConceptIdx200330
|
||||
|
||||
End Tag Table
|
||||
|
@ -2077,6 +2077,12 @@ E.g.:
|
||||
@*
|
||||
-find / -disk_name *_secret -exec hide on
|
||||
@*
|
||||
@item estimate_size
|
||||
prints a lower and an upper estimation of the number of blocks which the
|
||||
found files together will occupy in the emering ISO image.
|
||||
This does not account for the superblock,
|
||||
for the directories in the -find path, or for image padding.
|
||||
@*
|
||||
@item find
|
||||
performs another run of -find on the matching file address.
|
||||
It accepts the same params as -find, except iso_rr_path.
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2010.12.02.063209"
|
||||
#define Xorriso_timestamP "2010.12.02.111029"
|
||||
|
@ -552,5 +552,9 @@ int Xorriso_preparer_string(struct XorrisO *xorriso, char xorriso_id[129],
|
||||
int Xorriso_jigdo_interpreter(struct XorrisO *xorriso, char *aspect, char *arg,
|
||||
int flag);
|
||||
|
||||
|
||||
int Xorriso_estimate_file_size(struct XorrisO *xorriso, struct FindjoB *job,
|
||||
char *basename, mode_t st_mode, off_t st_size, int flag);
|
||||
|
||||
#endif /* Xorrisoburn_includeD */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user