mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Some little bugfixies for xz and lzma archives:
* Increase number of reading butes by one for better analyzation of compression type. * Add recognize lzma archive by extention. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
f5d01be72a
commit
bd95f71a6b
27
src/util.c
27
src/util.c
@ -855,7 +855,7 @@ get_current_wd (char *buffer, int size)
|
||||
#endif /* !USE_VFS */
|
||||
|
||||
enum compression_type
|
||||
get_compression_type (int fd)
|
||||
get_compression_type (int fd, const char * name)
|
||||
{
|
||||
unsigned char magic[16];
|
||||
|
||||
@ -920,14 +920,23 @@ get_compression_type (int fd)
|
||||
}
|
||||
|
||||
/* XZ compression magic */
|
||||
if (magic[0] == 0xFD
|
||||
&& magic[1] == 0x37
|
||||
&& magic[2] == 0x7A
|
||||
&& magic[3] == 0x58
|
||||
&& magic[4] == 0x5A
|
||||
&& magic[5] == 0x00) {
|
||||
return COMPRESSION_XZ;
|
||||
}
|
||||
if (mc_read(fd, (char *) magic+5, 1) == 1)
|
||||
{
|
||||
if (
|
||||
magic[0] == 0xFD
|
||||
&& magic[1] == 0x37
|
||||
&& magic[2] == 0x7A
|
||||
&& magic[3] == 0x58
|
||||
&& magic[4] == 0x5A
|
||||
&& magic[5] == 0x00
|
||||
){
|
||||
return COMPRESSION_XZ;
|
||||
}
|
||||
}
|
||||
|
||||
/* HACK: we must belive to extention of LZMA file :) ...*/
|
||||
if (strlen(name) > 5 && strcmp(&name[strlen(name)-5],".lzma") == 0)
|
||||
return COMPRESSION_LZMA;
|
||||
|
||||
return COMPRESSION_NONE;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ enum compression_type {
|
||||
|
||||
/* Looks for ``magic'' bytes at the start of the VFS file to guess the
|
||||
* compression type. Side effect: modifies the file position. */
|
||||
enum compression_type get_compression_type (int fd);
|
||||
enum compression_type get_compression_type (int fd, const char*);
|
||||
const char *decompress_extension (int type);
|
||||
|
||||
/* Hook functions */
|
||||
|
@ -348,7 +348,7 @@ mcview_load (mcview_t * view, const char *command, const char *file, int start_l
|
||||
/* Must be one of those nice files that grow (/proc) */
|
||||
mcview_set_datasource_vfs_pipe (view, fd);
|
||||
} else {
|
||||
type = get_compression_type (fd);
|
||||
type = get_compression_type (fd, file);
|
||||
|
||||
if (view->magic_mode && (type != COMPRESSION_NONE)) {
|
||||
g_free (view->filename);
|
||||
|
@ -175,7 +175,7 @@ cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super,
|
||||
mc_stat (name, &(super->u.arch.st));
|
||||
super->u.arch.type = CPIO_UNKNOWN;
|
||||
|
||||
type = get_compression_type (fd);
|
||||
type = get_compression_type (fd, name);
|
||||
if (type != COMPRESSION_NONE) {
|
||||
char *s;
|
||||
|
||||
|
@ -243,7 +243,7 @@ tar_open_archive_int (struct vfs_class *me, const char *name,
|
||||
archive->u.arch.type = TAR_UNKNOWN;
|
||||
|
||||
/* Find out the method to handle this tar file */
|
||||
type = get_compression_type (result);
|
||||
type = get_compression_type (result, name);
|
||||
mc_lseek (result, 0, SEEK_SET);
|
||||
if (type != COMPRESSION_NONE) {
|
||||
char *s;
|
||||
|
Loading…
Reference in New Issue
Block a user