1 #include "../icedb/fs_backend.hpp" 2 #include "../icedb/compat/gsl/gsl_assert" 3 #include "../private/hdf5_load.h" 13 = {
".hdf5",
".nc",
".h5",
".cdf",
".hdf" };
19 while (sfs::is_symlink(res) && sfs::exists(res))
21 res = sfs::read_symlink(res);
27 const sfs::path &base,
30 std::string sBase = base.string();
31 std::replace(sBase.begin(), sBase.end(),
'\\',
'/');
33 std::vector<std::pair<sfs::path, std::string> > res;
35 if (sfs::is_regular_file(sbase)) {
36 if (valid_extensions.count(base.extension()) > 0) {
37 res.push_back(std::pair<sfs::path, std::string>(sbase,
"/"));
41 for (
const auto& p : sfs::recursive_directory_iterator(base)) {
43 if (!sfs::exists(sp))
continue;
44 if (sfs::is_regular_file(sp)) {
45 if (valid_extensions.count(sp.extension()) > 0) {
46 std::string sP = p.path().string();
47 std::replace(sP.begin(), sP.end(),
'\\',
'/');
48 Expects(sP.find(sBase) == 0);
49 std::string relPath = sP.substr(sBase.length());
51 relPath = relPath.substr(relPath.find_first_not_of(
'/'));
64 res.push_back(std::pair<sfs::path, std::string>(p, relPath));
75 sfs::path pBase(location);
76 Expects(sfs::exists(pBase));
78 Expects(sfs::exists(res));
88 for (
const auto & cand : mountFilesCands) {
90 htri_t isval = H5Fis_hdf5(cand.first.string().c_str());
91 Expects(isval >= 0 &&
"File should exist at this point." && cand.first.string().c_str());
93 mountFiles.push_back(cand);
95 std::cerr <<
"File " << cand.first.string() <<
" is somehow invalid." << std::endl;
101 static std::atomic<int> i{ 0 };
103 std::ostringstream out;
104 out <<
"VIRTUAL-" << j;
105 return std::string(out.str());
CollectedFilesRet_Type collectDatasetFiles(const sfs::path &base, const ExtensionsMatching_Type &valid_extensions)
sfs::path resolveSymLinks(const sfs::path &base)
Finds out where a symbolic link points to.
sfs::path resolveSymlinkPathandForceExists(const std::string &location)
Like resolveSymLinks, but throw if the resulting path does not exist.
std::set< sfs::path > ExtensionsMatching_Type
std::vector< std::pair< sfs::path, std::string > > CollectedFilesRet_Type
File path, relative mount point.
const ExtensionsMatching_Type common_hdf5_extensions
CollectedFilesRet_Type collectActualHDF5files(const sfs::path &pBaseS)
Like collectDatasetFiles for HDF5 files, but then check that these files are, indeed, HDF5 files.
std::string getUniqueVROOTname()
Generate a unique string, used in memort-only HDF5 file trees.