Implemented option -du

This commit is contained in:
2007-11-01 19:11:56 +00:00
parent d006ef3179
commit 11d712622e
6 changed files with 288 additions and 102 deletions

View File

@ -3780,14 +3780,16 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
"images with Rock Ridge extensions. Write targets can be drives with optical",
"media or local filesystem objects.",
"",
"Note: Options marked by prefix \"> \" are not implemented yet.",
"",
"Preparation options:",
"Drive addresses are either /dev/... as listed with option -devices or",
"disk files with prefix \"stdio:\", e.g. stdio:/tmp/pseudo_drive .",
" -dev address Set input and output drive and load eventual ISO image.",
" Set the image expansion method to growing.",
" -indev address Set input drive and load eventual ISO image. Switch from",
"> -indev address Set input drive and load eventual ISO image. Switch from",
" growing to modifying.",
" -outdev address",
"> -outdev address",
" Set output drive and switch from growing to modifying.",
" -ban_stdio_write",
" Allow for writing only the usage of optical drives.",
@ -3795,7 +3797,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Blank media resp. invalidate ISO image on media.",
" -format \"full\"",
" Format DVD-RW to overwriteable state or de-ice DVD+RW.",
" -V volume_id Specifies the volume ID text.",
"> -V volume_id Specifies the volume ID text.",
"",
" -J Generate Joliet info additional to Rock Ridge info.",
"",
@ -3826,7 +3828,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Like -add but read the pathspecs from file disk_path.",
" -graft-points Allow pathspecs of form iso_rr_path=disk_path",
"",
" -cp_r disk_path [...] iso_rr_path",
"> -cp_r disk_path [...] iso_rr_path",
" Insert the given files or directory trees from filesystem",
" into the ISO image.",
" -rm iso_rr_path [...]",
@ -3836,27 +3838,27 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -mv iso_rr_path [...] iso_rr_path",
" Rename the given file objects in the ISO tree to the last",
" argument in the list.",
" -chown uid iso_rr_path [...]",
"> -chown uid iso_rr_path [...]",
" Equivalent to chown in the ISO image.",
" -chgrp gid iso_rr_path [...]",
"> -chgrp gid iso_rr_path [...]",
" Equivalent to chgrp in the ISO image.",
" -chmod mode iso_rr_path [...]",
"> -chmod mode iso_rr_path [...]",
" Equivalent to chmod in the ISO image.",
" -alter_date type timestring iso_rr_path [...]",
"> -alter_date type timestring iso_rr_path [...]",
" Alter the date entries of a file in the ISO image. type is",
" one of \"a\", \"m\", \"b\" for:",
" access time, modification time, both times.",
" -mkdir iso_rr_path [...]",
" Create empty directories if they do not exist yet",
" -rmdir iso_rr_path [...]",
"> -rmdir iso_rr_path [...]",
" Delete empty directories.",
" -- Mark end of particular action argument list.",
"",
" -f Follow symbolic links within disk_path.",
"> -f Follow symbolic links within disk_path.",
"",
" -overwrite \"on\"|\"off\"",
"> -overwrite \"on\"|\"off\"",
" Allow or disallow to overwrite existing files in ISO image.",
" -reassure \"on\"|\"off\"",
"> -reassure \"on\"|\"off\"",
" If \"on\" then ask the user for \"y\" or \"n\" with any",
" file before deleting or overwriting it in the ISO image.",
"",
@ -3894,20 +3896,27 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" -pwdi same as -pwd.",
" -pwdx tells the current working directory in the local filesystem.",
"",
" -ls pattern lists files of the ISO image which match the given",
" shell parser pattern. (I.e. wildcards '*' '?')",
" -lsi pattern same as -ls.",
" -lsx pattern lists files of the local filesystem which match the given",
" shell parser pattern. (I.e. wildcards '*' '?')",
" -ls pattern [...] lists files of the ISO image which match one of the",
" given shell parser patterns. (I.e. wildcards '*' '?')",
" -lsi pattern [...] same as -ls.",
"> -lsx pattern [...] lists files of the local filesystem which match one",
" of the patterns.",
"",
" -ls_l pattern like -ls but also telling some file attributes.",
" -ls_li pattern same as -ls_l.",
" -ls_lx pattern like -lsx but also telling some file attributes.",
" -ls_l pattern [...] like -ls but also telling some file attributes.",
" -ls_li pattern [...] same as -ls_l.",
"> -ls_lx pattern [...] like -lsx but also telling some file attributes.",
"",
" -find pattern lists matching files below current working directory in",
" -du pattern [...] recursively lists sizes of files or directories which",
" match one of the shell parser patterns.",
" -dui pattern [...] same as -du.",
" -du_s pattern [...] like -du but summing up subdirectories without",
" listing them explicitely.",
" -dui pattern [...] same as -du_s.",
"",
"> -find pattern lists matching files below current working directory in",
" the ISO image.",
" -findi pattern same as -find.",
" -findx pattern lists matching files below current working directory in",
"> -findi pattern same as -find.",
"> -findx pattern lists matching files below current working directory in",
" the local filesystem.",
"",
"General options:",
@ -4028,15 +4037,18 @@ int Xorriso_option_j_capital(struct XorrisO *xorriso, int flag)
}
/* Options -ls alias -lsi and ls_l alias ls_li */
/* @param flag bit0= long format (-ls_l)
/* Options -ls alias -lsi and -ls_l alias -ls_li
and -du alias -dui and -du_s alias -du_si
@param flag bit0= long format (-ls_l , -du)
bit1= do not expand patterns but use literally
bit2= du rather than ls
*/
int Xorriso_option_lsi(struct XorrisO *xorriso, int argc, char **argv,
int *idx, int flag)
{
int ret, end_idx, filec= 0, nump, i;
char **filev= NULL, **patterns= NULL;
off_t mem= 0;
end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 1);
@ -4067,15 +4079,16 @@ no_memory:;
}
}
if(flag&2) {
ret= Xorriso_ls_filev(xorriso, nump, argv + (*idx), flag&1);
} else if(nump==1 && strcmp(patterns[0],"*")==0){
ret= Xorriso_ls_filev(xorriso, nump, argv + (*idx), mem, flag&1);
} else if(nump==1 && strcmp(patterns[0],"*")==0 && !(flag&4)){
/* save temporary memory by calling simpler function */
ret= Xorriso_ls(xorriso, (flag&1)|4);
} else {
ret= Xorriso_expand_pattern(xorriso, nump, patterns, &filec, &filev, 0);
ret= Xorriso_expand_pattern(xorriso, nump, patterns, &filec, &filev,
&mem, 0);
if(ret<=0)
{ret= 0; goto ex;}
ret= Xorriso_ls_filev(xorriso, filec, filev, flag&1);
ret= Xorriso_ls_filev(xorriso, filec, filev, mem, flag&(1|4));
}
if(ret<=0)
{ret= 0; goto ex;}
@ -4943,6 +4956,10 @@ next_command:;
(*idx)++;
ret= Xorriso_option_dialog(xorriso, arg1, 0);
} else if(strcmp(cmd,"-du")==0 || strcmp(cmd,"-dui")==0 ||
strcmp(cmd,"-du_s")==0 || strcmp(cmd,"-du_si")==0) {
ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (strlen(cmd)<5)|4);
} else if(strcmp(cmd,"-eject")==0) {
(*idx)++;
ret= Xorriso_option_eject(xorriso, arg1, 0);
@ -5161,14 +5178,16 @@ next_command:;
/* tis ok */;
} else if(cmd[0]=='-') {
unknown_option:;
sprintf(xorriso->info_text,
"=== Input line beginning with '-' is not a known option\n");
"=== Not a known option:\n");
sprintf(xorriso->info_text+strlen(xorriso->info_text),
"=== '%s'\n",cmd);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
} else {
goto unknown_option;
/* >>> ??? pathspecs for option -add */;