Warning, file /graphics/peruse/src/qtquick/karchive-rar/unarr/unarr.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* Copyright 2015 the unarr project authors (see AUTHORS file).
0002    License: LGPLv3 */
0003 
0004 #ifndef unarr_h
0005 #define unarr_h
0006 
0007 #include <stddef.h>
0008 #include <stdint.h>
0009 #include <stdbool.h>
0010 typedef int64_t off64_t;
0011 typedef int64_t time64_t;
0012 
0013 #define UNARR_API_VERSION 100
0014 
0015 /***** common/stream *****/
0016 
0017 typedef struct ar_stream_s ar_stream;
0018 
0019 /* opens a read-only stream for the given file path; returns NULL on error */
0020 ar_stream *ar_open_file(const char *path);
0021 #ifdef _WIN32
0022 ar_stream *ar_open_file_w(const wchar_t *path);
0023 #endif
0024 /* opens a read-only stream for the given chunk of memory; the pointer must be valid until ar_close is called */
0025 ar_stream *ar_open_memory(const void *data, size_t datalen);
0026 #ifdef _WIN32
0027 typedef struct IStream IStream;
0028 /* opens a read-only stream based on the given IStream */
0029 ar_stream *ar_open_istream(IStream *stream);
0030 #endif
0031 
0032 /* closes the stream and releases underlying resources */
0033 void ar_close(ar_stream *stream);
0034 /* tries to read 'count' bytes into buffer, advancing the read offset pointer; returns the actual number of bytes read */
0035 size_t ar_read(ar_stream *stream, void *buffer, size_t count);
0036 /* moves the read offset pointer (same as fseek); returns false on failure */
0037 bool ar_seek(ar_stream *stream, off64_t offset, int origin);
0038 /* shortcut for ar_seek(stream, count, SEEK_CUR); returns false on failure */
0039 bool ar_skip(ar_stream *stream, off64_t count);
0040 /* returns the current read offset (or 0 on error) */
0041 off64_t ar_tell(ar_stream *stream);
0042 
0043 /***** common/unarr *****/
0044 
0045 typedef struct ar_archive_s ar_archive;
0046 
0047 /* frees all data stored for the given archive; does not close the underlying stream */
0048 void ar_close_archive(ar_archive *ar);
0049 /* reads the next archive entry; returns false on error or at the end of the file (use ar_at_eof to distinguish the two cases) */
0050 bool ar_parse_entry(ar_archive *ar);
0051 /* reads the archive entry at the given offset as returned by ar_entry_get_offset (offset 0 always restarts at the first entry); should always succeed */
0052 bool ar_parse_entry_at(ar_archive *ar, off64_t offset);
0053 /* reads the (first) archive entry associated with the given name; returns false if the entry couldn't be found */
0054 bool ar_parse_entry_for(ar_archive *ar, const char *entry_name);
0055 /* returns whether the last ar_parse_entry call has reached the file's expected end */
0056 bool ar_at_eof(ar_archive *ar);
0057 
0058 /* returns the name of the current entry as UTF-8 string; this pointer is only valid until the next call to ar_parse_entry; returns NULL on failure */
0059 const char *ar_entry_get_name(ar_archive *ar);
0060 /* returns the stream offset of the current entry for use with ar_parse_entry_at */
0061 off64_t ar_entry_get_offset(ar_archive *ar);
0062 /* returns the total size of uncompressed data of the current entry; read exactly that many bytes using ar_entry_uncompress */
0063 size_t ar_entry_get_size(ar_archive *ar);
0064 /* returns the stored modification date of the current entry in 100ns since 1601/01/01 */
0065 time64_t ar_entry_get_filetime(ar_archive *ar);
0066 /* WARNING: don't manually seek in the stream between ar_parse_entry and the last corresponding ar_entry_uncompress call! */
0067 /* uncompresses the next 'count' bytes of the current entry into buffer; returns false on error */
0068 bool ar_entry_uncompress(ar_archive *ar, void *buffer, size_t count);
0069 
0070 /* copies at most 'count' bytes of the archive's global comment (if any) into buffer; returns the actual amount of bytes copied (or, if 'buffer' is NULL, the required buffer size) */
0071 size_t ar_get_global_comment(ar_archive *ar, void *buffer, size_t count);
0072 
0073 /***** rar/rar *****/
0074 
0075 /* checks whether 'stream' could contain RAR data and prepares for archive listing/extraction; returns NULL on failure */
0076 ar_archive *ar_open_rar_archive(ar_stream *stream);
0077 
0078 /***** tar/tar *****/
0079 
0080 /* checks whether 'stream' could contain TAR data and prepares for archive listing/extraction; returns NULL on failure */
0081 ar_archive *ar_open_tar_archive(ar_stream *stream);
0082 
0083 /***** zip/zip *****/
0084 
0085 /* checks whether 'stream' could contain ZIP data and prepares for archive listing/extraction; returns NULL on failure */
0086 /* set deflatedonly for extracting XPS, EPUB, etc. documents where non-Deflate compression methods are not supported by specification */
0087 ar_archive *ar_open_zip_archive(ar_stream *stream, bool deflatedonly);
0088 
0089 /***** _7z/_7z *****/
0090 
0091 /* checks whether 'stream' could contain 7Z data and prepares for archive listing/extraction; returns NULL on failure */
0092 ar_archive *ar_open_7z_archive(ar_stream *stream);
0093 
0094 #endif