@@ -229,7 +229,7 @@ Error ResourceUID::load_from_cache(bool p_reset) {
229
229
int32_t len = f->get_32 ();
230
230
Cache c;
231
231
c.cs .resize (len + 1 );
232
- ERR_FAIL_COND_V (c.cs .size () != len + 1 , ERR_FILE_CORRUPT); // out of memory
232
+ ERR_FAIL_COND_V (c.cs .size () != len + 1 , ERR_FILE_CORRUPT); // Out of memory.
233
233
c.cs [len] = 0 ;
234
234
int32_t rl = f->get_buffer ((uint8_t *)c.cs .ptrw (), len);
235
235
ERR_FAIL_COND_V (rl != len, ERR_FILE_CORRUPT);
@@ -257,7 +257,7 @@ Error ResourceUID::update_cache() {
257
257
for (KeyValue<ID, Cache> &E : unique_ids) {
258
258
if (!E.value .saved_to_cache ) {
259
259
if (f.is_null ()) {
260
- f = FileAccess::open (get_cache_file (), FileAccess::READ_WRITE); // append
260
+ f = FileAccess::open (get_cache_file (), FileAccess::READ_WRITE); // Append.
261
261
if (f.is_null ()) {
262
262
return ERR_CANT_OPEN;
263
263
}
@@ -282,6 +282,25 @@ Error ResourceUID::update_cache() {
282
282
return OK;
283
283
}
284
284
285
+ String ResourceUID::get_path_from_cache (Ref<FileAccess> &p_cache_file, const String &p_uid_string) {
286
+ const uint32_t entry_count = p_cache_file->get_32 ();
287
+ CharString cs;
288
+ for (uint32_t i = 0 ; i < entry_count; i++) {
289
+ int64_t id = p_cache_file->get_64 ();
290
+ int32_t len = p_cache_file->get_32 ();
291
+ cs.resize (len + 1 );
292
+ ERR_FAIL_COND_V (cs.size () != len + 1 , String ());
293
+ cs[len] = 0 ;
294
+ int32_t rl = p_cache_file->get_buffer ((uint8_t *)cs.ptrw (), len);
295
+ ERR_FAIL_COND_V (rl != len, String ());
296
+
297
+ if (singleton->id_to_text (id) == p_uid_string) {
298
+ return String (cs);
299
+ }
300
+ }
301
+ return String ();
302
+ }
303
+
285
304
void ResourceUID::clear () {
286
305
cache_entries = 0 ;
287
306
unique_ids.clear ();
0 commit comments