From dead1e3ee2d8d575ea859f55a537e5ad216ea745 Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 12 Jan 2023 19:20:32 +0100 Subject: [PATCH] feat: Move all internal structures to a minitar_entry_internal struct --- CMakeLists.txt | 2 +- docs/API.md | 2 +- minitar.h | 7 ++++++- src/tar.c | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eb573f..a96a07f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/docs/API.md b/docs/API.md index 0d087b6..21c917f 100644 --- a/docs/API.md +++ b/docs/API.md @@ -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`) \ No newline at end of file +`_internal`: Reserved for internal use. (`struct minitar_entry_internal`) \ No newline at end of file diff --git a/minitar.h b/minitar.h index 5339472..0c96d0d 100644 --- a/minitar.h +++ b/minitar.h @@ -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 diff --git a/src/tar.c b/src/tar.c index 81ef4e2..a5b6570 100644 --- a/src/tar.c +++ b/src/tar.c @@ -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;