diff options
author | hop311 <hop3114@gmail.com> | 2023-11-11 21:49:52 +0100 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-11-13 00:39:21 +0100 |
commit | ce84886cb931975f622134d6c8d32a69c675d975 (patch) | |
tree | 5b02ae0a6bd71fe01c082dc5af30c6e830c54de2 /src/openvic-simulation/dataloader/Dataloader.hpp | |
parent | fd686eadf81e85bd4993a483adcefd6a153d259f (diff) |
Directory lookup refactor+suppressed wargoal error
Diffstat (limited to 'src/openvic-simulation/dataloader/Dataloader.hpp')
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.hpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp index 7c71763..5039582 100644 --- a/src/openvic-simulation/dataloader/Dataloader.hpp +++ b/src/openvic-simulation/dataloader/Dataloader.hpp @@ -30,11 +30,16 @@ namespace OpenVic { bool _load_map_dir(GameManager& game_manager) const; bool _load_history(GameManager& game_manager, bool unused_history_file_warnings) const; - /* _DirIterator is fs::directory_iterator or fs::recursive_directory_iterator. - * _Equiv is an equivalence relation with respect to which every found file shall be unique. - * If a file is equivalent to the empty path then it is not included. */ - template<typename _DirIterator, std::predicate<fs::path const&, fs::path const&> _Equiv> - path_vector_t _lookup_files_in_dir(std::string_view path, fs::path const& extension) const; + /* _DirIterator is fs::directory_iterator or fs::recursive_directory_iterator. _UniqueKey is the type of a callable + * which converts a string_view filepath with root removed into a string_view unique key. Any path whose key is empty + * or matches an earlier found path's key is discarded, ensuring each looked up path's key is non-empty and unique. */ + template<typename _DirIterator, typename _UniqueKey> + requires requires (_UniqueKey const& unique_key, std::string_view path) { + { unique_key(path) } -> std::convertible_to<std::string_view>; + } + path_vector_t _lookup_files_in_dir( + std::string_view path, fs::path const& extension, _UniqueKey const& unique_key + ) const; public: static ovdl::v2script::Parser parse_defines(fs::path const& path); @@ -73,7 +78,7 @@ namespace OpenVic { */ fs::path lookup_file(std::string_view path, bool print_error = true) const; /* Checks alternate file endings, e.g. if "*.tga" doesn't exist then try "*.dds" */ - fs::path lookup_image_file(std::string_view path) const; + fs::path lookup_image_file_or_dds(std::string_view path) const; path_vector_t lookup_files_in_dir(std::string_view path, fs::path const& extension) const; path_vector_t lookup_files_in_dir_recursive(std::string_view path, fs::path const& extension) const; path_vector_t lookup_basic_indentifier_prefixed_files_in_dir(std::string_view path, fs::path const& extension) const; |