Tar library for windows

Started by
0 comments, last by flangazor 19 years, 6 months ago
i was just wondering if anyone had or knew where i could get either tar souce for windows (as their website only has it for linux and using the files to consturct proper installation would be something i really dont want to do) or the necessary tar libs and include (and dlls?) for a MinGW32 compiler on Windows? if so, thats great, if not... then yeah, we'll probably end up writing out our archive method if that the case, which owuld be quite an annoyance...
- relpats_eht
Advertisement
libtar

It's not too hard to write yourself. Everything is in blocks of 512 bytes. You read in 512 bytes for the first file's header and check the file/directory/symlink flag. If its a file, you figure out its size and read the size (ceiling to the next 512 bytes) and spit out the file. If it's a directory, you create the directory. Then you keep reading the 512 bytes until you are done.

union tar_header{char char_buf[512];struct{	char name[100];	char mode[8];	char uid[8];	char gid[8];	char size[12];	char mtime[12];	char chksum[8];	char typeflag;	char linkname[100];	char magic[6];	char version[2];	char uname[32];	char gname[32];	char devmajor[8];	char devminor[8];	char prefix[155];	char padding[12];	char *gnu_longname;	char *gnu_longlink;}header;};


If you are looking for a specific file in the tar.gz you are making (since you asked about gz before) then you may be please to know that gz is a linear format. This means that as you unpack your file you can read the tar header on the fly and if it's the right file you can just extract what you need -otherwise keep unzipping until you find the appropriate file header.

On the other hand, if you do end up writing your own file format, you may want to do something with a table of contents and zipping on a file by file basis to find what you need more easily and extract only what you want.

gl hf

This topic is closed to new replies.

Advertisement