2023-12-22 11:57:49 +00:00
|
|
|
// SPDX-FileCopyrightText: 2002-2023 PCSX2 Dev Team
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0+
|
2022-05-12 10:23:01 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/ProgressCallback.h"
|
|
|
|
|
2022-05-12 16:07:09 +00:00
|
|
|
#ifdef _WIN32
|
2022-05-12 10:23:01 +00:00
|
|
|
#include "7z.h"
|
|
|
|
#include "7zFile.h"
|
2022-05-12 16:07:09 +00:00
|
|
|
#endif
|
2022-05-12 10:23:01 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class Updater
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Updater(ProgressCallback* progress);
|
|
|
|
~Updater();
|
|
|
|
|
|
|
|
static void SetupLogging(ProgressCallback* progress, const std::string& destination_directory);
|
|
|
|
|
|
|
|
bool Initialize(std::string destination_directory);
|
|
|
|
|
|
|
|
bool OpenUpdateZip(const char* path);
|
|
|
|
bool PrepareStagingDirectory();
|
|
|
|
bool StageUpdate();
|
|
|
|
bool CommitUpdate();
|
|
|
|
void CleanupStagingDirectory();
|
2022-05-23 10:16:03 +00:00
|
|
|
void RemoveUpdateZip();
|
2022-05-12 10:23:01 +00:00
|
|
|
|
2022-12-04 06:13:00 +00:00
|
|
|
std::string FindPCSX2Exe() const;
|
|
|
|
|
2022-05-12 10:23:01 +00:00
|
|
|
private:
|
2024-04-04 12:18:17 +00:00
|
|
|
bool RecursiveDeleteDirectory(const char* path);
|
2022-05-12 10:23:01 +00:00
|
|
|
|
2022-05-23 10:16:03 +00:00
|
|
|
void CloseUpdateZip();
|
|
|
|
|
2022-05-12 10:23:01 +00:00
|
|
|
struct FileToUpdate
|
|
|
|
{
|
|
|
|
u32 file_index;
|
|
|
|
std::string destination_filename;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool ParseZip();
|
|
|
|
|
2022-05-23 10:16:03 +00:00
|
|
|
std::string m_zip_path;
|
2022-05-12 10:23:01 +00:00
|
|
|
std::string m_destination_directory;
|
|
|
|
std::string m_staging_directory;
|
|
|
|
|
|
|
|
std::vector<FileToUpdate> m_update_paths;
|
|
|
|
std::vector<std::string> m_update_directories;
|
|
|
|
|
|
|
|
ProgressCallback* m_progress;
|
2022-05-12 16:07:09 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2022-05-12 10:23:01 +00:00
|
|
|
CFileInStream m_archive_stream = {};
|
|
|
|
CLookToRead2 m_look_stream = {};
|
|
|
|
CSzArEx m_archive = {};
|
|
|
|
|
|
|
|
bool m_file_opened = false;
|
|
|
|
bool m_archive_opened = false;
|
2022-05-12 16:07:09 +00:00
|
|
|
#endif
|
2022-05-12 10:23:01 +00:00
|
|
|
};
|