Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,710 changes: 5,710 additions & 0 deletions 3rdParty/miniz-cpp/zip_file.hpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions SerialPrograms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ function(apply_common_target_properties target_name)
target_link_directories(${target_name} PRIVATE ../3rdPartyBinaries/)
endfunction()


# Apply common properties to both targets
apply_common_target_properties(SerialProgramsLib)
apply_common_target_properties(SerialPrograms)
Expand Down
45 changes: 45 additions & 0 deletions SerialPrograms/Source/CommonFramework/Tools/FileUnzip.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* File Unzip
*
* From: https://github.com/PokemonAutomation/
*
*/

#include "miniz-cpp/zip_file.hpp"
#include "FileUnzip.h"
#include <filesystem>

#include <iostream>
using std::cout;
using std::endl;

namespace PokemonAutomation{

void unzip_file(const std::string& zip_path, const std::string& output_dir) {
cout << "try to unzip the file." << endl;
miniz_cpp::zip_file archive(zip_path);

// create folder structure before extracting.
// since miniz-cpp does not automatically create subdirectories if they exist within the zip archive
std::vector<miniz_cpp::zip_info> const info_list = archive.infolist();
auto const current_directory = std::filesystem::current_path();
std::error_code ec{};
for(miniz_cpp::zip_info const & info: info_list ){
std::filesystem::path const p{(std::filesystem::path(output_dir) / info.filename).parent_path()};
// Create the entire directory tree for this file
std::filesystem::create_directories(p, ec);

if (ec) {
std::cerr << "Error creating " << p << ": " << ec.message() << std::endl;
ec.clear();
}
}

// Extract all files to the specified path
archive.extractall(output_dir);

cout << "done unzipping the file." << endl;

}


}
17 changes: 17 additions & 0 deletions SerialPrograms/Source/CommonFramework/Tools/FileUnzip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* File Unzip
*
* From: https://github.com/PokemonAutomation/
*
*/

#ifndef PokemonAutomation_FileUnzip_H
#define PokemonAutomation_FileUnzip_H

#include <string>

namespace PokemonAutomation{

void unzip_file(const std::string& zip_path, const std::string& output_dir);

}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
#include "Common/Cpp/Sockets/ClientSocket.h"
#include "Common/Cpp/Containers/SparseArray.h"
#include "CommonFramework/Tools/GlobalThreadPools.h"
#include "CommonFramework/Tools/FileUnzip.h"

#ifdef PA_ARCH_x86
//#include "Kernels/Kernels_x64_SSE41.h"
Expand Down Expand Up @@ -345,7 +346,6 @@ void stress_test(Logger& logger, CancellableScope& scope){




void TestProgramComputer::program(ProgramEnvironment& env, CancellableScope& scope){
using namespace Kernels;
using namespace NintendoSwitch;
Expand All @@ -358,7 +358,15 @@ void TestProgramComputer::program(ProgramEnvironment& env, CancellableScope& sco

[[maybe_unused]] Logger& logger = env.logger();


#if 1
unzip_file(SETTINGS_PATH() + "test2.zip", SETTINGS_PATH() + "testB/");

#endif

#if 0
stress_test(logger, scope);
#endif

#if 0
{
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/cmake/SourceFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ file(GLOB LIBRARY_SOURCES
Source/CommonFramework/Tools/ErrorDumper.h
Source/CommonFramework/Tools/FileDownloader.cpp
Source/CommonFramework/Tools/FileDownloader.h
Source/CommonFramework/Tools/FileUnzip.cpp
Source/CommonFramework/Tools/FileUnzip.h
Source/CommonFramework/Tools/GlobalThreadPools.cpp
Source/CommonFramework/Tools/GlobalThreadPools.h
Source/CommonFramework/Tools/ProgramEnvironment.cpp
Expand Down