#include "t_update.c"
#include "l_lsl.c"
#include "u_debug.c"
+#include "u_file.c"
#endif
return res;
}
+
+
+U_FILE* u_fopen(const char *path, const char *mode) {
+ return fopen(path, mode);
+}
+
+void u_fclose(U_FILE *f) {
+ fclose(f);
+}
+
+int u_fgetc(U_FILE *f) {
+ return fgetc(f);
+}
--- /dev/null
+#include "u_file.h"
+
+const char *u_file_read(const char *path) {
+ u32 len = 16;
+ u32 index = 0;
+ char *buf = u_malloc(len);
+ char c;
+ U_FILE *f = u_fopen(path, "r");
+ if (f == LRTS_NULL) {
+ return LRTS_NULL;
+ }
+
+ while ((c = u_fgetc(f)) >= 0) {
+ if (index >= len) {
+ len *= 2;
+ buf = u_realloc(buf, len);
+ }
+ buf[index++] = c;
+ }
+
+ return buf;
+}
--- /dev/null
+#ifndef U_FILE_H__
+#define U_FILE_H__
+
+U_FILE* u_fopen(const char *path, const char *mode);
+
+void u_fclose(U_FILE *f);
+
+int u_fgetc(U_FILE *f);
+
+/* reads a file into a memory buffer
+ * allocated with u_malloc */
+const char *u_file_read(const char *path);
+
+#endif