Libzip
libzip.org
libzip - libzip
libzip is fully documented via man pages. HTML versions of the man pages are in the Reference section. Example source code is in the examples and src subdirectories.
Factsheet
libzip
Developers Dieter Baron, Thomas Klausner
Stable release 1.11.4
/ 23 May 2025; 12 months ago (23 May 2025)
/ 23 May 2025; 12 months ago (23 May 2025)
libzip
Developers Dieter Baron, Thomas Klausner
Stable release 1.11.4
/ 23 May 2025; 12 months ago (23 May 2025)
/ 23 May 2025; 12 months ago (23 May 2025)
Libzip
libzip.org › documentation
Documentation · libzip
zip_errors — list of all libzip error codes · zip_fclose — close file in zip archive · zip_fdopen — open zip archive using open file descriptor · zip_file_add — add file to zip archive or replace file in zip archive · zip_file_attributes_init — initialize zip file attributes structure ·
Fossies
fossies.org › linux › libzip › examples › in-memory.c
libzip: examples/in-memory.c | Fossies
May 23, 2025 - 32 */ 33 34 #include <errno.h> 35 #include <stdio.h> 36 #include <stdlib.h> 37 #include <string.h> 38 #include <sys/stat.h> 39 40 #include <zip.h> 41 42 static int 43 get_data(void **datap, size_t *sizep, const char *archive) { 44 /* example implementation that reads data from file */ 45 struct stat st; 46 FILE *fp; 47 48 if ((fp = fopen(archive, "rb")) == NULL) { 49 if (errno != ENOENT) { 50 fprintf(stderr, "can't open %s: %s\n", archive, strerror(errno)); 51 return -1; 52 } 53 54 *datap = NULL; 55 *sizep = 0; 56 57 return 0; 58 } 59 60 if (fstat(fileno(fp), &st) < 0) { 61 fprintf(stderr, "ca
Top answer 1 of 2
3
You should not call zip_source_free() since source has already been used in zip_file_add() and freed there.
Also, you should check the return value of zip_open() instead of the value of errorp. Nothing in the documentation indicates that error codes are different than 0. However, the return value will be NULL if the zip file cannot be opened.
2 of 2
0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zip.h>
// apt-get install libzip-dev
// gcc source.c -lzip
int main(){
const char * path = "archive.zip";
const char * file = "message";
const char * data = "Hello World!";
int error = 0;
struct zip *archive = zip_open(path, ZIP_CREATE, &error);
if(error){
printf("could not open or create archive\n");
return -1;
}
struct zip_source *source = zip_source_buffer(archive, data, strlen(data), 0);
if(source == NULL){
printf("failed to create source buffer. %s\n",zip_strerror(archive));
return -1;
}
int index = (int)zip_file_add(archive, file, source, ZIP_FL_OVERWRITE);
if(index < 0){
printf("failed to add file to archive: %s\n",zip_strerror(archive));
return -1;
}
//zip_source_free(source);
zip_close(archive);
return 0;
}
GitHub
github.com › aseprite › libzip › blob › master › examples › in-memory.c
libzip/examples/in-memory.c at master · aseprite/libzip
This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at <libzip@nih.at> · Redistribution and use in source and binary forms, with or without · modification, are permitted provided that the following conditions ·
Author aseprite
GitHub
gist.github.com › mobius › 1759816
using libzip to extract files - gists · GitHub
gcc libzip_simple.c -lzip -o libzip_simple.out · Copy link · Windows O_BINARY is required. Or binary file as zip inside zip become corrupted. fd = open(sb.name, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 0644); Copy link ·
FreeBASIC Wiki
freebasic.net › wiki › wikka.php
libzip - FreeBASIC Wiki Manual | FBWiki
Dim As String filename = *zip_get_name(zip, i, 0) Print "file: " & filename & ", "; '' Retrieve the file size via a zip_stat(). Dim As zip_stat stat If (zip_stat_index(zip, i, 0, @stat)) Then Print "zip_stat() failed" Return End If If ((stat.valid And ZIP_STAT_SIZE) = 0) Then Print "could not ...
GitHub
github.com › nih-at › libzip
GitHub - nih-at/libzip: A C library for reading, creating, and modifying zip archives. · GitHub
libzip is fully documented via man pages. HTML versions of the man pages are on libzip.org and in the man directory. You can start with libzip(3), which lists all others. Example source code is in the examples and src subdirectories.
Starred by 1K users
Forked by 314 users
Languages C 90.3% | CMake 9.1%
GitHub
github.com › winlibs › libzip › blob › master › examples › in-memory.c
libzip/examples/in-memory.c at master · winlibs/libzip
C library for reading, creating, and modifying zip archives - libzip/examples/in-memory.c at master · winlibs/libzip
Author winlibs
Libzip
libzip.org › documentation › zip_file_add.html
zip_file_add · libzip
libzip (-lzip) #include <zip.h> zip_int64_t zip_file_add(zip_t *archive, const char *name, zip_source_t *source, zip_flags_t flags); int zip_file_replace(zip_t *archive, zip_uint64_t index, zip_source_t *source, zip_flags_t flags); The function zip_file_add() adds a file to a zip archive, while ...
GitHub
github.com › aseprite › libzip › tree › master › examples
libzip/examples at master · aseprite/libzip
libzip mirror. Contribute to aseprite/libzip development by creating an account on GitHub.
Author aseprite
Libzip
libzip.org › documentation › libzip.html
libzip · libzip
For this reason, when modifying zip archives, libzip writes to a temporary file and replaces the original zip archive atomically.
Wikipedia
en.wikipedia.org › wiki › Libzip
libzip - Wikipedia
November 23, 2024 - Since version 1.1, libzip contains ziptool, a tool for modifying zip archives from the command line.
Linux Man Pages
linux.die.net › man › 3 › libzip
libzip(3) - Linux man page
libzip - library for manipulating zip archives · libzip (-lzip) #include <zip.h> libzip is a library for reading, creating, and modifying zip archives. Below there are two sections listing functions: one for how to read from zip archives and one for how to create/modify them.
7-Zip Documentation
documentation.help › FreeBASIC › ExtLibZip.html
libzip - FreeBASIC - Documentation & Help
Dim As String filename = *zip_get_name(zip, i, 0) Print "file: " & filename & ", "; '' Retrieve the file size via a zip_stat(). Dim As zip_stat stat If (zip_stat_index(zip, i, 0, @stat)) Then Print "zip_stat() failed" Return End If If ((stat.valid And ZIP_STAT_SIZE) = 0) Then Print "could not ...
GitHub
github.com › winlibs › libzip
GitHub - winlibs/libzip: C library for reading, creating, and modifying zip archives · GitHub
libzip is fully documented via man pages. HTML versions of the man pages are on libzip.org and in the man directory. You can start with libzip(3), which lists all others. Example source code is in the examples and src subdirectories.
Starred by 10 users
Forked by 2 users
Languages C 89.8% | CMake 9.5%
Davidzchen
davidzchen.com › tech › 2020 › 08 › 03 › iterating-over-zip-file-entries-with-libzip.html
Iterating Over Zip File Entries with libzip - David Z. Chen
August 3, 2020 - libzip is one of the most full-featured and widely-used open source libraries for working with Zip arhives and has been adopted by numerous open source projects as well as commercial products. The library is implemented in C, which also makes it ideal for implementing language-specific bindings. While its documentation is very comprehensive, I find the descriptions of its various API’s to often be unclear, and there are no examples provided for how various common use cases could be implemented using the library.
FreshPorts
freshports.org › archivers › libzip
FreshPorts -- archivers/libzip: C library for reading, creating, and modifying ZIP archives
libzip is a C library for reading, creating, and modifying zip archives. Files can be added from data buffers, files, or compressed data copied directly from other zip archives. Changes made without closing the archive can be reverted. The API is documented by man pages.
