2021-11-30 21:29:18 -06:00
|
|
|
#ifndef RESOURCES_H
|
|
|
|
#define RESOURCES_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2023-12-18 06:45:27 -06:00
|
|
|
#include "stb_ds.h"
|
|
|
|
#include "string.h"
|
2021-11-30 21:29:18 -06:00
|
|
|
|
2023-10-09 18:10:10 -05:00
|
|
|
extern char *DATA_PATH;
|
2021-11-30 21:29:18 -06:00
|
|
|
|
|
|
|
void resources_init();
|
2023-08-27 21:57:19 -05:00
|
|
|
void fill_extensions(char *paths, const char *path, const char *ext);
|
2021-11-30 21:29:18 -06:00
|
|
|
char *get_filename_from_path(char *path, int extension);
|
|
|
|
char *get_directory_from_path(char *path);
|
2022-08-24 12:24:21 -05:00
|
|
|
char *str_replace_ext(const char *s, const char *newext);
|
2021-11-30 21:29:18 -06:00
|
|
|
FILE *res_open(char *path, const char *tag);
|
2022-02-06 10:14:57 -06:00
|
|
|
FILE *path_open(const char *tag, const char *fmt, ...);
|
|
|
|
char *make_path(const char *file);
|
2023-09-13 01:08:32 -05:00
|
|
|
char **ls(char *path);
|
2023-11-17 15:16:13 -06:00
|
|
|
int cp(char *p1, char *p2);
|
2023-09-18 10:45:51 -05:00
|
|
|
int fexists(char *path);
|
2023-11-17 15:16:13 -06:00
|
|
|
FILE *fopen_mkdir(char *path, char *mode);
|
2022-08-25 15:48:15 -05:00
|
|
|
|
2023-09-18 12:35:40 -05:00
|
|
|
void *slurp_file(const char *filename, size_t *size);
|
2023-09-07 16:46:35 -05:00
|
|
|
char *slurp_text(const char *filename, size_t *size);
|
2023-09-04 09:48:44 -05:00
|
|
|
int slurp_write(const char *txt, const char *filename);
|
|
|
|
|
2023-09-18 07:36:07 -05:00
|
|
|
char *seprint(char *fmt, ...);
|
|
|
|
|
2023-09-05 17:09:25 -05:00
|
|
|
void pack_engine(const char *fname);
|
2023-09-04 09:48:44 -05:00
|
|
|
|
2023-12-13 19:53:09 -06:00
|
|
|
static inline void *stbarrdup(void *mem, size_t size, int len) {
|
|
|
|
void *out = NULL;
|
|
|
|
arrsetlen(out, len);
|
|
|
|
memcpy(out,mem,size*len);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define arrconcat(a,b) do{for (int i = 0; i < arrlen(b); i++) arrput(a,b[i]);}while(0)
|
|
|
|
#define arrdup(a) (stbarrdup(a, sizeof(*a), arrlen(a)))
|
|
|
|
|
2021-11-30 21:29:18 -06:00
|
|
|
#endif
|