summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-01-02 21:46:26 -0800
committerMichael Pavone <pavone@retrodev.com>2017-01-02 21:46:26 -0800
commitf6ab2dad74b981bd9e222f771a62cad34ae35c34 (patch)
treed1bf83a75fdea30abe5bef8eb9b0c2869795bdc2 /util.c
parent7d1a9bbb9b343e128cbfbc3567ab329f22edbd5a (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.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/util.c b/util.c
index 2e36b33..59f51b6 100644
--- a/util.c
+++ b/util.c
@@ -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) {