1 #ifndef CASM_FileEnumerator
2 #define CASM_FileEnumerator
4 #include <boost/filesystem.hpp>
24 bool _relative =
false);
27 template <
typename OutputIterator>
31 template <
typename OutputIterator>
32 OutputIterator
bset_files(OutputIterator result);
35 template <
typename OutputIterator>
39 template <
typename OutputIterator>
40 OutputIterator
eci_files(OutputIterator result);
43 template <
typename OutputIterator>
47 template <
typename OutputIterator>
51 template <
typename OutputIterator>
59 template <
typename OutputIterator>
60 OutputIterator
_if_exists(OutputIterator result, fs::path path);
63 template <
typename OutputIterator>
64 OutputIterator
_all_that_exist(OutputIterator result, fs::path location);
91 m_primclex(_primclex),
92 m_dir(m_primclex.
dir()),
93 m_set(m_primclex.settings()),
94 m_all_settings(_all_settings),
95 m_relative(_relative),
96 m_all_bset(m_dir.all_bset()),
97 m_all_calctype(m_dir.all_calctype()),
98 m_all_property(m_dir.all_property()) {}
104 auto b = path.string().size();
105 return fs::path(path.string().substr(a, b));
111 template <
typename OutputIterator>
114 if (fs::exists(path)) {
121 template <
typename OutputIterator>
124 std::vector<fs::path> all;
128 if (!fs::exists(location)) {
131 fs::directory_iterator it(location);
132 fs::directory_iterator end_it;
133 for (; it != end_it; ++it) {
134 if (fs::is_regular_file(*it)) {
152 template <
typename OutputIterator>
161 for (
auto it = v.begin(); it != v.end(); ++it) {
174 template <
typename OutputIterator>
194 template <
typename OutputIterator>
202 for (
auto ref : all_ref) {
216 template <
typename OutputIterator>
229 for (
auto ref : all_ref) {
232 for (
auto eci : all_eci) {
247 template <
typename OutputIterator>
275 template <
typename OutputIterator>
295 template <
typename OutputIterator>
299 std::string pattern =
"calctype.";
300 for (; it != end; ++it) {
304 if (fs::is_directory(*it)) {
305 std::string
dir = it->path().filename().string();
306 if (
dir.substr(0, pattern.size()) == pattern) {
307 if (
dir.substr(pattern.size(),
dir.size()) !=
315 if (fs::is_regular_file(*it)) {
Specification of CASM project directory structure.
fs::path prim() const
Return prim.json path.
fs::path root_dir() const
Return casm project directory path.
std::vector< std::string > all_eci(std::string property, std::string calctype, std::string ref, std::string bset) const
Check filesystem directory structure and return list of all eci names.
fs::path configuration_calc_settings_dir(std::string configname, std::string calctype) const
Return calculation settings directory path, for configuration specific settings.
fs::path SCEL() const
Return SCEL path.
fs::path calculated_properties(std::string configname, std::string calctype) const
Return properties.calc.json file path.
fs::path crystal_point_group() const
Return crystal_point_group.json path.
fs::path config_list() const
Return master config_list.json file path.
fs::path project_settings() const
Return project_settings.json path.
fs::path clust(std::string bset) const
fs::path enumerator_plugins() const
Return enumerators plugin dir.
fs::path training_data() const
Return 'training_data' directorty path.
fs::path chemical_reference(std::string calctype, std::string ref) const
Return chemical reference file path.
fs::path basis(std::string bset) const
fs::path eci(std::string property, std::string calctype, std::string ref, std::string bset, std::string eci) const
Returns path to eci.json.
fs::path calc_settings_dir(std::string calctype) const
Return calculation settings directory path, for global settings.
fs::path supercell_calc_settings_dir(std::string scelname, std::string calctype) const
Return calculation settings directory path, for supercell specific settings.
fs::path calc_status(std::string configname, std::string calctype) const
Return calculation status file path.
fs::path lattice_point_group() const
Return lattice_point_group.json path.
fs::path clexulator_src(std::string project_name, std::string bset) const
Returns path to clexulator source file.
fs::path composition_axes() const
Return composition axes file path.
fs::path factor_group() const
Return factor_group.json path.
fs::path bspecs(std::string bset) const
Return basis function specs (bspecs.json) file path.
std::vector< std::string > all_ref(std::string calctype) const
Check filesystem directory structure and return list of all ref names for a given calctype.
Lists all files in a CASM project, for use with 'casm files' command.
OutputIterator all_calc_files(OutputIterator result)
Enumerate all training data files.
const PrimClex & m_primclex
OutputIterator _if_exists(OutputIterator result, fs::path path)
output path if it exists
std::vector< std::string > m_all_property
FileEnumerator(const PrimClex &_primclex, bool _all_settings=false, bool _relative=false)
A CASM project file enumerator.
fs::path _if_relative(fs::path path)
make paths relative to m_primclex.dir().root_dir() if m_relative
OutputIterator calc_status_files(OutputIterator result)
Enumerate calculation status files.
OutputIterator reference_files(OutputIterator result)
Enumerate reference files.
OutputIterator eci_files(OutputIterator result)
Enumerate eci files.
OutputIterator _all_that_exist(OutputIterator result, fs::path location)
Get all regular files that exist in directory 'location'.
OutputIterator calc_settings_files(OutputIterator result)
Enumerate calculation settings files.
std::vector< std::string > m_all_calctype
OutputIterator bset_files(OutputIterator result)
Enumerate bset files.
std::vector< std::string > m_all_bset
OutputIterator basic_files(OutputIterator result)
Enumerate all setting independent files.
PrimClex is the top-level data structure for a CASM project.
std::string project_name() const
Get project name.
ClexDescription const & default_clex() const
Get default ClexDescription.
Represents a supercell of the primitive parent crystal structure.
DB::Database< T > & db() const
const DirectoryStructure & dir() const
Access DirectoryStructure object. Throw if not set.
ConfigIO::GenericConfigFormatter< jsonParser > config()
DirectoryStructure const & dir