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

Function SFileGetFileName

extern/StormLib/src/SFileGetFileInfo.cpp:565–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

563}
564
565bool WINAPI SFileGetFileName(HANDLE hFile, char * szFileName)
566{
567 TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle
568 DWORD dwErrCode = ERROR_INVALID_HANDLE;
569
570 // Check valid parameters
571 if(IsValidFileHandle(hFile))
572 {
573 TFileEntry * pFileEntry = hf->pFileEntry;
574
575 // For MPQ files, retrieve the file name from the file entry
576 if(hf->pStream == NULL)
577 {
578 if(pFileEntry != NULL)
579 {
580 // If the file name is not there yet, create a pseudo name
581 if(pFileEntry->szFileName == NULL)
582 dwErrCode = CreatePseudoFileName(hFile, pFileEntry, szFileName);
583
584 // Copy the file name to the output buffer, if any
585 if(pFileEntry->szFileName && szFileName)
586 {
587 strcpy(szFileName, pFileEntry->szFileName);
588 dwErrCode = ERROR_SUCCESS;
589 }
590 }
591 }
592
593 // For local files, copy the file name from the stream
594 else
595 {
596 if(szFileName != NULL)
597 {
598 const TCHAR * szStreamName = FileStream_GetFileName(hf->pStream);
599 StringCopy(szFileName, MAX_PATH, szStreamName);
600 }
601 dwErrCode = ERROR_SUCCESS;
602 }
603 }
604
605 if(dwErrCode != ERROR_SUCCESS)
606 SetLastError(dwErrCode);
607 return (dwErrCode == ERROR_SUCCESS);
608}
609

Callers 2

TestOnLocalListFileFunction · 0.85
DoMPQSearch_FileEntryFunction · 0.85

Calls 5

IsValidFileHandleFunction · 0.85
CreatePseudoFileNameFunction · 0.85
FileStream_GetFileNameFunction · 0.85
StringCopyFunction · 0.85
SetLastErrorFunction · 0.85

Tested by 1

TestOnLocalListFileFunction · 0.68