Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/updater/updater.h
7513 views
1
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <[email protected]>
2
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
3
4
#pragma once
5
6
#include "updater_progress_callback.h"
7
8
#include "unzip.h"
9
10
#include <string>
11
#include <vector>
12
13
class Updater
14
{
15
public:
16
explicit Updater(UpdaterProgressCallback* progress);
17
~Updater();
18
19
bool Initialize(std::string staging_directory, std::string destination_directory);
20
21
bool OpenUpdateZip(const char* path);
22
void RemoveUpdateZip();
23
bool PrepareStagingDirectory();
24
bool StageUpdate();
25
bool CommitUpdate();
26
void CleanupStagingDirectory();
27
bool ClearDestinationDirectory();
28
29
private:
30
bool RecursiveDeleteDirectory(const char* path, bool remove_dir);
31
32
struct FileToUpdate
33
{
34
std::string original_zip_filename;
35
std::string destination_filename;
36
u32 file_mode;
37
};
38
39
bool ParseZip();
40
void CloseUpdateZip();
41
42
std::string m_zip_path;
43
std::string m_staging_directory;
44
std::string m_destination_directory;
45
46
std::vector<FileToUpdate> m_update_paths;
47
std::vector<std::string> m_update_directories;
48
49
UpdaterProgressCallback* m_progress;
50
unzFile m_zf = nullptr;
51
};
52
53