diff --git a/.gitmodules b/.gitmodules
index 1601291341..f878c1a9e3 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,6 +4,3 @@
[submodule "deps/expected-lite"]
path = deps/expected-lite
url = https://github.com/martinmoene/expected-lite.git
-[submodule "deps/cziplib"]
- path = deps/cziplib
- url = https://github.com/kuba--/zip.git
diff --git a/Cpp.Build.props b/Cpp.Build.props
index 5a4538f940..f146a4d770 100644
--- a/Cpp.Build.props
+++ b/Cpp.Build.props
@@ -26,6 +26,7 @@
true
$(MsbuildThisFileDirectory)\CppRuleSet.ruleset
+ $(MSBuildThisFileDirectory)deps;$(MSBuildThisFileDirectory)packages;$(CAExcludePath)
@@ -34,7 +35,7 @@
arm64
false
true
- $(MSBuildThisFileFullPath)\..\deps\;$(MSBuildThisFileFullPath)\..\packages\;$(ExternalIncludePath)
+ $(MSBuildThisFileDirectory)deps;$(MSBuildThisFileDirectory)packages;$(ExternalIncludePath)
Guard
diff --git a/deps/cziplib b/deps/cziplib
deleted file mode 160000
index 81314fff0a..0000000000
--- a/deps/cziplib
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 81314fff0a882b72a9ad321e7a3311660125b56e
diff --git a/tools/BugReportTool/BugReportTool/BugReportTool.vcxproj b/tools/BugReportTool/BugReportTool/BugReportTool.vcxproj
index 734146a663..f56b2646b4 100644
--- a/tools/BugReportTool/BugReportTool/BugReportTool.vcxproj
+++ b/tools/BugReportTool/BugReportTool/BugReportTool.vcxproj
@@ -30,6 +30,7 @@
NotUsing
../../../src/
+ true
Console
@@ -37,10 +38,6 @@
-
-
- 4706;26451;4267;4244;%(DisableSpecificWarnings)
-
@@ -61,8 +58,6 @@
-
-
diff --git a/tools/BugReportTool/BugReportTool/BugReportTool.vcxproj.filters b/tools/BugReportTool/BugReportTool/BugReportTool.vcxproj.filters
index 0723bd31ac..f8117733d9 100644
--- a/tools/BugReportTool/BugReportTool/BugReportTool.vcxproj.filters
+++ b/tools/BugReportTool/BugReportTool/BugReportTool.vcxproj.filters
@@ -8,7 +8,6 @@
ZipTools
-
@@ -28,8 +27,6 @@
ZipTools
-
-
diff --git a/tools/BugReportTool/BugReportTool/ZipTools/zipfolder.cpp b/tools/BugReportTool/BugReportTool/ZipTools/zipfolder.cpp
index 6b5f4f0180..476707bd67 100644
--- a/tools/BugReportTool/BugReportTool/ZipTools/zipfolder.cpp
+++ b/tools/BugReportTool/BugReportTool/ZipTools/zipfolder.cpp
@@ -1,50 +1,53 @@
#include "ZipFolder.h"
-#include "..\..\..\..\deps\cziplib\src\zip.h"
#include
+#define WIN32_LEAN_AND_MEAN
+#include
+
+#include
+#include
+#include
+
void ZipFolder(std::filesystem::path zipPath, std::filesystem::path folderPath)
{
- std::string reportFilename{ "PowerToysReport_" };
- reportFilename += timeutil::format_as_local("%F-%H-%M-%S", timeutil::now());
- reportFilename += ".zip";
+ const auto reportFilename{
+ std::format("PowerToysReport_{0}.zip",
+ timeutil::format_as_local("%F-%H-%M-%S", timeutil::now()))
+ };
+ const auto finalReportFullPath{ zipPath / reportFilename };
- auto tmpZipPath = std::filesystem::temp_directory_path();
- tmpZipPath /= reportFilename;
+ const auto tempReportFilename{ reportFilename + ".tmp" };
+ const auto tempReportFullPath{ zipPath / tempReportFilename };
- struct zip_t* zip = zip_open(tmpZipPath.string().c_str(), ZIP_DEFAULT_COMPRESSION_LEVEL, 'w');
- if (!zip)
+ // tar -c --format=zip -f "ReportFile.zip" *
+ const auto executable{ wil::ExpandEnvironmentStringsW(LR"(%WINDIR%\System32\tar.exe)") };
+ auto commandline{ std::format(LR"("{0}" -c --format=zip -f "{1}" *)", executable, tempReportFullPath.wstring()) };
+
+ const auto folderPathAsString{ folderPath.lexically_normal().wstring() };
+
+ wil::unique_process_information pi;
+ STARTUPINFOW si{ .cb = sizeof(STARTUPINFOW) };
+ if (!CreateProcessW(executable.c_str(),
+ commandline.data() /* must be mutable */,
+ nullptr,
+ nullptr,
+ FALSE,
+ DETACHED_PROCESS,
+ nullptr,
+ folderPathAsString.c_str(),
+ &si,
+ &pi))
{
printf("Cannot open zip.");
throw -1;
}
- using recursive_directory_iterator = std::filesystem::recursive_directory_iterator;
- const size_t rootSize = folderPath.wstring().size();
- for (const auto& dirEntry : recursive_directory_iterator(folderPath))
- {
- if (dirEntry.is_regular_file())
- {
- auto path = dirEntry.path().string();
- auto relativePath = path.substr(rootSize, path.size());
- zip_entry_open(zip, relativePath.c_str());
- zip_entry_fwrite(zip, path.c_str());
- zip_entry_close(zip);
- }
- }
+ WaitForSingleObject(pi.hProcess, INFINITE);
- zip_close(zip);
-
- std::error_code err;
- std::filesystem::copy(tmpZipPath, zipPath, err);
+ std::error_code err{};
+ std::filesystem::rename(tempReportFullPath, finalReportFullPath, err);
if (err.value() != 0)
{
- wprintf_s(L"Failed to copy %s. Error code: %d\n", tmpZipPath.c_str(), err.value());
+ wprintf_s(L"Failed to rename %s. Error code: %d\n", tempReportFullPath.native().c_str(), err.value());
}
-
- err = {};
- std::filesystem::remove_all(tmpZipPath, err);
- if (err.value() != 0)
- {
- wprintf_s(L"Failed to delete %s. Error code: %d\n", tmpZipPath.c_str(), err.value());
- }
-}
\ No newline at end of file
+}