26 const char *filename = path;
29 if (*p ==
'/' || *p ==
'\\') {
38 size_t len = strlen(filename);
44 strncpy(out_base, filename, len);
59 const char *filename = path;
62 if (*p ==
'/' || *p ==
'\\') {
69 const char *ext = strrchr(filename,
'.');
76 len = strlen(filename);
80 if (len >= out_size) {
84 strncpy(out_stem, filename, len);
99 FILE *f = fopen(path,
"r");
105 fseek(f, 0, SEEK_END);
107 fseek(f, 0, SEEK_SET);
108 char *buffer =
malloc(1 + *size);
111 fread(buffer,
sizeof(
char), *size, f);
112 buffer[*size] =
'\0';
124static inline void gm3u_str_copy_eol(
char *dest,
const char *src,
126 while (*src && isspace((
unsigned char)*src))
129 while (src[i] !=
'\0' && src[i] !=
'\n' && src[i] !=
'\r' &&
135 while (i > 0 && isspace((
unsigned char)dest[i - 1])) {
void * malloc(size_t size)
Custom implementation of malloc using a static memory pool.
Definition malloc.h:144
void gmu_get_filename_base(const char *path, char *out_base, size_t out_size)
Extracts the base filename (filename with extension) from a full path.
Definition utils.h:24
void gmu_get_filename_stem(const char *path, char *out_stem, size_t out_size)
Extracts the filename stem (filename without extension) from a full path.
Definition utils.h:57
int gmu_read_file(const char *path, char **content, size_t *size)
Reads the entire content of a file into a dynamically allocated buffer.
Definition utils.h:98