diff options
-rw-r--r-- | cpp/src/Slice/FileTracker.cpp | 82 | ||||
-rw-r--r-- | cpp/src/Slice/FileTracker.h | 6 | ||||
-rw-r--r-- | cpp/src/slice2java/Main.cpp | 9 |
3 files changed, 18 insertions, 79 deletions
diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp index fbba124fc3b..bfb253931c1 100644 --- a/cpp/src/Slice/FileTracker.cpp +++ b/cpp/src/Slice/FileTracker.cpp @@ -10,12 +10,7 @@ #include <Slice/FileTracker.h> #include <IceUtil/ConsoleUtil.h> - -#ifdef _WIN32 -# include <direct.h> -#else -# include <unistd.h> -#endif +#include <IceUtil/FileUtil.h> using namespace IceUtilInternal; using namespace std; @@ -98,15 +93,11 @@ Slice::FileTracker::setSource(const string& source) } void -Slice::FileTracker::setOutput(const string& output, bool error) +Slice::FileTracker::error() { - assert(!_source.empty()); - _errors.insert(make_pair(_source, output)); - if(error) - { - _generated.erase(_curr); - _curr = _generated.end(); - } + assert(_curr != _generated.end()); + _generated.erase(_curr); + _curr = _generated.end(); } void @@ -132,19 +123,11 @@ Slice::FileTracker::cleanup() { if(!p->second) { -#ifdef _WIN32 - _unlink(p->first.c_str()); -#else - unlink(p->first.c_str()); -#endif + IceUtilInternal::unlink(p->first); } else { -#ifdef _WIN32 - _rmdir(p->first.c_str()); -#else - rmdir(p->first.c_str()); -#endif + IceUtilInternal::rmdir(p->first); } } } @@ -153,57 +136,18 @@ void Slice::FileTracker::dumpxml() { consoleOut << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; - consoleOut << "<generated>" << endl; - for(map<string, string>::const_iterator p = _errors.begin(); p != _errors.end(); ++p) + for(map<string, list<string> >::const_iterator p = _generated.begin(); p != _generated.end(); ++p) { - consoleOut << " <source name=\"" << p->first << "\""; - - map<string, list<string> >::const_iterator q = _generated.find(p->first); - if(q == _generated.end()) - { - consoleOut << " error=\"true\">" << endl; - } - else + if(!p->second.empty()) { - consoleOut << ">" << endl; - for(list<string>::const_iterator r = q->second.begin(); r != q->second.end(); ++r) + consoleOut << " <source name=\"" << p->first << "\">"; + for(list<string>::const_iterator q = p->second.begin(); q != p->second.end(); ++q) { - consoleOut << " <file name=\"" << *r << "\"/>" << endl; + consoleOut << " <file name=\"" << *q << "\"/>" << endl; } + consoleOut << " </source>" << endl; } - consoleOut << " <output>" << escape(p->second) << "</output>" << endl; - consoleOut << " </source>" << endl; } consoleOut << "</generated>" << endl; } - -string -Slice::FileTracker::escape(const string& str) const -{ - ostringstream ostr; - - for(string::const_iterator p = str.begin(); p != str.end(); ++p) - { - switch(*p) - { - case '<': - ostr << "<"; - break; - case '>': - ostr << ">"; - break; - case '&': - ostr << "&"; - break; - case '"': - ostr << """; - break; - default: - ostr << *p; - break; - } - } - - return ostr.str(); -} diff --git a/cpp/src/Slice/FileTracker.h b/cpp/src/Slice/FileTracker.h index 1826e52a495..35151c9d5b3 100644 --- a/cpp/src/Slice/FileTracker.h +++ b/cpp/src/Slice/FileTracker.h @@ -52,20 +52,16 @@ public: static FileTrackerPtr instance(); void setSource(const std::string&); - void setOutput(const std::string&, bool); void addFile(const std::string&); void addDirectory(const std::string&); - + void error(); void cleanup(); void dumpxml(); private: - std::string escape(const std::string&) const; - std::list<std::pair< std::string, bool> > _files; std::string _source; - std::map<std::string, std::string> _errors; std::map<std::string, std::list<std::string> > _generated; std::map<std::string, std::list<std::string> >::iterator _curr; }; diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index a1ff63c6127..5bb0c638d84 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -309,6 +309,7 @@ compile(const vector<string>& argv) if(cppHandle == 0) { + FileTracker::instance()->error(); status = EXIT_FAILURE; break; } @@ -336,6 +337,7 @@ compile(const vector<string>& argv) if(!icecpp->close()) { p->destroy(); + FileTracker::instance()->error(); return EXIT_FAILURE; } @@ -379,10 +381,6 @@ compile(const vector<string>& argv) ChecksumMap m = createChecksums(p); copy(m.begin(), m.end(), inserter(checksums, checksums.begin())); } - if(listGenerated) - { - FileTracker::instance()->setOutput(os.str(), false); - } } catch(const Slice::FileException& ex) { @@ -393,6 +391,7 @@ compile(const vector<string>& argv) p->destroy(); consoleErr << argv[0] << ": error: " << ex.reason() << endl; status = EXIT_FAILURE; + FileTracker::instance()->error(); break; } } @@ -441,7 +440,7 @@ compile(const vector<string>& argv) } } - if(listGenerated && status == EXIT_SUCCESS) + if(listGenerated) { FileTracker::instance()->dumpxml(); } |