| 964 | } |
| 965 | |
| 966 | bool 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 |
no test coverage detected