Initialize the variables where they're needed.

This commit is contained in:
tastytea 2021-05-21 07:05:44 +02:00
parent 354583bcbd
commit a941bcced3
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 4 additions and 7 deletions

View File

@ -35,22 +35,19 @@ using fmt::format;
std::vector<std::string> list(const fs::path &filepath)
{
struct archive *zipfile{};
struct archive_entry *entry{};
int result{};
std::vector<std::string> toc;
zipfile = archive_read_new();
auto *zipfile{archive_read_new()};
archive_read_support_filter_all(zipfile);
archive_read_support_format_all(zipfile);
result = archive_read_open_filename(zipfile, filepath.c_str(), 10240);
auto result{archive_read_open_filename(zipfile, filepath.c_str(), 10240)};
if (result != ARCHIVE_OK)
{
throw exception{format(translate("Could not open {0:s}.").str(),
filepath.string())};
}
struct archive_entry *entry{};
std::vector<std::string> toc;
while (archive_read_next_header(zipfile, &entry) == ARCHIVE_OK)
{
toc.emplace_back(archive_entry_pathname(entry));