calccrypto / tar Goto Github PK
View Code? Open in Web Editor NEWA simple tar implementation in C
License: MIT License
A simple tar implementation in C
License: MIT License
Hi, Your code suppose to compress the files? Or maybe I am missing something...
Hello,
When I remove a nonexistent file from an archive, I get Exiting with error due to previous error but no other errors are shown:
$ touch test1 test2 test3
$ tar -cf test.tar test1 test2 test3
$ exec r test.tar test4
Exiting with error due to previous error
Are there any plans to expand on this library, for example, to add support for gzip / xz decompression.
Many people (including myself), find libarchive more complicated than it needs to be. I believe that if this library was expanded upon, it could be a suitable alternative.
Regards.
From man major
:
[…] was deprecated in glibc 2.25, and since glibc 2.28, <sys/types.h> no longer provides these definitions.
Whenever I try to test this out I get a permission-denied error with mknod. This is the output of running "make test":
cc -Wall -std=c99 -c tar.c
ar -r libtar.a tar.o
ar: creating libtar.a
cc -Wall -std=c99 main.c -o exec -ltar -L.
rm -rf test.tar char block sym pipe folder file real out
create fake directory entries
mknod: block: Operation not permitted
make: *** [Makefile:27: test] Error 1
What is going wrong here?
I like this library, but I would love to read more documentation. In order to be able to use it I needed to read the source code, which could be avoided if there was a good documentation about how to use the function together with some little and explanatory examples.
One may compile if the -std=c11
flag is removed from the Makefile
.
tar.c:551:26: error: ‘S_IFMT’ undeclared (first use in this function)
switch (st.st_mode & S_IFMT) {
Also applies with {S_IFREG
, S_IFLINK
, S_IFCHR
, S_IFBLK
, S_IFDIR
, S_IFIFO
, S_IFSOCK
}
The block in main.c that displays help information is never executed:
if (argc == 2){
fprintf(stdout, "Usage: %s options(s) tarfile [sources]\n"\
...
}
because its condition is always satisfied by the preceding if
block, which terminates the program.
Hello,
I've spotted two issues within extract_entry()
function.
A. This conditional branch:
if ((entry -> type == CHAR) || (entry -> type == BLOCK))
is never reached as it inside another condition:
if ((entry -> type == REGULAR) || (entry -> type == NORMAL) || (entry -> type == CONTIGUOUS))
I guess the first if ()
should be moved out of the second one.
B. This condition looks redundant:
if ((entry -> type == REGULAR) || (entry -> type == NORMAL) || (entry -> type == CONTIGUOUS))
as it's already inside the same condition.
44: for(count = 0; ; count++){
45: *tar = malloc(sizeof(struct tar_t));
On line 45 memory is reserved which leads to problems, because the 'next' pointer of the structure doesn't point to NULL. The program crashes on tar_free().
I changed the line to *tar = calloc(1, sizeof(struct tar_t));
to fix this
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.