diff util.c @ 1438:e2bd03ed3190

Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
author Michael Pavone <pavone@retrodev.com>
date Wed, 23 Aug 2017 21:18:17 -0700
parents 5ceb316c479a
children d82af64c94d2
line wrap: on
line diff
--- a/util.c	Mon Aug 21 23:49:56 2017 -0700
+++ b/util.c	Wed Aug 23 21:18:17 2017 -0700
@@ -270,6 +270,26 @@
 	return strdup(lastdot+1);
 }
 
+char * path_dirname(char *path)
+{
+	char *lastslash = NULL;
+	char *cur;
+	for (cur = path; *cur; cur++)
+	{
+		if (is_path_sep(*cur)) {
+			lastslash = cur;
+		}
+	}
+	if (!lastslash) {
+		return NULL;
+	}
+	char *dir = malloc(lastslash-path+1);
+	memcpy(dir, path, lastslash-path);
+	dir[lastslash-path] = 0;
+	
+	return dir;
+}
+
 uint32_t nearest_pow2(uint32_t val)
 {
 	uint32_t ret = 1;