diff util.c @ 1140:4490c9c12272

Detect system type from filename if header based methods fail. Allow overriding system type from command line.
author Michael Pavone <pavone@retrodev.com>
date Mon, 02 Jan 2017 21:46:26 -0800
parents 160e3f597cec
children a344885e7c79
line wrap: on
line diff
--- a/util.c	Mon Jan 02 16:33:03 2017 -0800
+++ b/util.c	Mon Jan 02 21:46:26 2017 -0800
@@ -149,6 +149,26 @@
 	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 @@
 #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 @@
 
 #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) {