Libzip
libzip.org › documentation
Documentation · libzip
libzip - library for manipulating zip archives · zip — zip archive structure · zip_error — error information · zip_file — file in archive · zip_source — zip data source structure · zip_add — add file to zip archive or replace file in zip archive (obsolete interface) zip_add_dir — add directory to zip archive (obsolete interface) zip_close — close zip archive ·
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
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.
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
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%
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;
}
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.
Libzip
libzip.org › documentation › libzip.html
libzip · libzip
The zip format requires the use of forward slash (‘/’) as directory separator. Since backslash (‘\’) can be part of a valid file name on Unix systems, libzip does not automatically convert them, even on Windows.
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 ·
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
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.
FreeBASIC Wiki
freebasic.net › wiki › wikka.php
libzip - FreeBASIC Wiki Manual | FBWiki
'' .zip unpacking using libzip #include once "zip.bi" Sub create_parent_dirs(ByVal file As ZString Ptr) '' Given a path like this: '' foo/bar/baz/file.ext '' Do these mkdir()'s: '' foo '' foo/bar '' foo/bar/baz Dim As UByte Ptr p = file Do Select Case (*p) Case Asc("/") *p = 0 MkDir(*file) *p = Asc("/") Case 0 Exit Do End Select p += 1 Loop End Sub '' Asks libzip for information on file number 'i' in the .zip file, '' and then extracts it, while creating directories as needed.
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 › 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
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 ...
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.
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.
Cplusplus
cplusplus.com › forum › windows › 91350
[Solved] Trying to use libzip - C++ Forum
January 31, 2013 - Hi all! I am learning C++ and decided to make a little program to train me. It will be a program that zip/unzip files and moves them to another folder. I decided to use libzip. I compiled zlib and libzip with ./configure, make and make install in Cygwin. I linked libz.a, libzip.a and libzip.dll.a to my compiler and added the folder of zconf.h, zip.h, zlib.h and zipconf.h to the search directories.
GitHub
gist.github.com › a0255ebce3e3eec03e6878b47c8c7059
How to use libzip · GitHub
How to use libzip · Raw · libzipplayground.cpp · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ·
