summaryrefslogtreecommitdiff
path: root/src/Signature.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-07-12 15:09:03 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-07-12 15:09:03 +0000
commitaec1e9e7e10de695345a6692acf1297f896baa0a (patch)
tree6a45aa97414f2683265f620c1a9017e8e91f6be0 /src/Signature.cc
parent525bdbc4aac3d8b7c1cce59af0549631afddef02 (diff)
2008-07-13 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added the ability to save signature when download is completed if signature is available. The filename of signature file is the path to download file followed by ".sig". If it already exists, then signature will not be saved. * src/RequestGroupMan.cc * src/Signature.cc * test/SignatureTest.cc
Diffstat (limited to 'src/Signature.cc')
-rw-r--r--src/Signature.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Signature.cc b/src/Signature.cc
index 5672034e..2b3c2d4c 100644
--- a/src/Signature.cc
+++ b/src/Signature.cc
@@ -33,6 +33,8 @@
*/
/* copyright --> */
#include "Signature.h"
+#include "File.h"
+#include <fstream>
namespace aria2 {
@@ -72,8 +74,18 @@ const std::string& Signature::getBody() const
bool Signature::save(const std::string& filepath) const
{
- // TODO not yet implemented
- return false;
+ if(File(filepath).exists()) {
+ return false;
+ }
+ std::ofstream out(filepath.c_str());
+ try {
+ out.exceptions(std::ios::failbit);
+ out << _body;
+ out.close();
+ return true;
+ } catch(const std::ios::failure& exception) {
+ return false;
+ }
}
} // namespace aria2