diff options
Diffstat (limited to 'src/xd.c')
| -rw-r--r-- | src/xd.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/xd.c b/src/xd.c new file mode 100644 index 0000000..5e9644e --- /dev/null +++ b/src/xd.c @@ -0,0 +1,38 @@ +#include "xd.h" + +#include <raylib.h> +#include <stdio.h> +#include <stdlib.h> + +XdData *Xd_LoadFromFile(const char *filePath) { + FILE *file = fopen(filePath, "rb"); + + if (file == NULL) { + return NULL; + } + + XdData *data = malloc(sizeof(XdData)); + fread(data, sizeof(XdData), 1, file); + + fclose(file); + return data; +} + +void Xd_SaveFile(const char *filePath, XdData *data) { + if (data == NULL) { + printf("data is null\n"); + return; + } + + FILE *file = fopen(filePath, "wb"); + + if (file == NULL) { + perror("Failed to open a file"); + return; + } + + fwrite(data, sizeof(XdData), 1, file); + + fclose(file); + printf("saved\n"); +} |
