From 56450a708a7e5eabf237f4c3e858476ae591efaf Mon Sep 17 00:00:00 2001 From: xapantu Date: Wed, 5 Jan 2011 13:47:16 +0000 Subject: [PATCH] Added error handling in the addons code to handle path error when extracting archove files. (Feel free to remove it if you find a better way ;) ) git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7267 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/addons/zip.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/addons/zip.cpp b/src/addons/zip.cpp index 07f67d793..df13690cf 100644 --- a/src/addons/zip.cpp +++ b/src/addons/zip.cpp @@ -71,14 +71,23 @@ bool extract_zip(const std::string &from, const std::string &to) IReadFile* srcFile = file_system->createAndOpenFile(current_file.c_str()); IWriteFile* dstFile = file_system->createAndWriteFile((to+"/"+current_file).c_str()); - if (IFileSystem_copyFileToFile(dstFile, srcFile) < 0) + if(dstFile == NULL) { - printf("Could not copy '%s' from archive '%s'.\n", - current_file.c_str(), from.c_str()); - printf("This is ignored, but the addon might not work.\n"); + printf("Couldn't open the file '%s', and copy the archive files in it.\n", + (to+"/"+current_file).c_str()); + printf("The directory might not exist.\n"); + } + else + { + if (IFileSystem_copyFileToFile(dstFile, srcFile) < 0) + { + printf("Could not copy '%s' from archive '%s'.\n", + current_file.c_str(), from.c_str()); + printf("This is ignored, but the addon might not work.\n"); + } + dstFile->drop(); } srcFile->drop(); - dstFile->drop(); } // Remove the zip from the filesystem to save memory and avoid // problem with a name conflict. Note that we have to convert