Skip to content

Commit

Permalink
remove std::filesystem deps
Browse files Browse the repository at this point in the history
  • Loading branch information
CreRecombinase committed Nov 7, 2019
1 parent ddbc65d commit b3b1a4b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ GRTAGS
/src/Makevars
/.lintr
*.idx
/config.log
/config.status
/compile_commands.json
7 changes: 2 additions & 5 deletions inst/include/highfive/bits/H5File_misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
#include <H5Fpublic.h>
#include <cstdlib>


using Path = std::filesystem::path;
Path expand (Path in);

#include "path.hpp"

namespace HighFive {

Expand Down Expand Up @@ -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)){
Expand Down
12 changes: 1 addition & 11 deletions inst/include/highfive/bits/H5Node_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,7 @@
#include <boost/optional.hpp>
#include "../H5Filter.hpp"

#if __has_include(<filesystem>)

#include <filesystem>

using Path = std::filesystem::path;


#else
class Path;
#endif

#include "path.hpp"


namespace HighFive {
Expand Down
34 changes: 21 additions & 13 deletions inst/include/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@
#include <Rcpp.h>


#if __has_include(<filesystem>)
#if __has_include(<filesystem>) && !defined(NOFILEPATH)

#include <filesystem>

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 <sys/stat.h>
class Path{
public:
std::string nodes;
Path(const Rcpp::String &name):nodes(name.get_cstring()){
}
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!");
Expand Down Expand Up @@ -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");
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Makevars.in
Original file line number Diff line number Diff line change
@@ -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@

0 comments on commit b3b1a4b

Please sign in to comment.