Gave up the unusual parameter sequences of -extract and -paste_in

This commit is contained in:
2008-06-14 18:44:42 +00:00
parent a15e636952
commit 818de9128d
5 changed files with 91 additions and 79 deletions

View File

@ -8863,30 +8863,18 @@ ex:;
}
/* SPLIT : proposed target format
part_{partno}_of_{total_parts}_at_{offset}_with_{bytes}_of_{total_bytes}
*/
/* Options -cut_out, -paste_in */
/* @param flag bit0= -paste_in rather than cut_out
*/
/* Option -cut_out */
int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path,
char *start, char *count, char *iso_rr_path, int flag)
{
int ret;
double num;
off_t startbyte, bytecount;
char *cmd;
if(flag&1)
cmd= "paste_in";
else
cmd= "cut_out";
num= Scanf_io_size(start, 0);
if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */
sprintf(xorriso->info_text,
"-%s: startbyte address negative or much too large (%s)", cmd, start);
"-cut_out: startbyte address negative or much too large (%s)", start);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
@ -8894,29 +8882,19 @@ int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path,
num= Scanf_io_size(count, 0);
if(num<=0 || num > 1.0e18) {
sprintf(xorriso->info_text,
"-%s: bytecount zero, negative or much too large (%s)", cmd, count);
"-cut_out: bytecount zero, negative or much too large (%s)", count);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
bytecount= num;
if(flag&1) {
sprintf(xorriso->info_text, "-paste_in from %s to %s, byte %.f to %.f",
disk_path, iso_rr_path,
(double) startbyte, (double) (startbyte+bytecount));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
sprintf(xorriso->info_text,
"-cut_out from %s , byte %.f to %.f, and graft as %s",
disk_path, (double) startbyte, (double) (startbyte+bytecount),
iso_rr_path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
ret= Xorriso_paste_in(xorriso, disk_path, startbyte, bytecount,
iso_rr_path, 0);
} else {
sprintf(xorriso->info_text,
"-cut_out from %s , byte %.f to %.f, and graft as %s",
disk_path, (double) startbyte, (double) (startbyte+bytecount),
iso_rr_path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
ret= Xorriso_cut_out(xorriso, disk_path, startbyte, bytecount,
iso_rr_path, 0);
}
ret= Xorriso_cut_out(xorriso, disk_path, startbyte, bytecount,
iso_rr_path, 0);
return(ret);
}
@ -9222,8 +9200,8 @@ int Xorriso_option_error_behavior(struct XorrisO *xorriso,
bit1=do not reset pacifier, no final pacifier message
bit5= -extract_single: eventually do not insert directory tree
*/
int Xorriso_option_extract(struct XorrisO *xorriso, char *disk_path,
char *iso_path, int flag)
int Xorriso_option_extract(struct XorrisO *xorriso, char *iso_path,
char *disk_path, int flag)
{
int ret;
char eff_origin[SfileadrL], eff_dest[SfileadrL], *ipth;
@ -9843,6 +9821,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" By default \"off\" the inverse operation of xorriso from ISO",
" image to disk filesystem is disabled. \"on\" allows xorriso",
" to create, overwrite, delete files in the disk filesystem.",
" -extract iso_rr_path disk_path",
" Copy tree under iso_rr_path onto disk address disk_path.",
" This avoids the pitfalls of cp -r addressing rules.",
" -cpx iso_rr_path [***] disk_path",
" Copy leaf file objects from ISO image to disk filesystem.",
" -cpax iso_rr_path [***] disk_path",
@ -9851,14 +9832,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Copy directory trees from ISO image to disk filesystem.",
" -cp_rax iso_rr_path [***] disk_path",
" Like -cp_rx but trying to restore timestamps and ownership.",
"The following restore options get the same arguments as their counterparts",
"which put files into ISO images. Thus first disk_path and then iso_rr_path:",
" -extract disk_path iso_rr_path",
" Copy tree under iso_rr_path onto disk address disk_path.",
" This avoids the pitfalls of cp -r addressing rules.",
" -extract_single disk_path iso_rr_path",
" Like -extract but with directory do not insert its sub tree.",
" -paste_in disk_path byte_offset byte_count iso_rr_path",
" -paste_in iso_rr_path disk_path byte_offset byte_count",
" Copy ISO file content into a byte interval of a disk file.",
"",
"Compatibility emulation (argument list may be ended by --):",
@ -10826,6 +10802,41 @@ int Xorriso_option_page(struct XorrisO *xorriso, int len, int width, int flag)
}
/* Option -paste_in */
int Xorriso_option_paste_in(struct XorrisO *xorriso, char *iso_rr_path,
char *disk_path, char *start, char *count, int flag)
{
int ret;
double num;
off_t startbyte, bytecount;
num= Scanf_io_size(start, 0);
if(num<0 || num > 1.0e18) { /* 10^18 = 10^3 ^ 6 < 2^10 ^ 6 = 2^60 */
sprintf(xorriso->info_text,
"-paste_in: startbyte address negative or much too large (%s)", start);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
startbyte= num;
num= Scanf_io_size(count, 0);
if(num<=0 || num > 1.0e18) {
sprintf(xorriso->info_text,
"-paste_in : bytecount zero, negative or much too large (%s)", count);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
bytecount= num;
sprintf(xorriso->info_text, "-paste_in from %s to %s, byte %.f to %.f",
disk_path, iso_rr_path,
(double) startbyte, (double) (startbyte+bytecount));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
ret= Xorriso_paste_in(xorriso, disk_path, startbyte, bytecount,
iso_rr_path, 0);
return(ret);
}
/* Option -path-list */
int Xorriso_option_path_list(struct XorrisO *xorriso, char *adr, int flag)
{
@ -12138,8 +12149,8 @@ next_command:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0;
} else
ret= Xorriso_option_cut_out(xorriso, arg1, arg2,
argv[(*idx)-2], argv[(*idx)-1], 1);
ret= Xorriso_option_paste_in(xorriso, arg1, arg2,
argv[(*idx)-2], argv[(*idx)-1], 0);
} else if(strcmp(cmd,"path-list")==0 || strcmp(cmd,"path_list")==0) {
(*idx)++;