summaryrefslogtreecommitdiff
path: root/cpp/src/slice2cpp/Gen.cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2009-01-13 17:58:32 -0330
committerMatthew Newhook <matthew@zeroc.com>2009-01-13 17:58:32 -0330
commitefea74327637afce0a7f83b24d8c2f8b1d224f73 (patch)
treefda54ee1f4361dd3448c96753593fda264ce26cc /cpp/src/slice2cpp/Gen.cpp
parentAdded patch for mcpp 2.7.2 (diff)
downloadice-efea74327637afce0a7f83b24d8c2f8b1d224f73.tar.bz2
ice-efea74327637afce0a7f83b24d8c2f8b1d224f73.tar.xz
ice-efea74327637afce0a7f83b24d8c2f8b1d224f73.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3640 - If slice2java errors out generated files are left behind
- Added file tracker - Added calls to file tracker when files or directories are created. - All translators cleanup created files if interrupted, or if they fail. - Normalized various error messages. - Fixed bug with slice2cs which would not correctly check if the impl files were created. Squashed commit of the following: commit 0fec143af219d59dcec5b91cb96a79179f73bd0d Author: Matthew Newhook <matthew@zeroc.com> Date: Tue Jan 13 17:57:25 2009 -0330 Fixed FileException for VC6. commit 38b22497c751ad9b2f86af2d44e87a23c0049d9c Merge: df29064... 4421a3d... Author: Matthew Newhook <matthew@zeroc.com> Date: Tue Jan 13 17:55:49 2009 -0330 Merged R3_3_branch. commit df290649637685bfff4f777ccf53f4f04fda71a0 Author: Matthew Newhook <matthew@zeroc.com> Date: Tue Jan 13 17:45:18 2009 -0330 move checksum writing outside loop commit a9bb2356167b1f9259ce2d1f1b43d40b7fd0ce82 Author: Matthew Newhook <matthew@zeroc.com> Date: Tue Jan 13 17:35:00 2009 -0330 added quotes commit a2f3d7a2414d08ebdc290222b8e97d8b203cc9ab Author: Matthew Newhook <matthew@zeroc.com> Date: Tue Jan 13 17:21:27 2009 -0330 can't -> cannot commit c3113e33a3687cae369bf7803e4f1d18c9141762 Author: Matthew Newhook <matthew@zeroc.com> Date: Tue Jan 13 17:10:12 2009 -0330 minor fixes to output. commit 2a17d6e1b6c0e5eed8be79b8353ca3c06572e19c Author: U-WIN-5WBK5GD0FYQ\matthew <matthew@WIN-5WBK5GD0FYQ.(none)> Date: Tue Jan 13 12:05:46 2009 -0800 windows fixes. commit d8d4f6dc35043fb71b599dac7171fee0c2bb87bf Author: Matthew Newhook <matthew@zeroc.com> Date: Tue Jan 13 15:58:21 2009 -0330 remove debugging. commit f1e4d7a55e13fea4c0b84244fb437bd391fbe538 Author: Matthew Newhook <matthew@zeroc.com> Date: Tue Jan 13 15:53:37 2009 -0330 Added FileTracker. Added file tracking, and cleanup to lots of translators. commit 33dbfb0124509779bd2d95bbac06a02ca9b907ac Author: Matthew Newhook <matthew@zeroc.com> Date: Tue Jan 13 09:42:16 2009 -0330 http://bugzilla/bugzilla/show_bug.cgi?id=3640 If slice2java errors out generated files are left behind
Diffstat (limited to 'cpp/src/slice2cpp/Gen.cpp')
-rw-r--r--cpp/src/slice2cpp/Gen.cpp54
1 files changed, 26 insertions, 28 deletions
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index a577c67541f..c593e3dcd21 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -7,12 +7,14 @@
//
// **********************************************************************
+#include <IceUtil/DisableWarnings.h>
#include <Gen.h>
#include <Slice/Util.h>
#include <Slice/CPlusPlusUtil.h>
#include <IceUtil/Functional.h>
#include <IceUtil/Iterator.h>
#include <Slice/Checksum.h>
+#include <Slice/FileTracker.h>
#include <limits>
#include <sys/stat.h>
@@ -34,8 +36,8 @@ getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2)
return deprecateSymbol;
}
-Slice::Gen::Gen(const string& name, const string& base, const string& headerExtension,
- const string& sourceExtension, const vector<string>& extraHeaders, const string& include,
+Slice::Gen::Gen(const string& base, const string& headerExtension, const string& sourceExtension,
+ const vector<string>& extraHeaders, const string& include,
const vector<string>& includePaths, const string& dllExport, const string& dir,
bool imp, bool checksum, bool stream, bool ice) :
_base(base),
@@ -74,28 +76,34 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte
struct stat st;
if(stat(fileImplH.c_str(), &st) == 0)
{
- cerr << name << ": `" << fileImplH << "' already exists - will not overwrite" << endl;
- return;
+ ostringstream os;
+ os << fileImplH << "' already exists - will not overwrite";
+ throw FileException(__FILE__, __LINE__, os.str());
}
if(stat(fileImplC.c_str(), &st) == 0)
{
- cerr << name << ": `" << fileImplC << "' already exists - will not overwrite" << endl;
- return;
+ ostringstream os;
+ os << fileImplC << "' already exists - will not overwrite";
+ throw FileException(__FILE__, __LINE__, os.str());
}
implH.open(fileImplH.c_str());
if(!implH)
{
- cerr << name << ": can't open `" << fileImplH << "' for writing" << endl;
- return;
+ ostringstream os;
+ os << "cannot open `" << fileImplH << "': " << strerror(errno);
+ throw FileException(__FILE__, __LINE__, os.str());
}
+ FileTracker::instance()->addFile(fileImplH);
implC.open(fileImplC.c_str());
if(!implC)
{
- cerr << name << ": can't open `" << fileImplC << "' for writing" << endl;
- return;
+ ostringstream os;
+ os << "cannot open `" << fileImplC << "': " << strerror(errno);
+ throw FileException(__FILE__, __LINE__, os.str());
}
+ FileTracker::instance()->addFile(fileImplC);
string s = fileImplH;
if(_include.size())
@@ -119,16 +127,20 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte
H.open(fileH.c_str());
if(!H)
{
- cerr << name << ": can't open `" << fileH << "' for writing" << endl;
- return;
+ ostringstream os;
+ os << "cannot open `" << fileH << "': " << strerror(errno);
+ throw FileException(__FILE__, __LINE__, os.str());
}
+ FileTracker::instance()->addFile(fileH);
C.open(fileC.c_str());
if(!C)
{
- cerr << name << ": can't open `" << fileC << "' for writing" << endl;
- return;
+ ostringstream os;
+ os << "cannot open `" << fileC << "': " << strerror(errno);
+ throw FileException(__FILE__, __LINE__, os.str());
}
+ FileTracker::instance()->addFile(fileC);
printHeader(H);
printHeader(C);
@@ -158,20 +170,6 @@ Slice::Gen::~Gen()
}
}
-bool
-Slice::Gen::operator!() const
-{
- if(!H || !C)
- {
- return true;
- }
- if(_impl && (!implH || !implC))
- {
- return true;
- }
- return false;
-}
-
void
Slice::Gen::generate(const UnitPtr& p)
{