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

Function CreateFileHandle

3rdParty/StormLib/src/SBaseCommon.cpp:818–846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816// Common functions - MPQ File
817
818TMPQFile * CreateFileHandle(TMPQArchive * ha, TFileEntry * pFileEntry)
819{
820 TMPQFile * hf;
821
822 // Allocate space for TMPQFile
823 hf = STORM_ALLOC(TMPQFile, 1);
824 if(hf != NULL)
825 {
826 // Fill the file structure
827 memset(hf, 0, sizeof(TMPQFile));
828 hf->dwMagic = ID_MPQ_FILE;
829 hf->pStream = NULL;
830 hf->ha = ha;
831
832 // If the called entered a file entry, we also copy informations from the file entry
833 if(ha != NULL && pFileEntry != NULL)
834 {
835 // Set the raw position and MPQ position
836 hf->RawFilePos = FileOffsetFromMpqOffset(ha, pFileEntry->ByteOffset);
837 hf->MpqFilePos = pFileEntry->ByteOffset;
838
839 // Set the data size
840 hf->dwDataSize = pFileEntry->dwFileSize;
841 hf->pFileEntry = pFileEntry;
842 }
843 }
844
845 return hf;
846}
847
848TMPQFile * CreateWritableHandle(TMPQArchive * ha, DWORD dwFileSize)
849{

Callers 3

OpenLocalFileFunction · 0.85
SFileOpenFileExFunction · 0.85
CreateWritableHandleFunction · 0.85

Calls 1

FileOffsetFromMpqOffsetFunction · 0.85

Tested by

no test coverage detected