diff --git a/.gitignore b/.gitignore index 77a9d60..68f16da 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,6 @@ GRTAGS /src/Makevars /.lintr *.idx +/config.log +/config.status /compile_commands.json diff --git a/inst/include/highfive/bits/H5File_misc.hpp b/inst/include/highfive/bits/H5File_misc.hpp index 82cea7d..17c69b2 100644 --- a/inst/include/highfive/bits/H5File_misc.hpp +++ b/inst/include/highfive/bits/H5File_misc.hpp @@ -14,10 +14,7 @@ #include #include - -using Path = std::filesystem::path; -Path expand (Path in); - +#include "path.hpp" namespace HighFive { @@ -65,7 +62,7 @@ inline File::File(const std::string& filename, int openFlags, struct stat buffer; - const bool file_exists = std::filesystem::exists(_filename); + const bool file_exists = exists(_filename); if(file_exists){ if(!(openFlags & File::Truncate)){ diff --git a/inst/include/highfive/bits/H5Node_traits.hpp b/inst/include/highfive/bits/H5Node_traits.hpp index 41e0dc8..43613e1 100644 --- a/inst/include/highfive/bits/H5Node_traits.hpp +++ b/inst/include/highfive/bits/H5Node_traits.hpp @@ -13,17 +13,7 @@ #include #include "../H5Filter.hpp" -#if __has_include() - -#include - -using Path = std::filesystem::path; - - -#else -class Path; -#endif - +#include "path.hpp" namespace HighFive { diff --git a/inst/include/path.hpp b/inst/include/path.hpp index a7439a4..755cd30 100644 --- a/inst/include/path.hpp +++ b/inst/include/path.hpp @@ -2,22 +2,14 @@ #include -#if __has_include() +#if __has_include() && !defined(NOFILEPATH) #include using Path = std::filesystem::path; -inline std::string operator+(const std::string a, const Path &b){ - return(a+b.string()); -} - -inline std::string operator+(const Path &a, const std::string &b){ - return(a.string()+b); -} - - #else + #include class Path{ public: std::string nodes; @@ -25,6 +17,8 @@ class Path{ } Path(const std::string &name):nodes(name){ } + Path(const char* name):nodes(name){ + } std::string parent_path() { if(nodes.size()==0){ Rcpp::stop("path is empty!"); @@ -84,16 +78,30 @@ class Path{ }; inline std::string operator/(const std::string a, const Path &b){ - return(a+b.nodes); + return(a+b.string()); } inline std::ostream &operator<<(std::ostream &os, const Path &dt) { - os << dt.nodes; + os << dt.string(); return os; } +inline bool exists(const Path &p){ + struct stat buffer; + return (stat (p.c_str(), &buffer) == 0); +} + #endif + +inline std::string operator+(const std::string a, const Path &b){ + return(a+b.string()); +} + +inline std::string operator+(const Path &a, const std::string &b){ + return(a.string()+b); +} + inline Path expand (Path in) { if (in.string().size () < 1) return in; const char * home = getenv ("HOME"); @@ -116,7 +124,7 @@ inline Path expand (Path in) { inline Path root_path(const std::string &input) { Path pt=expand(Path(input)); - return pt.is_absolute() ? pt : "/" / pt; + return pt.is_absolute() ? pt : Path("/" + pt.string()); } inline Path root_path(const Rcpp::StringVector &input) { diff --git a/src/Makevars.in b/src/Makevars.in index 13021dc..f835924 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -1,4 +1,4 @@ PKG_LIBS += @HDF5R_LIBS@ #PKG_LIBS += $(shell ${R_HOME}/bin/Rscript -e "RcppParallel::RcppParallelLibs()") -PKG_CPPFLAGS += -I../inst/include @HDF5R_CPPFLAGS@ -DDEBUGNE -DXXH_NAMESPACE=ZSTD_ +PKG_CPPFLAGS += -I../inst/include @HDF5R_CPPFLAGS@ PKG_CFLAGS += @HDF5R_CFLAGS@