zipunzip

zipunzip —

Synopsis




enum        ZipOption;
typedef     zipinfo;
struct      zipinfo_;
int         zipfile_create_new              (const char *targ,
                                             const char **filenames,
                                             int level,
                                             ZipOption opt,
                                             GError **gerr);
int         zipfile_archive_files           (const char *targ,
                                             const char **filenames,
                                             int level,
                                             ZipOption opt,
                                             GError **gerr);
int         zipfile_extract_files           (const char *targ,
                                             const char **filenames,
                                             ZipOption opt,
                                             GError **gerr);
int         zipfile_delete_files            (const char *targ,
                                             const char **filenames,
                                             ZipOption opt,
                                             GError **gerr);
zipinfo*    zipfile_get_info                (const char *targ,
                                             ZipOption opt,
                                             GError **gerr);
int         zipinfo_print_all               (zipinfo *zinfo,
                                             FILE *fp);
void        zipinfo_destroy                 (zipinfo *zinfo);

Description

Details

enum ZipOption

typedef enum {
    ZIP_OPTIONS_DEFAULT = 0,
    ZIP_UPDATE          = 1 << 0, /* replace files from disk only if
				     they are newer than in archive */
    ZIP_RECURSE_DIRS    = 1 << 1, /* recurse into sub-directories */
    ZIP_DELETE_INPUTS   = 1 << 2, /* delete input files after compressing */
    ZIP_PUT_LINKS       = 1 << 3, /* store symlinks as links (unix only) */
    ZIP_VERBOSE         = 1 << 4, /* give an account of the proceedings */
    ZIP_TRACE           = 1 << 5  /* very detailed account of working */
} ZipOption;


zipinfo

typedef struct zipinfo_ zipinfo;


struct zipinfo_

struct zipinfo_ {
    gchar *name;      /* name of archive file */
    int nfiles;       /* number of files in archive */
    gchar **fnames;   /* array of filenames */
    guint32 *fsizes;  /* array of file sizes in bytes */
    time_t *mtimes;   /* array of last modification times of files */
};


zipfile_create_new ()

int         zipfile_create_new              (const char *targ,
                                             const char **filenames,
                                             int level,
                                             ZipOption opt,
                                             GError **gerr);

Creates a PKZip-type zip archive containing the files specified in the filenames list. The added files are compressed using the deflate method, or, if deflate does not reduce the size of the file, simply stored verbatim in the archive. If a file of the name targ already exists it is disregarded, and is overwritten once the new archive is created.

targ : name of zipfile to be created.
filenames : array of strings holding the names of the files to be added to targ, terminated by a NULL sentinel.
level : compression level for zlib deflation (1 = fastest, 9 = greatest compression; 6 is commonly reckoned to be a reasonable compromise between speed and space-saving.)
opt : bit-wise OR of the ZipOption flags.
gerr : location to receive a GError pointer in case of failure, or NULL.
Returns : 0 on success, non-zero error code on failure, in which case gerr will receive an account of the error if gerr is not NULL.

zipfile_archive_files ()

int         zipfile_archive_files           (const char *targ,
                                             const char **filenames,
                                             int level,
                                             ZipOption opt,
                                             GError **gerr);

If no file of the name targ already exists, this function is equivalent to zipfile_create_new(). But if targ already exists this function augments and/or updates the existing archive according to the following rule. For each file in filenames: if there is no file of that name in the current archive, the file is added; if there is a file of the same name in the archive, what happens depends on whether or not the option ZIP_UPDATE is given. If ZIP_UPDATE is given, the file in the archive is replaced only if the file on disk is more recently modified; if this option is not given, the file in the archive is replaced regardless.

targ : name of zipfile to be created or added to.
filenames : array of strings holding the names of the files to be added to targ, terminated by a NULL sentinel.
level : compression level for zlib deflation (1 = fastest, 9 = greatest compression; 6 is commonly reckoned to be a reasonable compromise between speed and space-saving.)
opt : bit-wise OR of the ZipOption flags.
gerr : location to receive a GError pointer in case of failure, or NULL.
Returns : 0 on success, non-zero error code on failure, in which case gerr will receive an account of the error if gerr is not NULL.

zipfile_extract_files ()

int         zipfile_extract_files           (const char *targ,
                                             const char **filenames,
                                             ZipOption opt,
                                             GError **gerr);

Unzips a PKZip-type zipfile, either extracting all members of the archive or, if filenames is non-NULL, a specified subset of the included files.

targ : name of file to be unzipped.
filenames : array of strings holding the names of the files to be extracted from targ, terminated by a NULL sentinel. If this argument is NULL, all files are extracted.
opt : may contain ZIP_VERBOSE or ZIP_TRACE.
gerr : location to receive a GError pointer in case of failure, or NULL.
Returns : 0 on success, non-zero error code on failure, in which case gerr will receive an account of the error if gerr is not NULL.

zipfile_delete_files ()

int         zipfile_delete_files            (const char *targ,
                                             const char **filenames,
                                             ZipOption opt,
                                             GError **gerr);

Deletes the specified entries from within a PKZip-type zipfile.

targ : name of file to be modified.
filenames : array of strings holding the names of the files to be deleted from targ, terminated by a NULL sentinel. This argument cannot be NULL.
opt : may contain ZIP_VERBOSE or ZIP_TRACE.
gerr : location to receive a GError pointer in case of failure, or NULL.
Returns : 0 on success, non-zero error code on failure, in which case gerr will receive an account of the error if gerr is not NULL.

zipfile_get_info ()

zipinfo*    zipfile_get_info                (const char *targ,
                                             ZipOption opt,
                                             GError **gerr);

Lists the contents of a PKZip-type zipfile, giving the results as a set of arrays within a zipinfo structure.

targ : name of file to be listed.
opt : may contain ZIP_VERBOSE or ZIP_TRACE.
gerr : location to receive a GError pointer in case of failure, or NULL.
Returns : pointer to a zipinfo structure holding the names, sizes and last modification times of the files in the zip archive, or NULL on failure.

zipinfo_print_all ()

int         zipinfo_print_all               (zipinfo *zinfo,
                                             FILE *fp);

Prints the content of zinfo, in the manner of "unzip -l".

zinfo : pointer to zipinfo structure.
fp : FILE to which results should be directed.
Returns : 0 on success, ZE_NONE if zinfo is NULL or empty.

zipinfo_destroy ()

void        zipinfo_destroy                 (zipinfo *zinfo);

Frees all resources associated with a zipinfo pointer, as obtained using zipfile_get_info().

zinfo : pointer to zipinfo structure.