|
|
|
@ -81,15 +81,7 @@ Updater::Updater(ProgressCallback* progress)
|
|
|
|
|
|
|
|
|
|
Updater::~Updater() |
|
|
|
|
{ |
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
if (m_archive_opened) |
|
|
|
|
SzArEx_Free(&m_archive, &g_Alloc); |
|
|
|
|
|
|
|
|
|
ISzAlloc_Free(&g_Alloc, m_look_stream.buf); |
|
|
|
|
|
|
|
|
|
if (m_file_opened) |
|
|
|
|
File_Close(&m_archive_stream.file); |
|
|
|
|
#endif |
|
|
|
|
CloseUpdateZip(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Updater::SetupLogging(ProgressCallback* progress, const std::string& destination_directory) |
|
|
|
@ -123,6 +115,8 @@ bool Updater::OpenUpdateZip(const char* path)
|
|
|
|
|
LookToRead2_CreateVTable(&m_look_stream, False); |
|
|
|
|
CrcGenerateTable(); |
|
|
|
|
|
|
|
|
|
m_zip_path = path; |
|
|
|
|
|
|
|
|
|
m_look_stream.buf = (Byte*)ISzAlloc_Alloc(&g_Alloc, kInputBufSize); |
|
|
|
|
if (!m_look_stream.buf) |
|
|
|
|
{ |
|
|
|
@ -163,6 +157,29 @@ bool Updater::OpenUpdateZip(const char* path)
|
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Updater::CloseUpdateZip() |
|
|
|
|
{ |
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
if (m_archive_opened) |
|
|
|
|
{ |
|
|
|
|
SzArEx_Free(&m_archive, &g_Alloc); |
|
|
|
|
m_archive_opened = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (m_look_stream.buf) |
|
|
|
|
{ |
|
|
|
|
ISzAlloc_Free(&g_Alloc, m_look_stream.buf); |
|
|
|
|
m_look_stream.buf = nullptr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (m_file_opened) |
|
|
|
|
{ |
|
|
|
|
File_Close(&m_archive_stream.file); |
|
|
|
|
m_file_opened = false; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Updater::RecursiveDeleteDirectory(const char* path) |
|
|
|
|
{ |
|
|
|
|
#ifdef _WIN32 |
|
|
|
@ -404,3 +421,14 @@ void Updater::CleanupStagingDirectory()
|
|
|
|
|
if (!RecursiveDeleteDirectory(m_staging_directory.c_str())) |
|
|
|
|
m_progress->DisplayFormattedError("Failed to remove staging directory '%s'", m_staging_directory.c_str()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Updater::RemoveUpdateZip() |
|
|
|
|
{ |
|
|
|
|
if (m_zip_path.empty()) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
CloseUpdateZip(); |
|
|
|
|
|
|
|
|
|
if (!FileSystem::DeleteFilePath(m_zip_path.c_str())) |
|
|
|
|
m_progress->DisplayFormattedError("Failed to remove update zip '%s'", m_zip_path.c_str()); |
|
|
|
|
} |
|
|
|
|