added optional button to restart game (door, panel and touch variants)
[rocksndiamonds.git] / src / libgame / zip / miniunz.c
index 478d4a8fbb3d1eaf3af3d1fbf30de476059b2dc0..1ca632a96bb262f9069475f94eb7a8bc50824dac 100644 (file)
    See the accompanying LICENSE file for the full text of the license.
 */
 
-#if defined(__linux__)
-// Linux needs this to support file operation on files larger then 4+GB
-#  ifndef __USE_FILE_OFFSET64
-#  define __USE_FILE_OFFSET64
-#  endif
-#  ifndef __USE_LARGEFILE64
-#  define __USE_LARGEFILE64
-#  endif
-#  ifndef _LARGEFILE64_SOURCE
-#  define _LARGEFILE64_SOURCE
-#  endif
-#  ifndef _FILE_OFFSET_BIT
-#  define _FILE_OFFSET_BIT 64
-#  endif
-#endif
-
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -405,7 +389,7 @@ static int miniunz_extract_currentfile(unzFile uf, int opt_extract_without_path,
     err = unzGetCurrentFileInfo64(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
     if (err != UNZ_OK)
     {
-        debug_printf("error %d with zipfile in unzGetCurrentFileInfo\n",err);
+        debug_printf("error %d with zipfile in unzGetCurrentFileInfo\n", err);
         return err;
     }
 
@@ -644,18 +628,25 @@ char **zip_extract(char *filename, char *directory)
        return NULL;
     }
 
-    if (CHDIR(directory))      // change to target directory
+    if (CHDIR(directory) != 0)         // change to target directory
     {
-      debug_printf("Cannot change to directory '%s'!\n", directory);
+        debug_printf("Cannot change to directory '%s'!\n", directory);
 
-      unzClose(uf);
+        unzClose(uf);
 
-      return NULL;
+        return NULL;
     }
 
     int success = (miniunz_extract_all(uf, 0, 1, NULL) == UNZ_OK);
 
-    CHDIR(last_directory);     // change back to previous directory
+    if (CHDIR(last_directory) != 0)    // change back to previous directory
+    {
+        debug_printf("Cannot change to directory '%s'!\n", last_directory);
+
+        unzClose(uf);
+
+        return NULL;
+    }
 
     unzClose(uf);