Merge pull request #1074 from haverland/rolling

Release creation like CaCo3's update-ota2
This commit is contained in:
jomjol
2022-09-25 18:27:28 +02:00
committed by GitHub
4 changed files with 156 additions and 114 deletions

View File

@@ -752,57 +752,59 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
mz_zip_archive_file_stat file_stat;
mz_zip_reader_file_stat(&zip_archive, i, &file_stat);
sprintf(archive_filename, file_stat.m_filename);
if (!file_stat.m_is_directory) {
// Try to extract all the files to the heap.
p = mz_zip_reader_extract_file_to_heap(&zip_archive, archive_filename, &uncomp_size, 0);
if (!p)
{
printf("mz_zip_reader_extract_file_to_heap() failed!\n");
mz_zip_reader_end(&zip_archive);
return ret;
}
// Save to File.
zw = std::string(archive_filename);
if (toUpper(zw) == "FIRMWARE.BIN")
{
zw = _target_bin + zw;
ret = zw;
}
else
{
std::string _dir = getDirectory(zw);
if (_dir.length() > 0)
if (!p)
{
zw = _main + zw;
printf("mz_zip_reader_extract_file_to_heap() failed on file %s\n", archive_filename);
mz_zip_reader_end(&zip_archive);
return ret;
}
// Save to File.
zw = std::string(archive_filename);
if (toUpper(zw) == "FIRMWARE.BIN")
{
zw = _target_bin + zw;
ret = zw;
}
else
{
zw = _target_zip + zw;
std::string _dir = getDirectory(zw);
if (_dir.length() > 0)
{
zw = _main + zw;
}
else
{
zw = _target_zip + zw;
}
}
string filename_zw = zw + SUFFIX_ZW;
printf("Filename to extract: %s, Zwischenfilename: %s", zw.c_str(), filename_zw.c_str());
// extrahieren in zwischendatei
DeleteFile(filename_zw);
FILE* fpTargetFile = OpenFileAndWait(filename_zw.c_str(), "wb");
fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
fclose(fpTargetFile);
DeleteFile(zw);
RenameFile(filename_zw, zw);
DeleteFile(filename_zw);
printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
// printf("File data: \"%s\"\n", (const char*)p);
// We're done.
mz_free(p);
}
string filename_zw = zw + SUFFIX_ZW;
printf("Filename to extract: %s, Zwischenfilename: %s", zw.c_str(), filename_zw.c_str());
// extrahieren in zwischendatei
DeleteFile(filename_zw);
FILE* fpTargetFile = OpenFileAndWait(filename_zw.c_str(), "wb");
fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
fclose(fpTargetFile);
DeleteFile(zw);
RenameFile(filename_zw, zw);
DeleteFile(filename_zw);
printf("Successfully extracted file \"%s\", size %u\n", archive_filename, (uint)uncomp_size);
// printf("File data: \"%s\"\n", (const char*)p);
// We're done.
mz_free(p);
}
// Close the archive, freeing any resources it was using