- assert(written == size);
-}
-
-StringOutputStream::StringOutputStream()
- : buf(std::ios_base::out)
-{
-}
-
-void StringOutputStream::write_internal(const void *data, size_t len)
-{
- buf.write((const char *)data, len);
- if (!buf.good())
- throw IOException("error writing to StringOutputStream");
-}
-
-FileOutputStream::FileOutputStream(FILE *file)
-{
- f = file;
-}
-
-FileOutputStream::~FileOutputStream()
-{
- fclose(f);
-}
-
-void FileOutputStream::write_internal(const void *data, size_t len)
-{
- size_t res;
-
- res = fwrite(data, 1, len, f);
- if (res != len) {
- throw IOException("write error");
- }
-}
-
-WrapperOutputStream::WrapperOutputStream(OutputStream &o)
- : real(o)
-{
-}
-
-void WrapperOutputStream::write_internal(const void *data, size_t len)
-{
- real.write(data, len);
-}
+ char block[T_BLOCKSIZE];
+ memset(block, 0, sizeof(block));
+ memcpy(block, &data[T_BLOCKSIZE * (blocks - 1)], T_BLOCKSIZE - padding);
+ if (tar_block_write(t, block) == -1)
+ throw IOException("Error writing final tar block");