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