Fix detection of zip-compressed file.

(compression_type): add COMPRESSION_ZIP value.
(decompress_extension): support COMPRESSION_ZIP.
(get_compression_type): fix zip-file detection.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2022-10-02 11:27:34 +03:00
parent 395569c685
commit b42e58dfbc
2 changed files with 4 additions and 3 deletions

View File

@ -840,12 +840,10 @@ get_compression_type (int fd, const char *name)
if (mc_read (fd, (char *) magic, 2) != 2)
return COMPRESSION_NONE;
/* Gzip can handle only deflated (8) or stored (0) files */
if ((magic[0] != 8 && magic[0] != 0) || magic[1] != 0)
return COMPRESSION_NONE;
/* Compatible with gzip */
return COMPRESSION_GZIP;
return COMPRESSION_ZIP;
}
/* PACK_MAGIC and LZH_MAGIC and compress magic */
@ -910,6 +908,8 @@ decompress_extension (int type)
{
switch (type)
{
case COMPRESSION_ZIP:
return "/uz" VFS_PATH_URL_DELIMITER;
case COMPRESSION_GZIP:
return "/ugz" VFS_PATH_URL_DELIMITER;
case COMPRESSION_BZIP:

View File

@ -77,6 +77,7 @@ typedef enum
enum compression_type
{
COMPRESSION_NONE,
COMPRESSION_ZIP,
COMPRESSION_GZIP,
COMPRESSION_BZIP,
COMPRESSION_BZIP2,