Try locate the file szFileName in the zipfile. For the iCaseSensitivity signification, see unzipStringFileNameCompare return value : UNZ_OK if the file is found. It becomes the current file. UNZ_END_OF_LIST_OF_FILE if the file is not found */
| 1230 | UNZ_END_OF_LIST_OF_FILE if the file is not found |
| 1231 | */ |
| 1232 | extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) |
| 1233 | { |
| 1234 | unz64_s* s; |
| 1235 | int err; |
| 1236 | |
| 1237 | /* We remember the 'current' position in the file so that we can jump |
| 1238 | * back there if we fail. |
| 1239 | */ |
| 1240 | unz_file_info64 cur_file_infoSaved; |
| 1241 | unz_file_info64_internal cur_file_info_internalSaved; |
| 1242 | ZPOS64_T num_fileSaved; |
| 1243 | ZPOS64_T pos_in_central_dirSaved; |
| 1244 | |
| 1245 | |
| 1246 | if (file==NULL) |
| 1247 | return UNZ_PARAMERROR; |
| 1248 | |
| 1249 | if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) |
| 1250 | return UNZ_PARAMERROR; |
| 1251 | |
| 1252 | s=(unz64_s*)file; |
| 1253 | if (!s->current_file_ok) |
| 1254 | return UNZ_END_OF_LIST_OF_FILE; |
| 1255 | |
| 1256 | /* Save the current state */ |
| 1257 | num_fileSaved = s->num_file; |
| 1258 | pos_in_central_dirSaved = s->pos_in_central_dir; |
| 1259 | cur_file_infoSaved = s->cur_file_info; |
| 1260 | cur_file_info_internalSaved = s->cur_file_info_internal; |
| 1261 | |
| 1262 | err = unzGoToFirstFile(file); |
| 1263 | |
| 1264 | while (err == UNZ_OK) |
| 1265 | { |
| 1266 | char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; |
| 1267 | err = unzGetCurrentFileInfo64(file,NULL, |
| 1268 | szCurrentFileName,sizeof(szCurrentFileName)-1, |
| 1269 | NULL,0,NULL,0); |
| 1270 | if (err == UNZ_OK) |
| 1271 | { |
| 1272 | if (unzStringFileNameCompare(szCurrentFileName, |
| 1273 | szFileName,iCaseSensitivity)==0) |
| 1274 | return UNZ_OK; |
| 1275 | err = unzGoToNextFile(file); |
| 1276 | } |
| 1277 | } |
| 1278 | |
| 1279 | /* We failed, so restore the state of the 'current file' to where we |
| 1280 | * were. |
| 1281 | */ |
| 1282 | s->num_file = num_fileSaved ; |
| 1283 | s->pos_in_central_dir = pos_in_central_dirSaved ; |
| 1284 | s->cur_file_info = cur_file_infoSaved; |
| 1285 | s->cur_file_info_internal = cur_file_info_internalSaved; |
| 1286 | return err; |
| 1287 | } |
| 1288 | |
| 1289 |
nothing calls this directly
no test coverage detected