NO

Author Topic: microtar library  (Read 1391 times)

Offline Vortex

  • Member
  • *
  • Posts: 843
    • http://www.vortex.masmcode.com
microtar library
« on: June 29, 2023, 12:59:09 PM »
Hello,

Project adapted to Pelles C Version 12 :

Quote
A lightweight tar library written in ANSI C

https://github.com/rxi/microtar

Example code from the GitHub repository :

Code: [Select]
#include <stdio.h>
#include "microtar.h"

int main(void)
{
mtar_t tar;
mtar_header_t h;
char *p;

/* Open archive for reading */
mtar_open(&tar, "test.tar", "r");

/* Print all file names and sizes */
while ( (mtar_read_header(&tar, &h)) != MTAR_ENULLRECORD ) {
  printf("%s (%d bytes)\n", h.name, h.size);
  mtar_next(&tar);
}

/* Load and print contents of file "test.txt" */
mtar_find(&tar, "test.txt", &h);
p = calloc(1, h.size + 1);
mtar_read_data(&tar, p, h.size);
printf("%s", p);
free(p);

/* Close archive */
mtar_close(&tar);
return 0;
}
Code it... That's all...

Offline cosh

  • Member
  • *
  • Posts: 33
Re: microtar library
« Reply #1 on: July 04, 2023, 01:55:17 PM »
Thank you for providing such a great library.
 :)
This library is so good and simple. I like it.

Offline Vortex

  • Member
  • *
  • Posts: 843
    • http://www.vortex.masmcode.com
Re: microtar library
« Reply #2 on: July 04, 2023, 08:58:00 PM »
Hi cosh,

Thanks for your feedback. The real provider is the author of the original code, rxi

All what I did are some minor modiicafions to compile the code with Pelles C.
Code it... That's all...

Offline John Z

  • Member
  • *
  • Posts: 841
Re: microtar library
« Reply #3 on: July 04, 2023, 10:16:26 PM »
Hi Vortex,

Another nice contribution!  Thanks.  I don't use the tar format for anything but nice to have options for Pelles C libraries.  Sometimes minor mods are the hardest  :)

John Z