lesomnus / tar

C++ implementation of TAR

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tar

C++ implementation of Tape ARchive (TAR).

Features

  • Unix Standard TAR

Example

Write

#include <fstream>
#include <iostream>

#include <tar/ustar.hpp>

int main(int argc, char* argv[]) {
	std::ofstream dst("foo.tar");

	tar::ustar::ostream o(dst.rdbuf());
	o.next(tar::header{.path = "Burger"});
	o << "Royale with Cheese" << std::endl;

	return 0;
}

Read

#include <cassert>
#include <fstream>
#include <iostream>
#include <sstream>

#include <tar/ustar.hpp>

int main(int argc, char* argv[]) {
	std::ifstream src("foo.tar");

	tar::ustar::istream i(src.rdbuf());

	tar::header h;
	i.next(h);
	assert("Burger" == h.path);

	std::stringstream body;
	body << i.rdbuf();
	assert("Royale with Cheese\n" == body.str());

	return 0;
}

About

C++ implementation of TAR


Languages

Language:C++ 89.0%Language:CMake 7.9%Language:Dockerfile 2.6%Language:Shell 0.5%