};
/*
- * Universal zstream.
+ * A stream object of universal compressor.
*/
struct la_zstream {
const uint8_t *next_in;
#define HAS_STREAM (1<<4)
struct {
- time_t time;
- long time_ns;
+ time_t time;
+ long time_ns;
} times[3];
#define MTIME 0
#define ATIME 1
zip->total_number_entry++;
zip->total_bytes_entry_name += file->name_len + 2;
if (file->size == 0) {
+ /* Count up the number of empty files. */
zip->total_number_empty_entry++;
if (file->dir)
zip->total_number_dir_entry++;
zip->entry_bytes_remaining = file->size;
zip->entry_crc32 = 0;
+ /*
+ * Store a symbolic link name as file contents.
+ */
if (archive_entry_filetype(entry) == AE_IFLNK) {
ssize_t bytes;
const void *p = (const void *)archive_entry_symlink(entry);
return (r);
}
+/*
+ * Write data to a temporary file.
+ */
static int
write_to_temp(struct archive_write *a, const void *buff, size_t s)
{
zip->total_number_nonempty_entry =
zip->total_number_entry - zip->total_number_empty_entry;
+ /* Connect an empty file list. */
*zip->file_list.last = zip->empty_list.first;
zip->file_list.last = zip->empty_list.last;
+ /* Connect a directory file list. */
ARCHIVE_RB_TREE_FOREACH(n, &(zip->rbtree)) {
file_register(zip, (struct file *)n);
}
/*
* NOTE: 7z command supports just LZMA1, LZMA2 and COPY for
- * the header.
+ * the compression type for encoding the header.
*/
#if HAVE_LZMA_H
header_compression = _7Z_LZMA1;
- /* If the stored file is only one, do not encode the header. */
+ /* If the stored file is only one, do not encode the header.
+ * This is the same way 7z command does. */
if (zip->total_number_entry == 1)
header_compression = _7Z_COPY;
#else
return (r);
}
+/*
+ * Encode 64 bits value into 7-Zip's encoded UINT64 value.
+ */
static int
enc_uint64(struct archive_write *a, uint64_t val)
{
}
#endif
+/*
+ * _7_COPY compressor.
+ */
static int
compression_init_encoder_copy(struct archive *a, struct la_zstream *lastrm)
{
return (ARCHIVE_OK);
}
+/*
+ * _7_DEFLATE compressor.
+ */
#ifdef HAVE_ZLIB_H
static int
compression_init_encoder_deflate(struct archive *a,
}
#endif
+/*
+ * _7_BZIP2 compressor.
+ */
#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR)
static int
compression_init_encoder_bzip2(struct archive *a,
}
#endif
+/*
+ * _7_LZMA1, _7_LZMA2 compressor.
+ */
#if defined(HAVE_LZMA_H)
static int
compression_init_encoder_lzma(struct archive *a,
#endif
/*
- * PPMd compression.
+ * _7_PPMD compressor.
*/
static void *
ppmd_alloc(void *p, size_t size)
return (ARCHIVE_OK);
}
+/*
+ * Universal compressor initializer.
+ */
static int
_7z_compression_init_encoder(struct archive_write *a, unsigned compression,
int compression_level)