minor code cleanup
[rocksndiamonds.git] / src / libgame / zip / miniunz.c
index 478d4a8fbb3d1eaf3af3d1fbf30de476059b2dc0..cf9839b1bb6c2cb303467e05942181e4c63c8cb4 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>
@@ -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);