Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/src/updater/updater.h
4243 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
#include "common/progress_callback.h"
6
#include "unzip.h"
7
#include <string>
8
#include <vector>
9
10
class Updater
11
{
12
public:
13
explicit Updater(ProgressCallback* progress);
14
~Updater();
15
16
bool Initialize(std::string staging_directory, std::string destination_directory);
17
18
bool OpenUpdateZip(const char* path);
19
void RemoveUpdateZip();
20
bool PrepareStagingDirectory();
21
bool StageUpdate();
22
bool CommitUpdate();
23
void CleanupStagingDirectory();
24
bool ClearDestinationDirectory();
25
26
private:
27
bool RecursiveDeleteDirectory(const char* path, bool remove_dir);
28
29
struct FileToUpdate
30
{
31
std::string original_zip_filename;
32
std::string destination_filename;
33
u32 file_mode;
34
};
35
36
bool ParseZip();
37
void CloseUpdateZip();
38
39
std::string m_zip_path;
40
std::string m_staging_directory;
41
std::string m_destination_directory;
42
43
std::vector<FileToUpdate> m_update_paths;
44
std::vector<std::string> m_update_directories;
45
46
ProgressCallback* m_progress;
47
unzFile m_zf = nullptr;
48
};
49
50