Let me explain what I'm trying to realize:
I have a encrypted tar file. I can decrypt it in memory, but obviously I can't write the decrypted data back to hard disk as a real file. The decrypted data is structured as a char* buffer in memory; how can I untar it in memory?
I can't find answer with libtar library.
I also tried to untar it with execlp("tar", "tar", "-xvO", (void*)0).
But it didn't work as I thought.
Anyone can give me a hint of the best solution? Thanks!
I suspect that libtar is the answer.
Using libtar, you can specify your own functions for opening/closing, reading and writing. From the manpage:
int tar_open(TAR **t, char *pathname, tartype_t *type, int oflags,
int mode, int options);
The
tar_open()function opens a tar archive file corresponding to the filename named by thepathnameargument. Theoflagsargument must be eitherO_RDONLYorO_WRONLY.The type argument specifies the access methods for the given file type. The
tartype_tstructure has members namedopenfunc(),closefunc(),readfunc()andwritefunc(), which are pointers to the functions for opening, closing, reading, and writing the file, respectively. If type isNULL, the file type defaults to a normal file, and the standardopen(),close(),read(), andwrite()functions are used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With