forked from len0rd/rockbox
zip: import initial module
This provides rudimentary support for parsing the contents of a ZIP file. For now this just supports uncompressed file entries but DEFLATE support is planned. This also only implements a low level public API so more work will be needed to make it usable by application code. Change-Id: Ia68b3078e5276666a0e5023f4bc7a9f94272738a
This commit is contained in:
parent
2acf8db3e1
commit
b87e75f768
3 changed files with 770 additions and 0 deletions
64
firmware/include/zip.h
Normal file
64
firmware/include/zip.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2021 by James Buren
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _ZIP_H_
|
||||
#define _ZIP_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
enum {
|
||||
ZIP_PASS_SHALLOW,
|
||||
ZIP_PASS_START,
|
||||
ZIP_PASS_DATA,
|
||||
ZIP_PASS_END,
|
||||
};
|
||||
|
||||
struct zip;
|
||||
|
||||
struct zip_args {
|
||||
uint16_t entry;
|
||||
uint16_t entries;
|
||||
char* name;
|
||||
uint32_t file_size;
|
||||
time_t modts;
|
||||
void* block;
|
||||
uint32_t block_size;
|
||||
uint32_t read_size;
|
||||
};
|
||||
|
||||
typedef int (*zip_callback) (const struct zip_args* args, int pass, void* ctx);
|
||||
|
||||
// open a handle for the given full file name path
|
||||
struct zip* zip_open(const char* name, bool try_mem);
|
||||
|
||||
// quick read of only directory index
|
||||
int zip_read_shallow(struct zip* z, zip_callback cb, void* ctx);
|
||||
|
||||
// slow read of whole archive
|
||||
// this can also pickup where a successful shallow read leftoff
|
||||
int zip_read_deep(struct zip* z, zip_callback cb, void* ctx);
|
||||
|
||||
// returns system resources
|
||||
void zip_close(struct zip* z);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue