Skip to content

canoi12/sabotar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

saboTar

sabotar is a c lib for read and write tar files

load and list

#define SBTAR_IMPLEMENTATION
#include "sabotar.h"

#include <stdio.h>

int main(int argc, char** argv) {
	sbtar_t tar;
	sbtar_load(&tar, "file.tar");
	// find for filename
	if (sbtar_find(&tar, "test.txt")) {
		sbtar_header_t h;
		sbtar_header(&tar, &h);
		printf("size: %d\n", h.size);
	}
	// list all files
	sbtar_ls(&tar);
	sbtar_close(&tar);
	return 0;
}

create and write

#define SBTAR_IMPLEMENTATION
#include "sabotar.h"

#include <string.h>

int main(int argc, char** argv) {
	sbtar_t tar;
	sbtar_new(&tar, "file.tar");
	const char* str = "hello world";
	sbtar_write(&tar, "test.txt", str, strlen(str));
	const char* str2 = "sabotar";
	sbtar_write(&tar, "sabotar/sabotar.txt", str2, strlen(str2));
	sbtar_ls(&tar);
	sbtar_close(&tar);
	return 0;
}

References and Inspirations

About

c lib for read and write tar files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published