Skip to content

Commit

Permalink
Avoid scary implicit conversion from sexp to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed Aug 23, 2024
1 parent 35a1905 commit d4dd17c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

#include "rapidxml/rapidxml_print.h"

#include "cpp11/as.hpp"
#include "cpp11/function.hpp"
#include "cpp11/raws.hpp"
#include "cpp11/sexp.hpp"

std::string zip_buffer(const std::string& zip_path,
const std::string& file_path) {
Expand All @@ -19,7 +21,8 @@ std::string zip_buffer(const std::string& zip_path,
bool zip_has_file(const std::string& zip_path,
const std::string& file_path) {
cpp11::function zip_has_file = cpp11::package("readxl")["zip_has_file"];
return zip_has_file(zip_path, file_path);
cpp11::sexp out = zip_has_file(zip_path, file_path);
return cpp11::as_cpp<bool>(out);
}

std::string xml_print(std::string xml) {
Expand Down

0 comments on commit d4dd17c

Please sign in to comment.