@@ -164,7 +164,16 @@ struct path_store {
164164 component_size = 0 ;
165165 ++in;
166166 } else {
167+ #ifdef _WIN32
168+ // note: ninja doesn't do this, so things should usually work without it
169+ // but e.g the scanner can return paths with a lower/upper case
170+ // drive letter depending on the environment variables
171+ // todo: maybe fix the scanner instead, or only toupper the drive letter ?
172+ // todo: unicode ?
173+ *out++ = toupper (*in++);
174+ #else
167175 *out++ = *in++;
176+ #endif
168177 ++component_size;
169178 }
170179 }
@@ -214,8 +223,12 @@ struct path_store {
214223 return itr->second ;
215224 }
216225
226+ auto open_paths_db (mdb::mdb_txn<false >& txn_rw) {
227+ return txn_rw.open_db <uint32_t , std::string_view>(" paths" );
228+ }
229+
217230 void commit_path_changes (mdb::mdb_txn<false >& txn_rw) {
218- auto db = txn_rw. open_db < uint32_t , std::string_view>( " paths " );
231+ auto db = open_paths_db (txn_rw );
219232
220233 if (id_to_normal_path_ref.empty ())
221234 return ;
@@ -239,7 +252,7 @@ struct path_store {
239252 }
240253
241254 void read_paths (mdb::mdb_txn<false >& txn_rw, std::string_view item_root_path) {
242- auto db = txn_rw. open_db < uint32_t , std::string_view>( " paths " );
255+ auto db = open_paths_db (txn_rw );
243256
244257 normal_paths.clear ();
245258 id_to_normal_path_ref.clear ();
@@ -284,10 +297,14 @@ struct path_store {
284297 return normal_paths.get_alloc (id_to_normal_path_ref[file_id]);
285298 }
286299
300+ auto open_file_data_db (mdb::mdb_txn<false >& txn_rw) {
301+ return txn_rw.open_db <file_id_t , file_entry>(" file_data" );
302+ }
303+
287304 // note: this doesn't work if called after update_file_data
288305 template <typename idx_t , typename F>
289306 void get_file_data (mdb::mdb_txn<false >& txn_rw, const vector_map<idx_t , file_id_t >& files, F&& data_func) {
290- auto db = txn_rw. open_db < file_id_t , file_entry>( " file_data " );
307+ auto db = open_file_data_db (txn_rw );
291308
292309 for (auto idx : files.indices ()) {
293310 auto file_id = files[idx];
@@ -313,7 +330,7 @@ struct path_store {
313330 }
314331
315332 void commit_file_data_changes (mdb::mdb_txn<false >& txn_rw) {
316- auto db = txn_rw. open_db < file_id_t , file_entry>( " file_data " );
333+ auto db = open_file_data_db (txn_rw );
317334
318335 for (auto & [file_id, entry] : new_file_data)
319336 db.put (file_id, entry);
@@ -323,6 +340,25 @@ struct path_store {
323340 commit_path_changes (txn_rw);
324341 commit_file_data_changes (txn_rw);
325342 }
343+
344+ void print_paths (mdb::mdb_txn<false >& txn_rw) {
345+ read_paths (txn_rw, " " );
346+ for (auto id = file_id_t { 1 }; id < id_to_normal_path_ref.size (); ++id) {
347+ auto path = normal_paths.get_alloc (id_to_normal_path_ref[id]);
348+ fmt::print (" {} - {}\n " , id, path);
349+ }
350+ }
351+
352+ void print_file_data (mdb::mdb_txn<false >& txn_rw) {
353+ auto db = open_file_data_db (txn_rw);
354+ // todo:
355+ }
356+
357+ // todo: this should work with a read-only txn as well
358+ void print (mdb::mdb_txn<false >& txn_rw) {
359+ print_paths (txn_rw);
360+ print_file_data (txn_rw);
361+ }
326362};
327363
328364} // namespace mdb
0 commit comments