mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-01-05 08:00:05 +01:00
Allow files with non-standard extensions to be tested or decompressed if they actually exist.
Don't allow a suffix if an actual output filename has been specified. Convert ints to chars when they can be.
This commit is contained in:
parent
f7a1c14e28
commit
8077412ee5
12
lrzip.c
12
lrzip.c
|
|
@ -531,7 +531,11 @@ void decompress_file(rzip_control *control)
|
|||
struct statvfs fbuf;
|
||||
|
||||
if (!STDIN) {
|
||||
if ((tmp = strrchr(control->infile, '.')) && strcmp(tmp,control->suffix)) {
|
||||
struct stat fdin_stat;
|
||||
|
||||
stat(control->infile, &fdin_stat);
|
||||
if (!S_ISREG(fdin_stat.st_mode) && (tmp = strrchr(control->infile, '.')) &&
|
||||
strcmp(tmp,control->suffix)) {
|
||||
/* make sure infile has an extension. If not, add it
|
||||
* because manipulations may be made to input filename, set local ptr
|
||||
*/
|
||||
|
|
@ -747,7 +751,11 @@ void get_fileinfo(rzip_control *control)
|
|||
struct stat st;
|
||||
|
||||
if (!STDIN) {
|
||||
if ((tmp = strrchr(control->infile, '.')) && strcmp(tmp,control->suffix)) {
|
||||
struct stat fdin_stat;
|
||||
|
||||
stat(control->infile, &fdin_stat);
|
||||
if (!S_ISREG(fdin_stat.st_mode) && (tmp = strrchr(control->infile, '.')) &&
|
||||
strcmp(tmp,control->suffix)) {
|
||||
infilecopy = malloc(strlen(control->infile) + strlen(control->suffix) + 1);
|
||||
if (unlikely(infilecopy == NULL))
|
||||
fatal("Failed to allocate memory for infile suffix\n");
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ struct rzip_control {
|
|||
i64 in_maxlen;
|
||||
FILE *msgout; //stream for output messages
|
||||
const char *suffix;
|
||||
int compression_level;
|
||||
uchar compression_level;
|
||||
i64 overhead; // compressor overhead
|
||||
i64 usable_ram; // the most ram we'll try to use on one activity
|
||||
i64 maxram; // the largest chunk of ram to allocate
|
||||
|
|
@ -218,7 +218,7 @@ struct rzip_control {
|
|||
i64 max_chunk;
|
||||
i64 max_mmap;
|
||||
int threads;
|
||||
int nice_val; // added for consistency
|
||||
char nice_val; // added for consistency
|
||||
char major_version;
|
||||
char minor_version;
|
||||
i64 st_size;
|
||||
|
|
@ -243,7 +243,7 @@ struct stream {
|
|||
uchar *buf;
|
||||
i64 buflen;
|
||||
i64 bufp;
|
||||
int eos;
|
||||
uchar eos;
|
||||
long uthread_no;
|
||||
long unext_thread;
|
||||
long base_thread;
|
||||
|
|
@ -253,7 +253,7 @@ struct stream {
|
|||
|
||||
struct stream_info {
|
||||
struct stream *s;
|
||||
int num_streams;
|
||||
uchar num_streams;
|
||||
int fd;
|
||||
i64 bufsize;
|
||||
i64 cur_pos;
|
||||
|
|
|
|||
3
main.c
3
main.c
|
|
@ -603,6 +603,7 @@ int main(int argc, char *argv[])
|
|||
if (control.outdir)
|
||||
failure("Cannot have -o and -O together\n");
|
||||
control.outname = optarg;
|
||||
control.suffix = "";
|
||||
break;
|
||||
case 'O':
|
||||
if (control.outname) /* can't mix -o and -O */
|
||||
|
|
@ -623,6 +624,8 @@ int main(int argc, char *argv[])
|
|||
control.flags &= ~FLAG_SHOW_PROGRESS;
|
||||
break;
|
||||
case 'S':
|
||||
if (control.outname)
|
||||
failure("Specified output filename already, can't specify an extension.\n");
|
||||
control.suffix = optarg;
|
||||
break;
|
||||
case 't':
|
||||
|
|
|
|||
Loading…
Reference in a new issue