From efea74327637afce0a7f83b24d8c2f8b1d224f73 Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Tue, 13 Jan 2009 17:58:32 -0330 Subject: 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 Date: Tue Jan 13 17:57:25 2009 -0330 Fixed FileException for VC6. commit 38b22497c751ad9b2f86af2d44e87a23c0049d9c Merge: df29064... 4421a3d... Author: Matthew Newhook Date: Tue Jan 13 17:55:49 2009 -0330 Merged R3_3_branch. commit df290649637685bfff4f777ccf53f4f04fda71a0 Author: Matthew Newhook Date: Tue Jan 13 17:45:18 2009 -0330 move checksum writing outside loop commit a9bb2356167b1f9259ce2d1f1b43d40b7fd0ce82 Author: Matthew Newhook Date: Tue Jan 13 17:35:00 2009 -0330 added quotes commit a2f3d7a2414d08ebdc290222b8e97d8b203cc9ab Author: Matthew Newhook Date: Tue Jan 13 17:21:27 2009 -0330 can't -> cannot commit c3113e33a3687cae369bf7803e4f1d18c9141762 Author: Matthew Newhook Date: Tue Jan 13 17:10:12 2009 -0330 minor fixes to output. commit 2a17d6e1b6c0e5eed8be79b8353ca3c06572e19c Author: U-WIN-5WBK5GD0FYQ\matthew Date: Tue Jan 13 12:05:46 2009 -0800 windows fixes. commit d8d4f6dc35043fb71b599dac7171fee0c2bb87bf Author: Matthew Newhook Date: Tue Jan 13 15:58:21 2009 -0330 remove debugging. commit f1e4d7a55e13fea4c0b84244fb437bd391fbe538 Author: Matthew Newhook 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 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 --- cpp/src/Slice/FileTracker.cpp | 117 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 cpp/src/Slice/FileTracker.cpp (limited to 'cpp/src/Slice/FileTracker.cpp') diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp new file mode 100644 index 00000000000..438670cf2f8 --- /dev/null +++ b/cpp/src/Slice/FileTracker.cpp @@ -0,0 +1,117 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include + +#ifdef _WIN32 +# include +#endif + +using namespace std; + +Slice::FileException::FileException(const char* file, int line, const string& r) : + Exception(file, line), + _reason(r) +{ +} + +Slice::FileException::~FileException() throw() +{ +} + +const char* Slice::FileException::_name = "Slice::FileException"; + +string +Slice::FileException::ice_name() const +{ + return _name; +} + +void +Slice::FileException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ": " << _reason; +} + +IceUtil::Exception* +Slice::FileException::ice_clone() const +{ + return new FileException(*this); +} + +void +Slice::FileException::ice_throw() const +{ + throw *this; +} + +string +Slice::FileException::reason() const +{ + return _reason; +} + + +static Slice::FileTrackerPtr Instance; + +Slice::FileTracker::FileTracker() +{ +} + +Slice::FileTracker::~FileTracker() +{ +} + +// The file tracker is not supposed to be thread safe. +Slice::FileTrackerPtr +Slice::FileTracker::instance() +{ + if(!Instance) + { + Instance = new FileTracker(); + } + return Instance; +} + +void +Slice::FileTracker::addFile(const string& file) +{ + _files.push_front(make_pair(file, false)); +} + +void +Slice::FileTracker::addDirectory(const string& dir) +{ + _files.push_front(make_pair(dir, true)); +} + +void +Slice::FileTracker::cleanup() +{ + for(list >::const_iterator p = _files.begin(); p != _files.end(); ++p) + { + if(!p->second) + { +#ifdef _WIN32 + _unlink(p->first.c_str()); +#else + unlink(p->first.c_str()); +#endif + } + else + { +#ifdef _WIN32 + _rmdir(p->first.c_str()); +#else + rmdir(p->first.c_str()); +#endif + } + } +} -- cgit v1.2.3