Adopted new libisofs filter module gzip.c, builtin filters --gzip, --gunzip
This commit is contained in:
@ -9953,6 +9953,17 @@ int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node,
|
||||
internal_filter= 1;
|
||||
} else if(strcmp(filter_name, "--zisofs-decode") == 0) {
|
||||
internal_filter= 2;
|
||||
} else if(strcmp(filter_name, "--gzip") == 0) {
|
||||
internal_filter= 3;
|
||||
suffix= ".gz";
|
||||
strip_suffix= 0;
|
||||
explicit_suffix= 1;
|
||||
} else if(strcmp(filter_name, "--gunzip") == 0 ||
|
||||
strcmp(filter_name, "--gzip-decode") == 0) {
|
||||
internal_filter= 4;
|
||||
suffix= ".gz";
|
||||
strip_suffix= 1;
|
||||
explicit_suffix= 1;
|
||||
} else {
|
||||
ret= Xorriso_lookup_extf(xorriso, filter_name, &found_lst, 0);
|
||||
if(ret < 0)
|
||||
@ -9985,19 +9996,29 @@ int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node,
|
||||
while(1) {
|
||||
if(!explicit_suffix) {
|
||||
stream= iso_file_get_stream(file);
|
||||
ret= iso_stream_get_external_filter(stream, &cmd, 0);
|
||||
if(ret > 0) {
|
||||
if(cmd->suffix[0]) {
|
||||
|
||||
/* >>> would need the current renaming state of path */;
|
||||
|
||||
ret= Xorriso_rename_suffix(xorriso, node, cmd->suffix, NULL,
|
||||
new_name,
|
||||
(flag & 1) | (!(cmd->behavior & 8) << 1));
|
||||
if(ret <= 0 || ret == 2)
|
||||
goto ex;
|
||||
if(strncmp(stream->class->type, "gzip", 4) == 0) {
|
||||
suffix= ".gz";
|
||||
strip_suffix= 1;
|
||||
} else if(strncmp(stream->class->type, "pizg", 4) == 0) {
|
||||
suffix= ".gz";
|
||||
strip_suffix= 0;
|
||||
} else {
|
||||
ret= iso_stream_get_external_filter(stream, &cmd, 0);
|
||||
if(ret > 0) {
|
||||
suffix= cmd->suffix;
|
||||
strip_suffix= !(cmd->behavior & 8);
|
||||
}
|
||||
}
|
||||
if(suffix[0]) {
|
||||
|
||||
/* >>> would need the current renaming state of path */;
|
||||
|
||||
ret= Xorriso_rename_suffix(xorriso, node, suffix, NULL, new_name,
|
||||
(flag & 1) | (strip_suffix << 1));
|
||||
if(ret <= 0 || ret == 2)
|
||||
goto ex;
|
||||
}
|
||||
}
|
||||
ret= iso_file_remove_filter(file, 0);
|
||||
if(ret != 1)
|
||||
@ -10012,6 +10033,14 @@ int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node,
|
||||
Xorriso_report_iso_error(xorriso, "", filter_ret,
|
||||
"Error when setting filter to ISO node", 0, "FAILURE", 1);
|
||||
}
|
||||
} else if (internal_filter == 3 || internal_filter == 4) {
|
||||
filter_ret = iso_file_add_gzip_filter(file,
|
||||
1 | ((internal_filter == 4) << 1));
|
||||
if(filter_ret < 0) {
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
Xorriso_report_iso_error(xorriso, "", filter_ret,
|
||||
"Error when setting filter to ISO node", 0, "FAILURE", 1);
|
||||
}
|
||||
} else {
|
||||
|
||||
#ifndef Xorriso_allow_extf_suiD
|
||||
@ -10288,6 +10317,10 @@ int Xorriso_stream_type(struct XorrisO *xorriso, IsoNode *node,
|
||||
strcpy(type_text, "--zisofs");
|
||||
} else if(strcmp(text, "osiz") == 0) {
|
||||
strcpy(type_text, "--zisofs-decode");
|
||||
} else if(strcmp(text, "gzip") == 0) {
|
||||
strcpy(type_text, "--gzip");
|
||||
} else if(strcmp(text, "pizg") == 0) {
|
||||
strcpy(type_text, "--gunzip");
|
||||
} else if(strcmp(text, "cout") == 0 || strcmp(text, "boot") == 0 ||
|
||||
strcmp(text, "user") == 0 || strcmp(text, "extf") == 0) {
|
||||
strcpy(type_text, text);
|
||||
@ -10394,20 +10427,25 @@ int Xorriso_status_zisofs(struct XorrisO *xorriso, char *filter, FILE *fp,
|
||||
*/
|
||||
{
|
||||
off_t ziso_count= 0, osiz_count= 0;
|
||||
off_t gzip_count= 0, gunzip_count= 0;
|
||||
|
||||
iso_zisofs_get_refcounts(&ziso_count, &osiz_count, 0);
|
||||
iso_gzip_get_refcounts(&gzip_count, &gunzip_count, 0);
|
||||
if((flag & 1) && xorriso->zlib_level == xorriso->zlib_level_default &&
|
||||
xorriso->zisofs_block_size == xorriso->zisofs_block_size_default &&
|
||||
xorriso->zisofs_by_magic == 0 &&
|
||||
ziso_count == 0 && osiz_count == 0 &&
|
||||
gzip_count == 0 && gunzip_count == 0 &&
|
||||
filter[0] == 0)
|
||||
return 2;
|
||||
sprintf(xorriso->result_line,
|
||||
"-zisofs level=%d:block_size=%dk:by_magic=%s:ziso_used=%.f:osiz_used=%.f\n",
|
||||
xorriso->zlib_level, xorriso->zisofs_block_size / 1024,
|
||||
xorriso->zisofs_by_magic ? "on" : "off",
|
||||
(double) ziso_count, (double) osiz_count);
|
||||
|
||||
"-zisofs level=%d:block_size=%dk:by_magic=%s:ziso_used=%.f:osiz_used=%.f",
|
||||
xorriso->zlib_level, xorriso->zisofs_block_size / 1024,
|
||||
xorriso->zisofs_by_magic ? "on" : "off",
|
||||
(double) ziso_count, (double) osiz_count);
|
||||
sprintf(xorriso->result_line + strlen(xorriso->result_line),
|
||||
":gzip_used=%.f:gunzip_used=%.f\n",
|
||||
(double) gzip_count, (double) gunzip_count);
|
||||
Xorriso_status_result(xorriso, filter, fp, flag&2);
|
||||
return(1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user