Add better checking and error messages.

This commit is contained in:
Steve Checkoway
2003-11-07 09:59:29 +00:00
parent e986f15792
commit 5657cc859f
2 changed files with 13 additions and 4 deletions
+9 -2
View File
@@ -43,6 +43,9 @@ mError(Processor::DefaultError), mInstalling(i)
if (mInstalling) if (mInstalling)
{ {
if (!DoesFileExist(path))
throw CString("Archive file not present.");
char archivePath[] = "/tmp/installerXXXXXX.tar"; char archivePath[] = "/tmp/installerXXXXXX.tar";
int fd = mkstemps(archivePath, 4); int fd = mkstemps(archivePath, 4);
@@ -53,11 +56,15 @@ mError(Processor::DefaultError), mInstalling(i)
char toolPath[] = "/usr/bin/gunzip"; char toolPath[] = "/usr/bin/gunzip";
try {
if(CallTool2(true, -1, fd, -1, toolPath, "-c", path.c_str(), NULL)) 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); unlink(mPath);
throw CString("Archive file not handled correctly or not present."); throw;
} }
close(fd);
} }
else else
mPath = path; mPath = path;
+2
View File
@@ -119,6 +119,8 @@ err:
int CallTool3(bool blocking, int fd_in, int fd_out, int fd_err, const char *path, char *const *arguments) 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(); pid_t pid = fork();
switch (pid) switch (pid)