]> gitweb.hhaalo.de Git - discspan.git/commitdiff
change read line
authorBastian Dehn <hhaalo@arcor.de>
Sat, 6 Sep 2025 14:28:53 +0000 (16:28 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 6 Sep 2025 14:28:53 +0000 (16:28 +0200)
libs/spandisc/src/filehandler.c

index decb4783439abe4e3d842fddabdee30aea8b0403..8f3fb525ab9f0e979af8eb2a61c0c0bb757238b6 100644 (file)
@@ -8,7 +8,7 @@
 
 #define MAX_PATH_LENGTH 255
 
-void read_file_stat(const char* path, medium_t* srcdata)
+void read_file_stat(char* path, medium_t* srcdata)
 {
        struct stat* st = malloc(sizeof(struct stat));
        file_size_t** filearray = srcdata->filearray;
@@ -17,6 +17,7 @@ void read_file_stat(const char* path, medium_t* srcdata)
        filearray = realloc(filearray, (length + 1) * sizeof(file_size_t*));
        srcdata->filearray = filearray;
        filearray[length] = malloc(sizeof(file_size_t));
+       path[strlen(path) - 1] = '\0';
        filearray[length]->name = malloc(sizeof(char) * strlen(path) + 1);
 
        stat(path, st);
@@ -34,7 +35,7 @@ void fill_array_from_file(FILE* in, medium_t* srcdata)
        char* path = malloc(sizeof(char) * MAX_PATH_LENGTH);
        memset(path, 0, MAX_PATH_LENGTH);
 
-       while (fscanf(in, "%[^\n]\n", path) == 1) {
+       while (fgets(path, MAX_PATH_LENGTH, in) != NULL) {
                read_file_stat(path, srcdata);
        }