///////////////////////////////////////////////////////////////////// returns the size of the file; returns 0 if there's no such file.
| 185 | ////////////////////////////////////////////////////////////////////////// |
| 186 | // returns the size of the file; returns 0 if there's no such file. |
| 187 | unsigned CRefStreamEngine::GetFileSize (const char* szFilePathPC, unsigned nCryPakFlags) |
| 188 | { |
| 189 | char szFilePathBuf[m_pPak->g_nMaxPath]; |
| 190 | const char *szFilePath = m_pPak->AdjustFileName (szFilePathPC, szFilePathBuf, nCryPakFlags); |
| 191 | NameStreamMap::iterator it = m_mapFilesByName.find (szFilePath); |
| 192 | if (it != m_mapFilesByName.end()) |
| 193 | { |
| 194 | if (!it->second->GetFileSize()) |
| 195 | it->second->Activate(); |
| 196 | return it->second->GetFileSize(); |
| 197 | } |
| 198 | |
| 199 | // we didn't find the file size in the cache - open the file and query the size |
| 200 | #if defined(LINUX) |
| 201 | HANDLE hFile = CreateFile (szFilePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); |
| 202 | #else |
| 203 | HANDLE hFile = CreateFile (szFilePath, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); |
| 204 | #endif |
| 205 | if (hFile != INVALID_HANDLE_VALUE) |
| 206 | { |
| 207 | unsigned nFileSize = ::GetFileSize(hFile, NULL); |
| 208 | CloseHandle (hFile); |
| 209 | return nFileSize; |
| 210 | } |
| 211 | else |
| 212 | { |
| 213 | CCachedFileDataPtr pFileData = m_pPak->GetFileData(szFilePath); |
| 214 | if (pFileData) |
| 215 | return pFileData->GetFileEntry()->desc.lSizeUncompressed; |
| 216 | else |
| 217 | { |
| 218 | m_pPak->OnMissingFile(szFilePathPC); |
| 219 | return 0; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | ////////////////////////////////////////////////////////////////////////// |
| 225 | // Gets called regularly, to finalize those proxies whose jobs have |
nothing calls this directly
no test coverage detected