Skip to content

Commit

Permalink
SporeModManager: make std::vector<char>() buffers static
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Nov 20, 2023
1 parent 3fa3a86 commit 0b27418
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions SporeModManager/SporeModManagerHelpers/Zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool Zip::CloseFile(ZipFile zipFile)

bool Zip::ExtractFile(ZipFile zipFile, std::filesystem::path file, std::filesystem::path outputFile)
{
std::vector<char> buffer(UNZIP_READ_SIZE);
static std::vector<char> buffer(UNZIP_READ_SIZE);
int bytesRead = 0;
std::ofstream outputFileStream;

Expand Down Expand Up @@ -166,8 +166,10 @@ bool Zip::ExtractFile(ZipFile zipFile, std::filesystem::path file, std::filesyst
std::cerr << "unzReadCurrentFile() Failed: " << std::to_string(bytesRead) << std::endl;
return false;
}

outputFileStream.write(buffer.data(), bytesRead);
else if (bytesRead > 0)
{
outputFileStream.write(buffer.data(), bytesRead);
}
} while (bytesRead > 0);

unzCloseCurrentFile(zipFile);
Expand All @@ -178,7 +180,7 @@ bool Zip::ExtractFile(ZipFile zipFile, std::filesystem::path file, std::filesyst

bool Zip::ExtractFile(ZipFile zipFile, std::filesystem::path file, std::vector<char>& outBuffer)
{
std::vector<char> buffer(UNZIP_READ_SIZE);
static std::vector<char> buffer(UNZIP_READ_SIZE);
int bytesRead = 0;

// try to find file in zip
Expand Down

0 comments on commit 0b27418

Please sign in to comment.