03 August 2010

Creating a TAR file in C++

I just wrote a C++ class creating a Tar file. The source code is available at:http://github.com/.../tarball.h. Creating such archive is useful when a web server should return a set of files or when a tool generates a whole bunch of files.


~> g++ -Wall -I ${PATH_TO_SRC}/cclindenb/src/core
~> ./a.out
~> tar tvf archive.tar
-rw-r--r-- pierre/users 14 2010-08-03 20:50 myfiles/item1.txt
-rw-r--r-- pierre/users 14 2010-08-03 20:50 myfiles/item2.txt
-rw-r--r-- pierre/users 692 2010-08-03 20:50 myfiles/code.cpp

tar xvf archive.tar --to-stdout myfiles/item1.txt 2> /dev/null
Hello World 1

That's it,


Anonymous said...

Very good program

jValdron said...

Pretty useful, thanks!

jValdron said...

Pretty useful, thanks!

Amaresh said...

Thank you so much. Saved my time....

Adriel said...

Thank you for posting your code!