#pragma once #include #include class PatchExtractor { public: static constexpr const char* PATCHES_ZIP = "sdmc:/SaltySD/plugins/FPSLocker/patches.zip"; static constexpr const char* EXTRACT_DIR = "sdmc:/SaltySD/plugins/FPSLocker/"; static constexpr const char* SELF_NRO = "sdmc:/switch/PatchExtractor.nro"; bool open(); void close(); /** Process one zip entry. Returns false when finished or on fatal error. */ bool step(); bool isOpen() const { return zip != nullptr; } unsigned long getTotal() const { return total; } unsigned long getExtracted() const { return extracted; } unsigned long getSkipped() const { return skipped; } int getProgressPercent() const; const std::string& getCurrentFile() const { return currentFile; } bool isFinished() const { return finished; } bool cleanup(); bool cleanupOk() const { return cleanupOk_; } /** Call after the UI has shut down; releases romfs so the NRO file can be unlinked. */ static void tryDeleteSelfOnExit(); private: static int mkdirs(const char* path); unzFile zip = nullptr; unsigned long total = 0; unsigned long extracted = 0; unsigned long skipped = 0; int err = UNZ_OK; bool finished = false; bool cleanupOk_ = true; std::string currentFile; };