diff options
Diffstat (limited to 'contrib/minizip/unzip.c')
-rw-r--r-- | contrib/minizip/unzip.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index 07d869e..96f9f33 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c | |||
@@ -828,7 +828,11 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) | |||
828 | unz_s* s; | 828 | unz_s* s; |
829 | int err; | 829 | int err; |
830 | 830 | ||
831 | 831 | /* We remember the 'current' position in the file so that we can jump | |
832 | * back there if we fail. | ||
833 | */ | ||
834 | unz_file_info cur_file_infoSaved; | ||
835 | unz_file_info_internal cur_file_info_internalSaved; | ||
832 | uLong num_fileSaved; | 836 | uLong num_fileSaved; |
833 | uLong pos_in_central_dirSaved; | 837 | uLong pos_in_central_dirSaved; |
834 | 838 | ||
@@ -843,25 +847,36 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) | |||
843 | if (!s->current_file_ok) | 847 | if (!s->current_file_ok) |
844 | return UNZ_END_OF_LIST_OF_FILE; | 848 | return UNZ_END_OF_LIST_OF_FILE; |
845 | 849 | ||
850 | /* Save the current state */ | ||
846 | num_fileSaved = s->num_file; | 851 | num_fileSaved = s->num_file; |
847 | pos_in_central_dirSaved = s->pos_in_central_dir; | 852 | pos_in_central_dirSaved = s->pos_in_central_dir; |
853 | cur_file_infoSaved = s->cur_file_info; | ||
854 | cur_file_info_internalSaved = s->cur_file_info_internal; | ||
848 | 855 | ||
849 | err = unzGoToFirstFile(file); | 856 | err = unzGoToFirstFile(file); |
850 | 857 | ||
851 | while (err == UNZ_OK) | 858 | while (err == UNZ_OK) |
852 | { | 859 | { |
853 | char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; | 860 | char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; |
854 | unzGetCurrentFileInfo(file,NULL, | 861 | err = unzGetCurrentFileInfo(file,NULL, |
855 | szCurrentFileName,sizeof(szCurrentFileName)-1, | 862 | szCurrentFileName,sizeof(szCurrentFileName)-1, |
856 | NULL,0,NULL,0); | 863 | NULL,0,NULL,0); |
857 | if (unzStringFileNameCompare(szCurrentFileName, | 864 | if (err == UNZ_OK) |
858 | szFileName,iCaseSensitivity)==0) | 865 | { |
859 | return UNZ_OK; | 866 | if (unzStringFileNameCompare(szCurrentFileName, |
860 | err = unzGoToNextFile(file); | 867 | szFileName,iCaseSensitivity)==0) |
868 | return UNZ_OK; | ||
869 | err = unzGoToNextFile(file); | ||
870 | } | ||
861 | } | 871 | } |
862 | 872 | ||
873 | /* We failed, so restore the state of the 'current file' to where we | ||
874 | * were. | ||
875 | */ | ||
863 | s->num_file = num_fileSaved ; | 876 | s->num_file = num_fileSaved ; |
864 | s->pos_in_central_dir = pos_in_central_dirSaved ; | 877 | s->pos_in_central_dir = pos_in_central_dirSaved ; |
878 | s->cur_file_info = cur_file_infoSaved; | ||
879 | s->cur_file_info_internal = cur_file_info_internalSaved; | ||
865 | return err; | 880 | return err; |
866 | } | 881 | } |
867 | 882 | ||