MCPcopy Create free account
hub / github.com/Kenix3/libultraship / SFileGetFileSize

Function SFileGetFileSize

extern/StormLib/src/SFileReadFile.cpp:769–814  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767// SFileGetFileSize
768
769DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD pdwFileSizeHigh)
770{
771 ULONGLONG FileSize;
772 TMPQFile * hf = (TMPQFile *)hFile;
773
774 // Validate the file handle before we go on
775 if(IsValidFileHandle(hFile))
776 {
777 // Make sure that the variable is initialized
778 FileSize = 0;
779
780 // If the file is patched file, we have to get the size of the last version
781 if(hf->hfPatch != NULL)
782 {
783 // Walk through the entire patch chain, take the last version
784 while(hf != NULL)
785 {
786 // Get the size of the currently pointed version
787 FileSize = hf->pFileEntry->dwFileSize;
788
789 // Move to the next patch file in the hierarchy
790 hf = hf->hfPatch;
791 }
792 }
793 else
794 {
795 // Is it a local file ?
796 if(hf->pStream != NULL)
797 {
798 FileStream_GetSize(hf->pStream, &FileSize);
799 }
800 else
801 {
802 FileSize = hf->dwDataSize;
803 }
804 }
805
806 // If opened from archive, return file size
807 if(pdwFileSizeHigh != NULL)
808 *pdwFileSizeHigh = (DWORD)(FileSize >> 32);
809 return (DWORD)FileSize;
810 }
811
812 SetLastError(ERROR_INVALID_HANDLE);
813 return SFILE_INVALID_SIZE;
814}
815
816DWORD WINAPI SFileSetFilePointer(HANDLE hFile, LONG lFilePos, LONG * plFilePosHigh, DWORD dwMoveMethod)
817{

Callers 8

LoadMpqFileFunction · 0.85
TestSetFilePointersFunction · 0.85
TestOnLocalListFileFunction · 0.85
VerifyFileFunction · 0.85
CreateListFileCacheFunction · 0.85
SAttrLoadAttributesFunction · 0.85
SFileSetFilePointerFunction · 0.85
LoadFileFromHandleMethod · 0.85

Calls 3

IsValidFileHandleFunction · 0.85
FileStream_GetSizeFunction · 0.85
SetLastErrorFunction · 0.85

Tested by 3

LoadMpqFileFunction · 0.68
TestSetFilePointersFunction · 0.68
TestOnLocalListFileFunction · 0.68