19 #ifndef RESOURCE_LOCATOR_H
20 #define RESOURCE_LOCATOR_H
28 #include "generic/lru_cache.h"
29 #include "generic/optional.h"
30 #include "generic/managed.h"
31 #include "utils/unicode.h"
41 std::runtime_error(what) {}
50 const std::list<Path>& search_path() {
return resource_path_; }
55 bool fail_silently=
false
57 std::shared_ptr<std::istream> open_file(
const Path& filename);
58 std::shared_ptr<std::stringstream> read_file(
const Path& filename);
59 std::vector<std::string> read_file_lines(
const Path& filename);
61 bool add_search_path(
const Path& path);
62 bool insert_search_path(uint32_t index,
const Path& path);
63 void remove_search_path(
const Path& path);
65 std::size_t search_path_size()
const {
return resource_path_.size(); }
68 std::size_t location_cache_size()
const;
71 void clear_location_cache();
74 void set_location_cache_limit(std::size_t entries);
81 read_blocking_enabled_ =
true;
84 void disable_read_blocking() {
85 read_blocking_enabled_ =
false;
88 bool read_blocking_enabled()
const {
89 return read_blocking_enabled_;
94 bool read_blocking_enabled_ =
false;
96 Path find_executable_directory();
97 Path find_working_directory();
99 std::list<Path> resource_path_;
101 mutable LRUCache<Path, Path> location_cache_;
106 #endif // RESOURCE_LOCATOR_H