MCPcopy Create free account
hub / github.com/diasurgical/devilution / LoadFileInMem

Function LoadFileInMem

Source/engine.cpp:976–997  ·  view source on GitHub ↗

* @brief Load a file in to a buffer * @param pszName Path of file * @param pdwFileLen Will be set to file size if non-NULL * @return Buffer with content of file */

Source from the content-addressed store, hash-verified

974 * @return Buffer with content of file
975 */
976BYTE *LoadFileInMem(char *pszName, DWORD *pdwFileLen)
977{
978 HANDLE file;
979 BYTE *buf;
980 int fileLen;
981
982 WOpenFile(pszName, &file, FALSE);
983 fileLen = WGetFileSize(file, NULL, pszName);
984
985 if (pdwFileLen)
986 *pdwFileLen = fileLen;
987
988 if (!fileLen)
989 app_fatal("Zero length SFILE:\n%s", pszName);
990
991 buf = (BYTE *)DiabloAllocPtr(fileLen);
992
993 WReadFile(file, buf, fileLen, pszName);
994 WCloseFile(file);
995
996 return buf;
997}
998
999/**
1000 * @brief Load a file in to the given buffer

Callers 15

LoadArtFontsFunction · 0.85
town.cppFile · 0.85
DRLG_LoadL1SPFunction · 0.85
LoadL1DungeonFunction · 0.85
LoadPreL1DungeonFunction · 0.85
InitCutsceneFunction · 0.85
InitObjectGFXFunction · 0.85
AddDiabObjsFunction · 0.85
InitObjectsFunction · 0.85
SetMapObjectsFunction · 0.85
OperatePedistalFunction · 0.85
SyncPedistalFunction · 0.85

Calls 6

WOpenFileFunction · 0.85
WGetFileSizeFunction · 0.85
app_fatalFunction · 0.85
DiabloAllocPtrFunction · 0.85
WReadFileFunction · 0.85
WCloseFileFunction · 0.85

Tested by

no test coverage detected