inline bool operator==(path_t const &a, path_t const &b) { if (!a || !b) return a.c_str() == b.c_str(); return a.length() == b.length() && ::strcmp(a.c_str(), b.c_str()) == 0; }
hasher::digest_rc md5_hasher::hex_digest(path_t const& fp) const { std::ifstream fh(fp.c_str(), std::ifstream::in | std::ifstream::binary); digest_rc rc(hex_digest(fh)); fh.close(); return rc; }
auto teardown = [&]() { fs::remove_all(sig_path); fs::remove_all(delta_path); fs::remove_all(target_path); fs::remove_all(config.cache_path); }; setup(); SECTION("it should generate a signature") { rs_result rc; REQUIRE(file_manager.is_readable(archive_011)); // generate sig REQUIRE(RS_DONE == encoder.signature(archive_011.c_str(), sig_path.c_str())); // verify the checksum REQUIRE(sig_checksum == md5_hasher.hex_digest(sig_path).digest); } SECTION("it should generate a delta") { REQUIRE(RS_DONE == encoder.signature(archive_011.c_str(), sig_path.c_str())); REQUIRE(file_manager.is_readable(sig_path)); REQUIRE(file_manager.is_readable(archive_012)); REQUIRE(file_manager.is_writable(delta_path)); REQUIRE(RS_DONE == encoder.delta(sig_path.c_str(), archive_012.c_str(), delta_path.c_str())); REQUIRE(delta_checksum == md5_hasher.hex_digest(delta_path).digest);
ArchiveWriter::ArchiveWriter(KernelTransaction &tx, const path_t &path, RsaKeyPair *keypair): keypair(keypair), tx(tx), state(State::Initial){ this->stream.reset(new boost::iostreams::stream<TransactedFileSink>(this->tx, path.c_str())); }
bool subpath(path_t const &root) const {return subpath(root.c_str());}
T jcast(path_t const &p) { return jcast<T>(p.c_str()); }
T jcast(path_t const &p) { return ::crystax::jni::details::jcast_helper<T, const char *>::cast(p.c_str()); }