MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / OpenCachedData

Function OpenCachedData

src/TexturePack.c:375–398  ·  view source on GitHub ↗

Attempts to open the cached data stream for the given url */

Source from the content-addressed store, hash-verified

373
374/* Attempts to open the cached data stream for the given url */
375static cc_bool OpenCachedData(const cc_string* url, struct Stream* stream) {
376 cc_string mainPath; char mainBuffer[FILENAME_SIZE];
377 cc_string altPath; char altBuffer[FILENAME_SIZE];
378 cc_filepath raw_path;
379 cc_result res;
380
381 String_InitArray(mainPath, mainBuffer);
382 String_InitArray(altPath, altBuffer);
383
384
385 MakeCachePath(&mainPath, &altPath, url);
386 Platform_EncodePath(&raw_path, &mainPath);
387 res = Stream_OpenPath(stream, &raw_path);
388
389 /* try fallback cache if can't find in main cache */
390 if (res == ReturnCode_FileNotFound && altPath.length) {
391 Platform_EncodePath(&raw_path, &altPath);
392 res = Stream_OpenPath(stream, &raw_path);
393 }
394
395 if (res == ReturnCode_FileNotFound) return false;
396 if (res) { Logger_SysWarn2(res, "opening cache for", url); return false; }
397 return true;
398}
399
400CC_NOINLINE static cc_string GetCachedTag(const cc_string* url, struct StringsBuffer* list) {
401 cc_string key; char keyBuffer[STRING_INT_CHARS];

Callers 1

Calls 4

MakeCachePathFunction · 0.85
Stream_OpenPathFunction · 0.85
Logger_SysWarn2Function · 0.85
Platform_EncodePathFunction · 0.70

Tested by

no test coverage detected