summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-08-09 22:52:49 +0200
committerAki <please@ignore.pl>2022-08-09 22:52:49 +0200
commita88cfc3a560f372f5abcff09fcbf8393c1f0bd55 (patch)
tree65e30320c3329c3c14bcb900a49936292ea0fee8
parentf5851278765e468f7fe04f943b8d69021e22e004 (diff)
downloadstarshatter-a88cfc3a560f372f5abcff09fcbf8393c1f0bd55.zip
starshatter-a88cfc3a560f372f5abcff09fcbf8393c1f0bd55.tar.gz
starshatter-a88cfc3a560f372f5abcff09fcbf8393c1f0bd55.tar.bz2
Cleaned-up selected parts of newly added code
-rw-r--r--ArchiveEx/Archive.cpp14
-rw-r--r--ArchiveEx/Archive.h2
2 files changed, 7 insertions, 9 deletions
diff --git a/ArchiveEx/Archive.cpp b/ArchiveEx/Archive.cpp
index 2e3aa52..134404c 100644
--- a/ArchiveEx/Archive.cpp
+++ b/ArchiveEx/Archive.cpp
@@ -16,13 +16,15 @@ namespace Archive
using UniqueFileHandle = std::unique_ptr<std::FILE, decltype(&std::fclose)>;
-static constexpr std::size_t DIRECTORY_MARGIN {64};
-
-
static inline std::size_t BytesToBlocks(std::size_t bytes);
static inline std::size_t ConvertPathSeparator(const char* src, char* dest);
+static constexpr std::uint32_t VERSION {0x0010};
+static constexpr std::size_t BLOCK_SIZE {1024};
+static constexpr std::size_t DIRECTORY_MARGIN {64};
+
+
Archive::Archive(const char* p) :
path {p},
header {},
@@ -70,13 +72,11 @@ Archive::Expand(const int index, std::uint8_t*& buffer, const bool null_terminat
int err = std::fseek(file.get(), sizeof(Header) + entry.offset, SEEK_SET);
if (-1 == err)
return -1;
- std::size_t length = std::fread(compressed.data(), 1, entry.compressed_size, file.get());
+ const std::size_t length = std::fread(compressed.data(), 1, entry.compressed_size, file.get());
if (entry.compressed_size != length)
return -1;
uLongf output_length = entry.original_size + static_cast<uLongf>(null_terminated);
- std::unique_ptr<std::uint8_t[]> uncompressed(new std::uint8_t[output_length]);
- if (!uncompressed)
- return -1;
+ auto uncompressed = std::make_unique<std::uint8_t[]>(output_length);
err = uncompress(uncompressed.get(), &output_length, compressed.data(), entry.compressed_size);
if (Z_OK != err)
return -1;
diff --git a/ArchiveEx/Archive.h b/ArchiveEx/Archive.h
index 0f1be0c..cbaf571 100644
--- a/ArchiveEx/Archive.h
+++ b/ArchiveEx/Archive.h
@@ -9,8 +9,6 @@ namespace Archive
{
-static constexpr std::uint32_t VERSION {0x0010};
-static constexpr std::size_t BLOCK_SIZE {1024};
static constexpr std::size_t NAMELEN {64};