-rw-r--r-- | src/eyetil.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/eyetil.cc b/src/eyetil.cc index 6ccc4ae..fba8724 100644 --- a/src/eyetil.cc +++ b/src/eyetil.cc @@ -162,32 +162,42 @@ tarchive_t::tarchive_t(void *p,size_t s) : a(archive_read_new()), e(0) { archive_read_finish(a); throw std::runtime_error("failed to archive_read_open_memory()"); } } tarchive_t::~tarchive_t() { assert(a); archive_read_finish(a); } bool tarchive_t::read_next_header() { assert(a); return archive_read_next_header(a,&e)==ARCHIVE_OK; } std::string tarchive_t::entry_pathname() { assert(a); assert(e); return archive_entry_pathname(e); } bool tarchive_t::read_data_into_fd(int fd) { assert(a); return archive_read_data_into_fd(a,fd)==ARCHIVE_OK; } binary_t integrity_digest(const void *ptr,size_t size,const std::string& ukey) { md5_digester rv; std::transform( (block512_t*)ptr, ((block512_t*)ptr)+size/sizeof(block512_t), rv.updater<uint16_t>(), block512_t::tcpcksum ); rv.update( binary_t(ukey) ); return rv.final(); } + +mimewrite_tarfile::mimewrite_tarfile(tmpdir_t& d) { + f.open((fn=d.get_file("the-tarfile.tar")).c_str(),std::ios_base::in|std::ios_base::out|std::ios_base::trunc|std::ios_base::binary); +} +mimewrite_tarfile::~mimewrite_tarfile() { + unlink(fn.c_str()); +} +int mimewrite_tarfile::write(const char *buf,size_t len) { + return f.write(buf,len) ? (idigest.update(buf,len),SOAP_OK) : SOAP_ERR; +} |