]> gitweb.hhaalo.de Git - discspan.git/commitdiff
add: calc ISO9660 overhead
authorBastian Dehn <hhaalo@arcor.de>
Sat, 23 Dec 2017 22:50:28 +0000 (23:50 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 23 Dec 2017 22:50:28 +0000 (23:50 +0100)
Makefile
discspan.c

index 24d7b49810ec884d0c5a56a8ff43ec962db0909d..03e34e00b17e5948a7aa0dfeb6b34275e4a16aea 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 CC=/usr/bin/gcc
-CFLAGS=-Wall
+CFLAGS=-Wall -lm
 
 BINPATH=/usr/bin
 
index 9bea7897fadf31f302647306306efb60dd177c6d..a304d28555f11009b24e8cd518894c86c8e537bd 100644 (file)
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <math.h>
 #include <unistd.h>
 #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];