2020 */
2121
2222
23- #include < iomanip>
24- #include < iostream>
25- #include < sstream>
26-
2723#include < boost/algorithm/string.hpp>
2824#include < openssl/sha.h>
2925
@@ -61,7 +57,8 @@ namespace snapper
6157 SN_THROW (Exception (_ (" Failed to load info.xml." )));
6258 }
6359
64- content = boost::join (cmd.get_stdout (), " \n " );
60+ if (!cmd.get_stdout ().empty ())
61+ content = boost::join (cmd.get_stdout (), " \n " ) + " \n " ;
6562
6663 y2mil (*this );
6764 }
@@ -76,17 +73,14 @@ namespace snapper
7673 }
7774
7875 unsigned char hash[SHA256_DIGEST_LENGTH ];
79- SHA256 (reinterpret_cast <const unsigned char *>(content.c_str ()), content.length (),
80- hash);
76+ SHA256 (reinterpret_cast <const unsigned char *>(content.c_str ()), content.length (), hash);
8177
82- std::stringstream ss;
83- for (int i = 0 ; i < SHA256_DIGEST_LENGTH ; i++)
84- {
85- ss << std::hex << std::setw (2 ) << std::setfill (' 0' )
86- << static_cast <int >(hash[i]);
87- }
78+ char buf[2 * SHA256_DIGEST_LENGTH + 1 ];
8879
89- return ss.str ();
80+ for (int i = 0 ; i < SHA256_DIGEST_LENGTH ; ++i)
81+ snprintf (&buf[2 * i], 3 , " %02x" , hash[i]);
82+
83+ return buf;
9084 }
9185
9286
@@ -143,6 +137,7 @@ namespace snapper
143137 std::ostream& operator <<(std::ostream& s, const CmdMetaParse& cmd_metaparse)
144138 {
145139 SnapshotMeta meta = cmd_metaparse.get_meta ();
140+
146141 s << " path: " << cmd_metaparse.path
147142 << " , checksum: " << cmd_metaparse.get_checksum ()
148143 << " , state: " << toString (meta.state ) << " , date: " << meta.date
0 commit comments