diff options
author | Michael Pavone <pavone@retrodev.com> | 2017-01-02 21:46:26 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2017-01-02 21:46:26 -0800 |
commit | f6ab2dad74b981bd9e222f771a62cad34ae35c34 (patch) | |
tree | d1bf83a75fdea30abe5bef8eb9b0c2869795bdc2 /util.c | |
parent | 7d1a9bbb9b343e128cbfbc3567ab329f22edbd5a (diff) |
Detect system type from filename if header based methods fail. Allow overriding system type from command line.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -149,6 +149,26 @@ char * basename_no_extension(char *path) return barename; } +char *path_extension(char *path) +{ + char *lastdot = NULL; + char *lastslash = NULL; + char *cur; + for (cur = path; *cur; cur++) + { + if (*cur == '.') { + lastdot = cur; + } else if (is_path_sep(*cur)) { + lastslash = cur + 1; + } + } + if (!lastdot || (lastslash && lastslash > lastdot)) { + //no extension + return NULL; + } + return strdup(lastdot+1); +} + uint32_t nearest_pow2(uint32_t val) { uint32_t ret = 1; @@ -524,7 +544,7 @@ void free_dir_list(dir_entry *list, size_t numentries) #ifdef __ANDROID__ #include <SDL.h> -char *read_bundled_file(char *name, long *sizeret) +char *read_bundled_file(char *name, uint32_t *sizeret) { SDL_RWops *rw = SDL_RWFromFile(name, "rb"); if (!rw) { @@ -564,7 +584,7 @@ char const *get_save_dir() #else -char *read_bundled_file(char *name, long *sizeret) +char *read_bundled_file(char *name, uint32_t *sizeret) { char *exe_dir = get_exe_dir(); if (!exe_dir) { |