From 5657cc859f6e1853a9f62f4a221d535a3e5be55c Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Fri, 7 Nov 2003 09:59:29 +0000 Subject: [PATCH] Add better checking and error messages. --- stepmania/PBProject/Installer/Processor.cpp | 15 +++++++++++---- stepmania/PBProject/Installer/Util.cpp | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/stepmania/PBProject/Installer/Processor.cpp b/stepmania/PBProject/Installer/Processor.cpp index 268830291c..2d7974dd98 100644 --- a/stepmania/PBProject/Installer/Processor.cpp +++ b/stepmania/PBProject/Installer/Processor.cpp @@ -43,6 +43,9 @@ mError(Processor::DefaultError), mInstalling(i) if (mInstalling) { + if (!DoesFileExist(path)) + throw CString("Archive file not present."); + char archivePath[] = "/tmp/installerXXXXXX.tar"; int fd = mkstemps(archivePath, 4); @@ -52,12 +55,16 @@ mError(Processor::DefaultError), mInstalling(i) mPath = archivePath; char toolPath[] = "/usr/bin/gunzip"; - - if(CallTool2(true, -1, fd, -1, toolPath, "-c", path.c_str(), NULL)) - { + + try { + if(CallTool2(true, -1, fd, -1, toolPath, "-c", path.c_str(), NULL)) + throw CString("Archive file not handled correctly."); + } catch (CString& e) { + close(fd); unlink(mPath); - throw CString("Archive file not handled correctly or not present."); + throw; } + close(fd); } else mPath = path; diff --git a/stepmania/PBProject/Installer/Util.cpp b/stepmania/PBProject/Installer/Util.cpp index b02806d97b..eb45aaa816 100644 --- a/stepmania/PBProject/Installer/Util.cpp +++ b/stepmania/PBProject/Installer/Util.cpp @@ -119,6 +119,8 @@ err: int CallTool3(bool blocking, int fd_in, int fd_out, int fd_err, const char *path, char *const *arguments) { + if (!DoesFileExist(path)) + throw CString("The tool \"") + path + "\" does not exist."; pid_t pid = fork(); switch (pid)