summaryrefslogtreecommitdiff
path: root/Contrib/VPatch/Source/GenPat/main.cpp
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2018-03-31 20:38:45 +0200
committerDidier Raboud <odyx@debian.org>2018-03-31 20:38:45 +0200
commitaebc9db998aa878419eaa4c02e558c8979f38d3b (patch)
tree10d3209c157339e1f409dbe7c8196a3d0f17162e /Contrib/VPatch/Source/GenPat/main.cpp
parentfe5eccc476c65971449791086ac97473549b95d2 (diff)
Import Upstream version 3.03
Diffstat (limited to 'Contrib/VPatch/Source/GenPat/main.cpp')
-rwxr-xr-xContrib/VPatch/Source/GenPat/main.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/Contrib/VPatch/Source/GenPat/main.cpp b/Contrib/VPatch/Source/GenPat/main.cpp
index 787c5bd..03ae8c8 100755
--- a/Contrib/VPatch/Source/GenPat/main.cpp
+++ b/Contrib/VPatch/Source/GenPat/main.cpp
@@ -275,23 +275,24 @@ int _tmain( int argc, TCHAR * argv[] ) {
*iter = NULL;
}
- patch.close();
+ patch.close(); // Close the temporary patch file so we can open it again for reading
TFileOffset patchSize = POSIX::getFileSize(tempFileName.c_str());
+ char* buf = new char[patchSize];
+ if (!buf) throw _T("Out of memory"); // In case we switch to nothrow_t
// finally: copy the temporary file to the actual patch
bifstream tempF;
tempF.open(tempFileName.c_str(), std::ios_base::binary | std::ios_base::in);
+ tempF.read(buf,patchSize);
+ if (tempF.fail()) throw _T("Could not read temp file");
+ tempF.close();
+ bofstream().open(tempFileName.c_str(), std::ios_base::binary | std::ios_base::out); // empty the temporary file
+
bofstream patchF;
patchF.open(patchFileName.c_str(), std::ios_base::binary | std::ios_base::out);
- char* buf = new char[patchSize];
- tempF.read(buf,patchSize);
patchF.write(buf,patchSize);
+ if (patchF.fail()) throw _T("Could not write patch file");
delete[] buf;
- tempF.close();
-
- // now empty the temporary file
- bofstream clearF;
- clearF.open(tempFileName.c_str(), std::ios_base::binary | std::ios_base::out);
}
catch(tstring s) {
terr << _T("Error thrown: ") << s.c_str();
@@ -301,6 +302,10 @@ int _tmain( int argc, TCHAR * argv[] ) {
terr << _T("Error thrown: ") << s;
return 2;
}
+ catch(...) {
+ terr << _T("Error thrown: Unknown error!\n");
+ return 2;
+ }
} else {
terr << _T("There was a problem opening the files.\n");
return 2;