| 816 | // Common functions - MPQ File |
| 817 | |
| 818 | TMPQFile * 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 | |
| 848 | TMPQFile * CreateWritableHandle(TMPQArchive * ha, DWORD dwFileSize) |
| 849 | { |
no test coverage detected