duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

updater.h (1127B)


      1 // SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
      2 // SPDX-License-Identifier: (GPL-3.0 OR 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   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 };