]> git.sesse.net Git - pistorm/blobdiff - platforms/amiga/hunk-reloc.c
Some non-working loading of file systems from disk for PiSCSI
[pistorm] / platforms / amiga / hunk-reloc.c
index 3b92e339af17249d5aea002f1ec1c94dbab75e33..b1c2e32c815174503fb0be5a40bc672805069bb4 100644 (file)
@@ -8,6 +8,7 @@
 #include <endian.h>
 #include "hunk-reloc.h"
 #include "piscsi/piscsi-enums.h"
+#include "piscsi/piscsi.h"
 
 #ifdef FAKESTORM
 #define lseek64 lseek
@@ -247,3 +248,27 @@ fail:;
 
     return -1;
 }
+
+int load_fs(struct piscsi_fs *fs, char *dosID) {
+    char filename[256];
+    memset(filename, 0x00, 256);
+    sprintf(filename, "./data/fs/%c%c%c.%d", dosID[0], dosID[1], dosID[2], dosID[3]);
+
+    FILE *in = fopen(filename, "rb");
+    if (in == NULL)
+        return -1;
+
+    fseek(in, 0, SEEK_END);
+    uint32_t file_size = ftell(in);
+    fseek(in, 0, SEEK_SET);
+
+    fs->binary_data = malloc(file_size);
+    fread(fs->binary_data, file_size, 1, in);
+    process_hunks(in, &fs->h_info, fs->relocs, 0x0);
+    fs->h_info.byte_size = file_size;
+    fs->h_info.alloc_size = file_size + add_size;
+
+    fclose(in);
+
+    return 0;
+}