diff --git a/lib/libimhex/include/hex/helpers/tar.hpp b/lib/libimhex/include/hex/helpers/tar.hpp index 888000bfb..2613449fd 100644 --- a/lib/libimhex/include/hex/helpers/tar.hpp +++ b/lib/libimhex/include/hex/helpers/tar.hpp @@ -42,6 +42,7 @@ namespace hex { private: mtar_t m_ctx = { }; + std::fs::path m_path; bool m_valid = false; }; diff --git a/lib/libimhex/source/helpers/tar.cpp b/lib/libimhex/source/helpers/tar.cpp index 58776929f..d76efe988 100644 --- a/lib/libimhex/source/helpers/tar.cpp +++ b/lib/libimhex/source/helpers/tar.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include @@ -27,6 +28,7 @@ namespace hex { else error = MTAR_EFAILURE; + this->m_path = path; this->m_valid = (error == MTAR_ESUCCESS); } @@ -36,6 +38,7 @@ namespace hex { Tar::Tar(hex::Tar &&other) noexcept { this->m_ctx = other.m_ctx; + this->m_path = other.m_path; this->m_valid = other.m_valid; other.m_ctx = { }; @@ -46,6 +49,8 @@ namespace hex { this->m_ctx = other.m_ctx; other.m_ctx = { }; + this->m_path = other.m_path; + this->m_valid = other.m_valid; other.m_valid = false; @@ -91,8 +96,13 @@ namespace hex { #if defined(OS_WINDOWS) std::replace(fixedPath.begin(), fixedPath.end(), '\\', '/'); #endif - mtar_find(&this->m_ctx, fixedPath.c_str(), &header); - + int ret = mtar_find(&this->m_ctx, fixedPath.c_str(), &header); + if(ret != MTAR_ESUCCESS){ + log::debug("Failed to read vector from path {} in tarred file {}: {}", + path.string(), this->m_path.string(), mtar_strerror(ret)); + return {}; + } + std::vector result(header.size, 0x00); mtar_read_data(&this->m_ctx, result.data(), result.size());