mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
Report tool improvements (#8709)
* bugreport: move to tools * bugreport: skip packaging installers, format time with seconds, remove monitor-info-report tool * bugreport: move BugReportTool to Tools folder * fix CI * fix CDPX
This commit is contained in:
28
tools/BugReportTool/BugReportTool/ZipTools/zipfolder.cpp
Normal file
28
tools/BugReportTool/BugReportTool/ZipTools/zipfolder.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "zipfolder.h"
|
||||
#include "..\..\..\..\deps\cziplib\src\zip.h"
|
||||
|
||||
void zipFolder(std::filesystem::path zipPath, std::filesystem::path folderPath)
|
||||
{
|
||||
struct zip_t* zip = zip_open(zipPath.string().c_str(), ZIP_DEFAULT_COMPRESSION_LEVEL, 'w');
|
||||
if (!zip)
|
||||
{
|
||||
printf("Can not 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);
|
||||
}
|
||||
}
|
||||
|
||||
zip_close(zip);
|
||||
}
|
||||
4
tools/BugReportTool/BugReportTool/ZipTools/zipfolder.h
Normal file
4
tools/BugReportTool/BugReportTool/ZipTools/zipfolder.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
|
||||
void zipFolder(std::filesystem::path zipPath, std::filesystem::path folderPath);
|
||||
Reference in New Issue
Block a user