Skip to content

Commit

Permalink
windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Jul 16, 2023
1 parent c0e8f45 commit 33b30b5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 34 deletions.
3 changes: 1 addition & 2 deletions src/decrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/xlcpp/cfbf.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <string>
#include <string_view>
#include <filesystem>
#include <string>
#include <vector>
#include <span>
#include <array>
Expand Down
14 changes: 1 addition & 13 deletions src/xlcpp/xlcpp-pimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,14 @@ 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<uint8_t> sv, std::string_view password, std::string_view outfile);
std::string data() const;

// void write_archive(struct archive* a) const;
// 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<uint8_t> sv, std::string_view password, std::string_view outfile);
};
Expand Down
21 changes: 5 additions & 16 deletions src/xlcpp/xlcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
#include <array>
#include <charconv>

// #ifdef _WIN32
#ifdef _WIN32
#include <stringapiset.h>
// #include <windows.h>
// #endif

// #define FMT_HEADER_ONLY
// #include <fmt/format.h>
// #include <fmt/compile.h>
#endif

#define BLOCK_SIZE 20480

Expand All @@ -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<xml_enc_string_view>& sv) {
// if (!sv)
// return "";
//
// return sv.value().decode();
// }

namespace xlcpp {

/* needed??? */
Expand Down Expand Up @@ -83,8 +73,7 @@ std::vector<uint8_t> 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;

Expand Down Expand Up @@ -148,7 +137,7 @@ void workbook_pimpl::load_from_memory(span<uint8_t> 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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/xlcpp/xlcpp.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <filesystem>
#include <string>
#include <chrono>
#include <string>
#include <list>
Expand Down Expand Up @@ -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<uint8_t> sv, std::string_view password = "", std::string_view outfile = "");
~workbook();

Expand Down

0 comments on commit 33b30b5

Please sign in to comment.