MCPcopy Create free account
hub / github.com/ddiakopoulos/polymer / walk_asset_dir

Method walk_asset_dir

libraries/lib-engine/src/shader-library.cpp:84–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void gl_shader_monitor::walk_asset_dir()
85{
86 std::error_code ec;
87
88 for (auto & sp : search_paths)
89 {
90 const path root = sp;
91
92 recursive_directory_iterator dir_iter(root, directory_options::skip_permission_denied, ec);
93 if (ec) continue;
94
95 for (auto it = begin(dir_iter); it != end(dir_iter); it.increment(ec))
96 {
97 if (ec)
98 {
99 ec.clear();
100 continue;
101 }
102
103 std::string entry_path_str;
104 std::string scanned_file;
105 try
106 {
107 entry_path_str = it->path().string();
108 scanned_file = get_filename_with_extension(entry_path_str);
109 }
110 catch (const std::exception &) { continue; }
111
112 for (auto & asset : assets)
113 {
114 // Regular shader assets
115 if (scanned_file == get_filename_with_extension(asset.second->vertexPath) ||
116 scanned_file == get_filename_with_extension(asset.second->fragmentPath) ||
117 scanned_file == get_filename_with_extension(asset.second->geomPath))
118 {
119 auto writeTime = duration_cast<seconds>(write_time(entry_path_str).time_since_epoch()).count();
120
121 if (writeTime > asset.second->writeTime)
122 {
123 asset.second->writeTime = writeTime;
124 asset.second->shouldRecompile = true;
125 log::get()->import_log->info("gl_shader_monitor updated program {}", asset.first);
126 }
127 }
128
129 // Each shader keeps a list of the files it includes. gl_shader_monitor watches a base path,
130 // so we should be able to recompile shaders dependent on common includes
131 for (const std::string & includePath : asset.second->includes)
132 {
133 if (scanned_file == get_filename_with_extension(includePath))
134 {
135 auto writeTime = duration_cast<seconds>(write_time(entry_path_str).time_since_epoch()).count();
136 if (writeTime > asset.second->writeTime)
137 {
138 asset.second->writeTime = writeTime;
139 asset.second->shouldRecompile = true;
140 log::get()->import_log->info("gl_shader_monitor updated include {}", includePath);
141 break;

Callers

nothing calls this directly

Calls 5

beginFunction · 0.85
endFunction · 0.85
write_timeFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected