Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_zip.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
35
36#ifndef __NILOREA_ZIP__
37#define __NILOREA_ZIP__
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
47
48#include <stddef.h>
49#include <stdint.h>
50
52typedef struct N_ZIP_MEMBER {
54 unsigned method;
56 uint64_t compressed;
58 uint64_t size;
60 uint32_t crc;
62 uint64_t offset;
64
70int n_zip_find(const char* path, const char* name, N_ZIP_MEMBER* member);
71
78int n_zip_extract(const char* path, const char* name, const char* out);
79
87int n_zip_find_ending(const char* path, const char* ending, char* name, size_t name_len);
88
99int n_zip_read(const char* path, const char* name, size_t max_size, unsigned char** data, size_t* len);
100
104
105#ifdef __cplusplus
106}
107#endif
108
109#endif /* __NILOREA_ZIP__ */
uint64_t size
its size once out
Definition n_zip.h:58
uint64_t compressed
its size in the archive
Definition n_zip.h:56
uint32_t crc
its CRC-32
Definition n_zip.h:60
uint64_t offset
where its local header is
Definition n_zip.h:62
unsigned method
0 stored, 8 deflated
Definition n_zip.h:54
int n_zip_extract(const char *path, const char *name, const char *out)
write a member out to a file, checking its CRC-32
Definition n_zip.c:267
int n_zip_find(const char *path, const char *name, N_ZIP_MEMBER *member)
find a member by its full name in an archive's central directory
Definition n_zip.c:152
int n_zip_find_ending(const char *path, const char *ending, char *name, size_t name_len)
find the first member whose name ends with a given text, as a PyTorch checkpoint's "archive/data....
Definition n_zip.c:156
int n_zip_read(const char *path, const char *name, size_t max_size, unsigned char **data, size_t *len)
read a member into memory, checking its CRC-32
Definition n_zip.c:282
What n_zip_find() says about a member.
Definition n_zip.h:52