summaryrefslogtreecommitdiff
path: root/src/xd.c
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-01-19 01:31:01 +0500
committerilotterytea <iltsu@alright.party>2025-01-19 01:50:45 +0500
commit940e7825753b2a72a253199cb33767e04257dbd4 (patch)
tree81623aee3418e9e49d46faa42471f41e1fb73922 /src/xd.c
parent6c4ecd35da17e07b743d4ef75e234383317d22ac (diff)
feat: xd format
Diffstat (limited to 'src/xd.c')
-rw-r--r--src/xd.c38
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");
+}