Implemented IsoExternalFilterCommand.behavior bits 1 and 2

which control revocation due to insufficient size reduction.
This commit is contained in:
Thomas Schmitt 2009-03-29 14:37:26 +02:00
parent 681d092118
commit 2534be5b5d
2 changed files with 22 additions and 2 deletions

View File

@ -615,7 +615,15 @@ int iso_file_add_external_filter(IsoFile *file, IsoExternalFilterCommand *cmd,
int ret;
FilterContext *f = NULL;
IsoStream *stream;
off_t original_size = 0, filtered_size = 0;
if (cmd->behavior & (2 | 4)) {
original_size = iso_file_get_size(file);
if (original_size <= 0 ||
((cmd->behavior & 4) && original_size < 2048)) {
return 2;
}
}
ret = extf_create_context(cmd, &f, 0);
if (ret < 0) {
return ret;
@ -627,10 +635,18 @@ int iso_file_add_external_filter(IsoFile *file, IsoExternalFilterCommand *cmd,
}
/* Run a full filter process getsize so that the size is cached */
stream = iso_file_get_stream(file);
ret = iso_stream_get_size(stream);
filtered_size = iso_stream_get_size(stream);
if (ret < 0) {
return ret;
}
if (((cmd->behavior & 2) && filtered_size >= original_size) ||
((cmd->behavior & 4) && filtered_size / 2048 >= original_size / 2048)){
ret = iso_file_remove_filter(file, 0);
if (ret < 0) {
return ret;
}
return 2;
}
return ISO_SUCCESS;
}

View File

@ -4710,7 +4710,11 @@ struct iso_external_filter_command
/* A bit field which controls behavior variations:
* bit0= Shortcut: 0 sized input will surely yield 0 sized output
* >>> not implemented yet: bit1= Do not install filter if the output becomes larger than the input
* bit1= Do not install filter if the output is not smaller than the input
* bit2= Do not install filter if the number of output blocks is
* not smaller than the number of input blocks. Block size is 2048.
* Assume that non-empty input yields non-empty output and thus do
* not attempt to attach a filter to files smaller than 2048 bytes.
*/
int behavior;
};