Jump to content
  • Advertisement
Sign in to follow this  

Tar library for windows

This topic is 5411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post

Link to post
Share on other sites

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];
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;

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!