changed checking for directory in zip file in last step
authorHolger Schemel <holger.schemel@virtion.de>
Fri, 20 Dec 2024 18:58:56 +0000 (19:58 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Fri, 20 Dec 2024 13:01:21 +0000 (14:01 +0100)
src/libgame/setup.c

index 1cad240d900b825e252d6798e8a39a4fb6db0ac6..09f7d2ebb23ba368c8c8ede056aee291ba5ac29b 100644 (file)
@@ -3769,17 +3769,6 @@ static int CheckZipFileForDirectoryExt(char *zip_filename, char *directory, int
   if (!strSuffix(top_dir, "/"))
     return ZIP_FILE_ERROR_DIR_NOT_FOUND;
 
-  // get path of extracted top level directory
-  top_dir_path = getPath2(directory, top_dir);
-
-  // remove trailing directory separator from top level directory path
-  // (required to be able to check for file and directory in next step)
-  top_dir_path[strlen(top_dir_path) - 1] = '\0';
-
-  // check if zip file's top level directory already exists in target directory
-  if (fileExists(top_dir_path))                // (checks for file and directory)
-    return ZIP_FILE_ERROR_DIR_EXISTS;
-
   // get filename of configuration file in top level directory
   top_dir_conf_filename = getStringCat2(top_dir, conf_basename);
 
@@ -3803,6 +3792,19 @@ static int CheckZipFileForDirectoryExt(char *zip_filename, char *directory, int
   if (!found_top_dir_conf_filename)
     return ZIP_FILE_ERROR_CONF_NOT_FOUND;
 
+  // zip file seems valid -- now check if included directory already exists
+
+  // get path of extracted top level directory
+  top_dir_path = getPath2(directory, top_dir);
+
+  // remove trailing directory separator from top level directory path
+  // (required to be able to check for file and directory in next step)
+  top_dir_path[strlen(top_dir_path) - 1] = '\0';
+
+  // check if zip file's top level directory already exists in target directory
+  if (fileExists(top_dir_path))                // (checks for file and directory)
+    return ZIP_FILE_ERROR_DIR_EXISTS;
+
   return ZIP_FILE_OK;
 }