| 189 | } |
| 190 | |
| 191 | bool OpenFileByCKeyEntry(TCascStorage * hs, PCASC_CKEY_ENTRY pCKeyEntry, DWORD dwOpenFlags, HANDLE * PtrFileHandle) |
| 192 | { |
| 193 | TCascFile * hf = NULL; |
| 194 | DWORD dwErrCode = ERROR_FILE_NOT_FOUND; |
| 195 | |
| 196 | // If the CKey entry is NULL, we consider the file non-existant |
| 197 | if(pCKeyEntry != NULL) |
| 198 | { |
| 199 | // Create the file handle structure |
| 200 | if((hf = new TCascFile(hs, pCKeyEntry)) != NULL) |
| 201 | { |
| 202 | hf->bVerifyIntegrity = (dwOpenFlags & CASC_STRICT_DATA_CHECK) ? true : false; |
| 203 | hf->bDownloadFileIf = (hs->dwFeatures & CASC_FEATURE_ONLINE) ? true : false; |
| 204 | hf->bOvercomeEncrypted = (dwOpenFlags & CASC_OVERCOME_ENCRYPTED) ? true : false; |
| 205 | dwErrCode = ERROR_SUCCESS; |
| 206 | } |
| 207 | else |
| 208 | { |
| 209 | dwErrCode = ERROR_NOT_ENOUGH_MEMORY; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | // Give the output parameter, no matter what |
| 214 | PtrFileHandle[0] = (HANDLE)hf; |
| 215 | |
| 216 | // Handle last error |
| 217 | if(dwErrCode != ERROR_SUCCESS) |
| 218 | SetCascError(dwErrCode); |
| 219 | return (dwErrCode == ERROR_SUCCESS); |
| 220 | } |
| 221 | |
| 222 | bool OpenLocalFile(LPCTSTR szFileName, DWORD dwOpenFlags, HANDLE * PtrFileHandle) |
| 223 | { |
no test coverage detected