From 33b30b5e35e385236320c1aaaef97652b8ac5663 Mon Sep 17 00:00:00 2001 From: Jan Marvin Garbuszus Date: Mon, 17 Jul 2023 01:01:40 +0200 Subject: [PATCH] windows --- src/decrypt.cpp | 3 +-- src/xlcpp/cfbf.h | 2 +- src/xlcpp/xlcpp-pimpl.h | 14 +------------- src/xlcpp/xlcpp.cpp | 21 +++++---------------- src/xlcpp/xlcpp.h | 4 ++-- 5 files changed, 10 insertions(+), 34 deletions(-) diff --git a/src/decrypt.cpp b/src/decrypt.cpp index e0de3cd74..6063624e9 100644 --- a/src/decrypt.cpp +++ b/src/decrypt.cpp @@ -3,9 +3,8 @@ // [[Rcpp::export]] void read_encryption(std::string PATH, std::string OUT, std::string PASSWORD) { - const std::filesystem::path path = PATH; - xlcpp::workbook wb(path, PASSWORD, OUT); + xlcpp::workbook wb(PATH, PASSWORD, OUT); // this creates xlcpp workbook, not the unzipped xlsx file // wb.save(OUT); diff --git a/src/xlcpp/cfbf.h b/src/xlcpp/cfbf.h index 2100dafeb..1d309bd6c 100644 --- a/src/xlcpp/cfbf.h +++ b/src/xlcpp/cfbf.h @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/xlcpp/xlcpp-pimpl.h b/src/xlcpp/xlcpp-pimpl.h index 39431b29e..47e2e3f47 100644 --- a/src/xlcpp/xlcpp-pimpl.h +++ b/src/xlcpp/xlcpp-pimpl.h @@ -26,7 +26,7 @@ typedef struct { class workbook_pimpl { public: workbook_pimpl() = default; - workbook_pimpl(const std::filesystem::path& fn, std::string_view password, std::string_view outfile); + workbook_pimpl(std::string& fn, std::string_view password, std::string_view outfile); workbook_pimpl(std::span sv, std::string_view password, std::string_view outfile); std::string data() const; @@ -34,18 +34,6 @@ class workbook_pimpl { // la_ssize_t write_callback(struct archive* a, const void* buffer, size_t length) const; void load_archive(struct archive* a); -#ifdef _WIN32 - void rename(const std::filesystem::path& fn) const; -#endif - - mutable std::string buf; - -#ifdef _WIN32 - unique_handle h; - HANDLE h2; - uint8_t readbuf[1048576]; -#endif - private: void load_from_memory(std::span sv, std::string_view password, std::string_view outfile); }; diff --git a/src/xlcpp/xlcpp.cpp b/src/xlcpp/xlcpp.cpp index 50bc5d72a..27bcd039f 100644 --- a/src/xlcpp/xlcpp.cpp +++ b/src/xlcpp/xlcpp.cpp @@ -10,13 +10,10 @@ #include #include -// #ifdef _WIN32 +#ifdef _WIN32 +#include // #include -// #endif - -// #define FMT_HEADER_ONLY -// #include -// #include +#endif #define BLOCK_SIZE 20480 @@ -31,13 +28,6 @@ static const string NS_CONTENT_TYPES = "http://schemas.openxmlformats.org/packag #define NUMFMT_OFFSET 165 -// static string try_decode(const optional& sv) { -// if (!sv) -// return ""; -// -// return sv.value().decode(); -// } - namespace xlcpp { /* needed??? */ @@ -83,8 +73,7 @@ std::vector loadFile(const std::string& filename) { } } - -workbook_pimpl::workbook_pimpl(const filesystem::path& fn, string_view password, string_view outfile) { +workbook_pimpl::workbook_pimpl(string& fn, string_view password, string_view outfile) { std::string path = fn; @@ -148,7 +137,7 @@ void workbook_pimpl::load_from_memory(span mem, string_view password, s } -workbook::workbook(const filesystem::path& fn, std::string_view password, std::string_view outfile) { +workbook::workbook(string& fn, std::string_view password, std::string_view outfile) { impl = new workbook_pimpl(fn, password, outfile); } diff --git a/src/xlcpp/xlcpp.h b/src/xlcpp/xlcpp.h index 95f5b34bd..aee441495 100644 --- a/src/xlcpp/xlcpp.h +++ b/src/xlcpp/xlcpp.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -39,7 +39,7 @@ class sheet; class XLCPP workbook { public: workbook(); - workbook(const std::filesystem::path& fn, std::string_view password = "", std::string_view outfile = ""); + workbook(std::string& fn, std::string_view password = "", std::string_view outfile = ""); workbook(std::span sv, std::string_view password = "", std::string_view outfile = ""); ~workbook();