diff --git a/data/.internal/readme.md b/data/.internal/readme.md index 307293ed21..e1f828a9bb 100644 --- a/data/.internal/readme.md +++ b/data/.internal/readme.md @@ -1,2 +1,16 @@ # Internal data Directory managed by OpenSpace internally, edit carefully + +## Directory structure +``` +. +├── readme.md +└── volumes_from_cdf + └── mas_merged_step_rho + ├── mas_merged_step_101.cdf.dictionary + ├── mas_merged_step_101.cdf.rawvolume + └── mas_merged_step.state + + +``` + diff --git a/modules/dataloader/reader.cpp b/modules/dataloader/reader.cpp index e88d3df1fc..e21dd4faef 100644 --- a/modules/dataloader/reader.cpp +++ b/modules/dataloader/reader.cpp @@ -26,13 +26,16 @@ #include #include +#include +#include + namespace { constexpr const char* _loggerCat = "Reader"; } // namespace namespace { static const openspace::properties::Property::PropertyInfo VolumesInfo = { - "Volumes", + "VolumeItems", "List of volumes stored internally and ready to load", "This list contains names of volume data files converted from the CDF format" }; @@ -48,7 +51,7 @@ namespace openspace::dataloader { Reader::Reader() : PropertyOwner({ "Reader" }) - , _volumes(VolumesInfo) + , _volumeItems(VolumesInfo) , _readVolumesTrigger(ReadVolumesTriggerInfo) { _topDir = ghoul::filesystem::Directory( @@ -60,7 +63,7 @@ Reader::Reader() readVolumeDataItems(); }); - addProperty(_volumes); + addProperty(_volumeItems); addProperty(_readVolumesTrigger); } @@ -68,23 +71,39 @@ void Reader::readVolumeDataItems() { ghoul::filesystem::Directory volumeDir( _topDir.path() + ghoul::filesystem::FileSystem::PathSeparator + - "CDF" + "volumes_from_cdf" ); - std::vector files = volumeDir.readFiles( - ghoul::filesystem::Directory::Recursive::Yes, + std::vector itemDirectories = volumeDir.readDirectories( + ghoul::filesystem::Directory::Recursive::No, ghoul::filesystem::Directory::Sort::Yes ); - // Print vector - // for (auto el : files) { - // LINFO("A file: " + el); + std::vector volumeItems(_volumeItems); + for (int i = 0; i < itemDirectories.size(); i++) { + volumeItems.push_back(itemDirectories[i]); + } + + // for (auto el : volumeItems) { + // LINFO("A dir: " + el); // } - // For each folder - // Take first part of file name - // Add to list - // Store a reference somehow if necessary + // Take out leaves of uri:s + // std::regex dirLeaf_regex("([^/]+)/?$"); + // std::smatch dirLeaf_match; + // std::vector itemDirLeaves; + + // // Add each directory uri leaf to list + // for (const std::string dir : itemDirectories) { + // if (std::regex_search(dir, dirLeaf_match, dirLeaf_regex)) { + // itemDirLeaves.push_back(dirLeaf_match[0].str()); + // } else { + // LWARNING("Looked for match in " + dir + " but found none."); + // } + + // } + + // Store a reference somehow if necessary } } \ No newline at end of file diff --git a/modules/dataloader/reader.h b/modules/dataloader/reader.h index eb57e5a31c..4e5811380f 100644 --- a/modules/dataloader/reader.h +++ b/modules/dataloader/reader.h @@ -40,7 +40,7 @@ class Reader : public properties::PropertyOwner { void readVolumeDataItems(); private: - properties::StringListProperty _volumes; + properties::StringListProperty _volumeItems; properties::TriggerProperty _readVolumesTrigger; ghoul::filesystem::Directory _topDir;