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

Function SFileGetFileName

3rdParty/StormLib/src/SFileGetFileInfo.cpp:966–1009  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

964}
965
966bool STORMAPI SFileGetFileName(HANDLE hFile, char * szFileName)
967{
968 TMPQFile * hf = (TMPQFile *)hFile; // MPQ File handle
969 int nError = ERROR_INVALID_HANDLE;
970
971 // Check valid parameters
972 if(IsValidFileHandle(hFile))
973 {
974 TFileEntry * pFileEntry = hf->pFileEntry;
975
976 // For MPQ files, retrieve the file name from the file entry
977 if(hf->pStream == NULL)
978 {
979 if(pFileEntry != NULL)
980 {
981 // If the file name is not there yet, create a pseudo name
982 if(pFileEntry->szFileName == NULL)
983 nError = CreatePseudoFileName(hFile, pFileEntry, szFileName);
984
985 // Copy the file name to the output buffer, if any
986 if(pFileEntry->szFileName && szFileName)
987 {
988 strcpy(szFileName, pFileEntry->szFileName);
989 nError = ERROR_SUCCESS;
990 }
991 }
992 }
993
994 // For local files, copy the file name from the stream
995 else
996 {
997 if(szFileName != NULL)
998 {
999 const TCHAR * szStreamName = FileStream_GetFileName(hf->pStream);
1000 StringCopy(szFileName, MAX_PATH, szStreamName);
1001 }
1002 nError = ERROR_SUCCESS;
1003 }
1004 }
1005
1006 if(nError != ERROR_SUCCESS)
1007 SetLastError(nError);
1008 return (nError == ERROR_SUCCESS);
1009}
1010

Callers 1

DoMPQSearch_FileEntryFunction · 0.85

Calls 5

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

Tested by

no test coverage detected