icedb  version 0.5.1
Snow particle scattering database API
fs_backend.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <boost/version.hpp>
3 #ifndef __has_include
4  //static_assert(0, "This library requires a recent compiler that supports __has_include");
5 #define __has_include(x) 0
6 #endif
7 #if (__has_include(<boost/filesystem.hpp>) || defined(ICEDB_HAS_COMPILED_BOOST_FILESYSTEM)) && (!ICEDB_PROHIBIT_BOOST_FILESYSTEM) && (BOOST_VERSION > 104400)
8 # define have_boost_filesystem 1
9 # include <boost/filesystem.hpp>
10  namespace sfs = boost::filesystem;
11 #elif __has_include(<filesystem>)
12  // filesystem is still problematic, so I am ignoring it for now. Build system almost always overrides with boost::filesystem.
13 # include <filesystem>
14 # define have_std_filesystem 1
15 # define experimental_filesystem
16  namespace sfs = std::experimental::filesystem::v1;
17  // namespace sfs = std::filesystem;
18 #elif __has_include(<experimental/filesystem>)
19 # include <experimental/filesystem>
20 # define have_std_filesystem 1
21 # define experimental_filesystem
22  namespace sfs = std::experimental::filesystem::v1;
23 #else
24 # error("This library either requires boost::filesystem v3 or a recent compiler that supports the C++ 2017 filesystem library.");
25 #endif
26 
27 //__cpp_lib_experimental_filesystem - is not yet defined on all compilers, notable MSVC17.
28 
29 
30 #include <set>
31 #include <string>
32 #include <map>
33 
34 namespace icedb {
35  namespace fs {
38  namespace impl {
39  typedef std::set<sfs::path> ExtensionsMatching_Type;
40  extern const ExtensionsMatching_Type common_hdf5_extensions;
42  sfs::path resolveSymLinks(const sfs::path &base);
43 
45  typedef std::vector<std::pair<sfs::path, std::string> > CollectedFilesRet_Type;
48  CollectedFilesRet_Type collectDatasetFiles(
49  const sfs::path &base,
50  const ExtensionsMatching_Type &fileExtensionsToMatch = common_hdf5_extensions);
51 
53  sfs::path resolveSymlinkPathandForceExists(const std::string &location);
54 
56  CollectedFilesRet_Type collectActualHDF5files(const sfs::path &pBaseS);
57 
59  std::string getUniqueVROOTname();
60  }
61  }
62 }
CollectedFilesRet_Type collectDatasetFiles(const sfs::path &base, const ExtensionsMatching_Type &valid_extensions)
Definition: fs_backend.cpp:26
sfs::path resolveSymLinks(const sfs::path &base)
Finds out where a symbolic link points to.
Definition: fs_backend.cpp:16
sfs::path resolveSymlinkPathandForceExists(const std::string &location)
Like resolveSymLinks, but throw if the resulting path does not exist.
Definition: fs_backend.cpp:73
std::set< sfs::path > ExtensionsMatching_Type
Definition: fs_backend.hpp:39
std::vector< std::pair< sfs::path, std::string > > CollectedFilesRet_Type
File path, relative mount point.
Definition: fs_backend.hpp:45
const ExtensionsMatching_Type common_hdf5_extensions
Definition: fs_backend.cpp:13
CollectedFilesRet_Type collectActualHDF5files(const sfs::path &pBaseS)
Like collectDatasetFiles for HDF5 files, but then check that these files are, indeed, HDF5 files.
Definition: fs_backend.cpp:82
std::string getUniqueVROOTname()
Generate a unique string, used in memort-only HDF5 file trees.
Definition: fs_backend.cpp:100