/* */ #include "Signature.h" #include #include "File.h" namespace aria2 { Signature::Signature() {} Signature::~Signature() {} void Signature::setType(const std::string& type) { _type = type; } void Signature::setFile(const std::string& file) { _file = file; } void Signature::setBody(const std::string& body) { _body = body; } bool Signature::save(const std::string& filepath) const { if(File(filepath).exists()) { return false; } std::string tempFilepath = filepath; tempFilepath += "__temp"; { std::ofstream out(tempFilepath.c_str(), std::ios::binary); if(!out) { return false; } out << _body; out.flush(); if(!out) { return false; } } return File(tempFilepath).renameTo(filepath); } } // namespace aria2