feat: Move all internal structures to a minitar_entry_internal struct
This commit is contained in:
parent
07c156c30b
commit
dead1e3ee2
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.8..3.22)
|
||||
|
||||
project(minitar LANGUAGES C VERSION 1.3.1)
|
||||
project(minitar LANGUAGES C VERSION 1.4.0)
|
||||
|
||||
option(MINITAR_IGNORE_UNSUPPORTED_TYPES "Skip past entries that have unsupported types instead of panicking" OFF)
|
||||
|
||||
|
@ -109,4 +109,4 @@ An entry in a tar archive. Fields:
|
||||
|
||||
`metadata`: The entry's metadata. (`struct minitar_entry_metadata`)
|
||||
|
||||
`position`: Reserved for internal use. (`fpos_t`)
|
||||
`_internal`: Reserved for internal use. (`struct minitar_entry_internal`)
|
@ -14,6 +14,11 @@ enum minitar_file_type
|
||||
MTAR_DIRECTORY
|
||||
};
|
||||
|
||||
struct minitar_entry_internal
|
||||
{
|
||||
fpos_t _mt_position;
|
||||
};
|
||||
|
||||
struct minitar_entry_metadata
|
||||
{
|
||||
char path[257];
|
||||
@ -31,7 +36,7 @@ struct minitar_entry_metadata
|
||||
struct minitar_entry
|
||||
{
|
||||
struct minitar_entry_metadata metadata;
|
||||
fpos_t position;
|
||||
struct minitar_entry_internal _internal;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -42,7 +42,7 @@ static int minitar_try_to_read_valid_entry(struct minitar* mp, struct minitar_en
|
||||
|
||||
// Fetch the current read position (which is currently pointing to the start of the entry's contents), so we can
|
||||
// return back to it when reading the contents of this entry using minitar_read_contents().
|
||||
if (fgetpos(mp->stream, &out->position)) return -1;
|
||||
if (fgetpos(mp->stream, &out->_internal._mt_position)) return -1;
|
||||
|
||||
minitar_parse_metadata_from_tar_header(&hdr, &out->metadata);
|
||||
if (out->metadata.size)
|
||||
@ -121,7 +121,7 @@ size_t minitar_read_contents(struct minitar* mp, struct minitar_entry* entry, ch
|
||||
// Save the current position
|
||||
if (fgetpos(mp->stream, ¤t_position)) return 0;
|
||||
// Move to the position stored in the entry
|
||||
if (fsetpos(mp->stream, &entry->position)) return 0;
|
||||
if (fsetpos(mp->stream, &entry->_internal._mt_position)) return 0;
|
||||
|
||||
// We refuse to read more than the size indicated by the archive
|
||||
if (max > entry->metadata.size) max = entry->metadata.size;
|
||||
|
Loading…
Reference in New Issue
Block a user