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

Function OpenLocalFile

3rdParty/StormLib/src/SFileOpenFileEx.cpp:71–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71static bool OpenLocalFile(const char * szFileName, HANDLE * PtrFile)
72{
73 TFileStream * pStream;
74 TMPQFile * hf = NULL;
75 TCHAR szFileNameT[MAX_PATH];
76
77 // Convert the file name to UNICODE (if needed)
78 StringCopy(szFileNameT, _countof(szFileNameT), szFileName);
79
80 // Open the file and create the TMPQFile structure
81 pStream = FileStream_OpenFile(szFileNameT, STREAM_FLAG_READ_ONLY);
82 if(pStream != NULL)
83 {
84 // Allocate and initialize file handle
85 hf = CreateFileHandle(NULL, NULL);
86 if(hf != NULL)
87 {
88 hf->pStream = pStream;
89 *PtrFile = hf;
90 return true;
91 }
92 else
93 {
94 FileStream_Close(pStream);
95 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
96 }
97 }
98 *PtrFile = NULL;
99 return false;
100}
101
102bool OpenPatchedFile(HANDLE hMpq, const char * szFileName, HANDLE * PtrFile)
103{

Callers 1

SFileOpenFileExFunction · 0.85

Calls 5

StringCopyFunction · 0.85
FileStream_OpenFileFunction · 0.85
CreateFileHandleFunction · 0.85
FileStream_CloseFunction · 0.85
SetLastErrorFunction · 0.85

Tested by

no test coverage detected