~mrms/tarum

3cd6182c74045d995c5bfe794a9045bfab2d1af6 — Marek Maškarinec 10 months ago 5ffcd72
Fix invalid handling of nonexistend files in Tar.addFile
2 files changed, 5 insertions(+), 5 deletions(-)

M README.md
M tar.c
M README.md => README.md +3 -3
@@ 11,7 11,7 @@ import (
)

fn main() {
    var err: Errno
    var err: tar.Errno
    var t: tar.Tar
        
    t, err = tar.open("test.tar", "w")


@@ 21,8 21,8 @@ fn main() {
    }
    
    t.addFile("pak.json")
    t.addFile("microtar/README.md")
    t.addFile("tar_linux.umi")
    t.addFile("pak/")
    t.addFile("README.md")
    
    err = t.finalize()
    if err != 0 {

M tar.c => tar.c +2 -2
@@ 193,8 193,6 @@ umc__tar_add_file(UmkaStackSlot *p, UmkaStackSlot *r)
	};
	strncpy(h.name, file, sizeof(h.name) - 1);

	mtar_write_header(tar, &h);

	if (S_ISDIR(st.st_mode)) {
		return;
	}


@@ 205,6 203,8 @@ umc__tar_add_file(UmkaStackSlot *p, UmkaStackSlot *r)
		return;
	}

	mtar_write_header(tar, &h);

	fseek(f, 0, SEEK_END);
	size_t size = ftell(f);
	fseek(f, 0, SEEK_SET);