MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / loadUnsafe

Method loadUnsafe

Source/Basic/Content.cpp:1528–1558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1526}
1527
1528uint8_t* Content::loadUnsafe(String filename, int64_t& size) {
1529 uint8_t* data = nullptr;
1530 if (filename.empty()) {
1531 return data;
1532 }
1533 auto fullPathAndPackage = Content::getFullPathAndPackage(filename);
1534 if (fullPathAndPackage.zipFile) {
1535 size_t s = 0;
1536 auto res = fullPathAndPackage.zipFile->getFileDataUnsafe(fullPathAndPackage.zipRelativePath, &s);
1537 size = s_cast<int64_t>(s);
1538 return res;
1539 }
1540 std::string fullPath = fullPathAndPackage.fullPath;
1541 if (isAndroidAsset(fullPath)) {
1542 data = _apkFile->getFileDataUnsafe(getAndroidAssetName(fullPath), r_cast<size_t*>(&size));
1543 } else {
1544 BLOCK_START {
1545 FILE* fp = fopen(fullPath.c_str(), "rb");
1546 BREAK_IF(!fp);
1547 fseek(fp, 0, SEEK_END);
1548 unsigned long dataSize = ftell(fp);
1549 fseek(fp, 0, SEEK_SET);
1550 data = new unsigned char[dataSize];
1551 dataSize = fread(data, sizeof(data[0]), dataSize, fp);
1552 fclose(fp);
1553 if (dataSize) {
1554 size = dataSize;
1555 }
1556 }
1557 BLOCK_END
1558 }
1559 if (!data) {
1560 Error("failed to load file: \"{}\"", fullPath);
1561 }

Callers 7

loadAsyncUnsafeMethod · 0.95
startMethod · 0.45
initInRenderMethod · 0.45
searchFilesAsyncMethod · 0.45
loadAsyncMethod · 0.45
dora_threaded_read_fileFunction · 0.45
ShaderCompiler.cppFile · 0.45

Calls 15

fopenFunction · 0.85
fseekFunction · 0.85
ftellFunction · 0.85
freadFunction · 0.85
fcloseFunction · 0.85
SDL_RWFromFileFunction · 0.85
SDL_GetErrorFunction · 0.85
SDL_RWcloseFunction · 0.85
SDL_RWsizeFunction · 0.85
SDL_RWreadFunction · 0.85
getFileDataUnsafeMethod · 0.80
getFileDataAsStringMethod · 0.80

Tested by

no test coverage detected