From: Bastian Dehn Date: Sat, 23 Dec 2017 22:50:28 +0000 (+0100) Subject: add: calc ISO9660 overhead X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=0bf95fabbc7a3ee1692aa204e57f233595c7be00;p=discspan.git add: calc ISO9660 overhead --- diff --git a/Makefile b/Makefile index 24d7b49..03e34e0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC=/usr/bin/gcc -CFLAGS=-Wall +CFLAGS=-Wall -lm BINPATH=/usr/bin diff --git a/discspan.c b/discspan.c index 9bea789..a304d28 100644 --- a/discspan.c +++ b/discspan.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include "file_size.h" @@ -119,14 +120,21 @@ int splitter(struct file_size *input, const char *output, unsigned long long splitgroesse, int length) { struct file_size *rest = (struct file_size *)malloc(length * sizeof(struct file_size)); + unsigned long long filesize = 0; int restcount = 0; FILE *out; + // First 32768 bytes are unused by ISO9660 + splitgroesse -= 32768; + out = fopen(output, "w"); for(int i = 0; i <= length; i++) { + // ISO9660 filesystem overhead + filesize = 33 + strlen(input[i].name) + input[i].fsize; + filesize = ceil(filesize/2048) * 2048; // filesize inklusive overhead - if(splitgroesse >= input[i].fsize) { - splitgroesse -= input[i].fsize; + if(splitgroesse >= filesize) { + splitgroesse -= filesize; fprintf(out, "%s\n", input[i].name); } else { rest[restcount++] = input[i];