[Cppfcplib] r14325 - trunk/apps/CppFCPLib

mkolar at freenetproject.org mkolar at freenetproject.org
Tue Jul 24 22:28:24 UTC 2007


Author: mkolar
Date: 2007-07-24 22:28:24 +0000 (Tue, 24 Jul 2007)
New Revision: 14325

Modified:
   trunk/apps/CppFCPLib/Node.cpp
   trunk/apps/CppFCPLib/Node.h
Log:
*  delete file created by library in TestDDA
*  GiveOpennetRef in GetNode



Modified: trunk/apps/CppFCPLib/Node.cpp
===================================================================
--- trunk/apps/CppFCPLib/Node.cpp	2007-07-24 22:24:33 UTC (rev 14324)
+++ trunk/apps/CppFCPLib/Node.cpp	2007-07-24 22:28:24 UTC (rev 14325)
@@ -242,6 +242,7 @@
 {
   Message::Ptr m = Message::factory( std::string("GetNode") );
 
+  if (fields.hasField("GiveOpennetRef")) m->setField("GiveOpennetRef", fields.getField("GiveOpennetRef"));
   if (fields.hasField("WithPrivate")) m->setField("WithPrivate", fields.getField("WithPrivate"));
   if (fields.hasField("WithVolatile")) m->setField("WithVolatile", fields.getField("WithVolatile"));
 
@@ -357,6 +358,7 @@
 {
    TestDDAReplyResponse::Ptr replyResponse;
    Message::Ptr m;
+   boost::filesystem::path filePath;
 
    try
    {
@@ -371,6 +373,7 @@
        }
      }
      if (write) {
+       filePath = boost::filesystem::path( replyResponse->getWriteFilename() );
        std::ofstream os(replyResponse->getWriteFilename().c_str());
        if (os) {
          os << replyResponse->getContent();;
@@ -378,29 +381,36 @@
        }
      }
      TestDDAResponse ret = testDDAResponse(dir, readContent.str());
-     //TODO: delete created file
+     try {
+       if (write) boost::filesystem::remove( filePath );
+     } catch (boost::filesystem::basic_filesystem_error<boost::filesystem::path>& e) {
+       log().log(ERROR, e.what());
+     }
      return ret;
    }
    catch (FCPException& e)
    {
      log().log(ERROR, e.getMessage()->toString());
-     return TestDDAResponse(dir, false, false);
    }
    catch (std::logic_error& e)
    {
      log().log(FATAL, e.what()); // this should never happen... TODO: should I force shutdown?
-     return TestDDAResponse(dir, false, false);
    }
    catch (std::runtime_error& e)
    {
      log().log(ERROR, e.what());
-     return TestDDAResponse(dir, false, false);
    }
    catch (std::exception& e)
    {
      log().log(ERROR, e.what());
-     return TestDDAResponse(dir, false, false);
    }
+   // can happen if testDDAResponse throws
+   try {
+     if (write) boost::filesystem::remove( filePath );
+   } catch (boost::filesystem::basic_filesystem_error<boost::filesystem::path>& e) {
+     log().log(ERROR, e.what());
+   }
+   return TestDDAResponse(dir, false, false);
 }
 
 Message::Ptr

Modified: trunk/apps/CppFCPLib/Node.h
===================================================================
--- trunk/apps/CppFCPLib/Node.h	2007-07-24 22:24:33 UTC (rev 14324)
+++ trunk/apps/CppFCPLib/Node.h	2007-07-24 22:28:24 UTC (rev 14325)
@@ -65,6 +65,7 @@
   Message::Ptr modifyPeer(const std::string &, const AdditionalFields& = AdditionalFields());
   PeerNote modifyPeerNote(const std::string &, const std::string &, int);
   Message::Ptr removePeer(const std::string &);
+
   Message::Ptr getNode(const AdditionalFields& = AdditionalFields());
   Message::Ptr getConfig(const AdditionalFields& = AdditionalFields());
   Message::Ptr modifyConfig(Message::Ptr m);




More information about the Cppfcplib mailing list