@@ -26,7 +26,9 @@ Build::Build(const std::filesystem::path &output_root)
2626 root_string{this ->root .string ()} {
2727 for (const auto &entry :
2828 std::filesystem::recursive_directory_iterator (this ->root )) {
29- this ->entries [entry.path ().native ()].tracked = false ;
29+ auto &map_entry{this ->entries_ [entry.path ().native ()]};
30+ map_entry.tracked = false ;
31+ map_entry.is_directory = entry.is_directory ();
3032 }
3133
3234 const auto deps_path{this ->root / DEPENDENCIES_FILE};
@@ -65,7 +67,7 @@ Build::Build(const std::filesystem::path &output_root)
6567 switch (tag) {
6668 case ' t' :
6769 if (!current_key.empty ()) {
68- this ->entries [current_key].dependencies = std::move (current_deps);
70+ this ->entries_ [current_key].dependencies = std::move (current_deps);
6971 current_deps = {};
7072 }
7173
@@ -97,7 +99,7 @@ Build::Build(const std::filesystem::path &output_root)
9799 std::string absolute_key{this ->root_string };
98100 absolute_key += ' /' ;
99101 absolute_key += path_part;
100- this ->entries [absolute_key].file_mark = mark_value;
102+ this ->entries_ [absolute_key].file_mark = mark_value;
101103 }
102104
103105 break ;
@@ -110,19 +112,19 @@ Build::Build(const std::filesystem::path &output_root)
110112 }
111113
112114 if (!current_key.empty ()) {
113- this ->entries [current_key].dependencies = std::move (current_deps);
115+ this ->entries_ [current_key].dependencies = std::move (current_deps);
114116 }
115117 this ->has_previous_run = true ;
116118 } catch (...) {
117- this ->entries .clear ();
119+ this ->entries_ .clear ();
118120 }
119121}
120122
121123auto Build::has_dependencies (const std::filesystem::path &path) const -> bool {
122124 assert (path.is_absolute ());
123125 std::shared_lock lock{this ->mutex };
124- const auto match{this ->entries .find (path.native ())};
125- return match != this ->entries .end () && !match->second .dependencies .empty ();
126+ const auto match{this ->entries_ .find (path.native ())};
127+ return match != this ->entries_ .end () && !match->second .dependencies .empty ();
126128}
127129
128130auto Build::finish () -> void {
@@ -132,7 +134,7 @@ auto Build::finish() -> void {
132134
133135 const auto root_prefix_size{this ->root_string .size () + 1 };
134136 std::shared_lock lock{this ->mutex };
135- for (const auto &entry : this ->entries ) {
137+ for (const auto &entry : this ->entries_ ) {
136138 if (!entry.second .tracked ) {
137139 continue ;
138140 }
@@ -181,7 +183,7 @@ auto Build::finish() -> void {
181183
182184 // Remove untracked files inside the output directory
183185 std::shared_lock read_lock{this ->mutex };
184- for (const auto &entry : this ->entries ) {
186+ for (const auto &entry : this ->entries_ ) {
185187 if (!entry.second .tracked &&
186188 entry.first .size () > this ->root_string .size () &&
187189 entry.first .starts_with (this ->root_string )) {
@@ -193,7 +195,7 @@ auto Build::finish() -> void {
193195auto Build::refresh (const std::filesystem::path &path) -> void {
194196 const auto value{std::filesystem::file_time_type::clock::now ()};
195197 std::unique_lock lock{this ->mutex };
196- this ->entries [path.native ()].file_mark = value;
198+ this ->entries_ [path.native ()].file_mark = value;
197199}
198200
199201auto Build::mark (const std::filesystem::path &path)
@@ -202,8 +204,8 @@ auto Build::mark(const std::filesystem::path &path)
202204
203205 {
204206 std::shared_lock lock{this ->mutex };
205- const auto match{this ->entries .find (path.native ())};
206- if (match != this ->entries .end () && match->second .file_mark .has_value ()) {
207+ const auto match{this ->entries_ .find (path.native ())};
208+ if (match != this ->entries_ .end () && match->second .file_mark .has_value ()) {
207209 return match->second .file_mark ;
208210 }
209211 }
@@ -217,7 +219,7 @@ auto Build::mark(const std::filesystem::path &path)
217219 try {
218220 const auto value{std::filesystem::last_write_time (path)};
219221 std::unique_lock lock{this ->mutex };
220- this ->entries [path.native ()].file_mark = value;
222+ this ->entries_ [path.native ()].file_mark = value;
221223 return value;
222224 } catch (const std::filesystem::filesystem_error &) {
223225 return std::nullopt ;
@@ -227,8 +229,8 @@ auto Build::mark(const std::filesystem::path &path)
227229auto Build::mark_locked (const std::filesystem::path &path) const
228230 -> std::optional<mark_type> {
229231 assert (path.is_absolute ());
230- const auto match{this ->entries .find (path.native ())};
231- if (match != this ->entries .end () && match->second .file_mark .has_value ()) {
232+ const auto match{this ->entries_ .find (path.native ())};
233+ if (match != this ->entries_ .end () && match->second .file_mark .has_value ()) {
232234 return match->second .file_mark ;
233235 }
234236
@@ -245,7 +247,7 @@ auto Build::track(const std::filesystem::path &path) -> void {
245247 assert (path.is_absolute ());
246248 const auto &path_string{path.native ()};
247249 std::unique_lock lock{this ->mutex };
248- this ->entries [path_string].tracked = true ;
250+ this ->entries_ [path_string].tracked = true ;
249251 auto parent_key{path_string};
250252 while (true ) {
251253 const auto slash{parent_key.rfind (' /' )};
@@ -254,19 +256,20 @@ auto Build::track(const std::filesystem::path &path) -> void {
254256 }
255257
256258 parent_key = parent_key.substr (0 , slash);
257- auto &parent_entry{this ->entries [parent_key]};
259+ auto &parent_entry{this ->entries_ [parent_key]};
258260 if (parent_entry.tracked ) {
259261 break ;
260262 }
261263
262264 parent_entry.tracked = true ;
265+ parent_entry.is_directory = true ;
263266 }
264267}
265268
266269auto Build::is_untracked_file (const std::filesystem::path &path) const -> bool {
267270 std::shared_lock lock{this ->mutex };
268- const auto match{this ->entries .find (path.native ())};
269- return match == this ->entries .cend () || !match->second .tracked ;
271+ const auto match{this ->entries_ .find (path.native ())};
272+ return match == this ->entries_ .cend () || !match->second .tracked ;
270273}
271274
272275auto Build::output_write_json (const std::filesystem::path &path,
0 commit comments