summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-08-23 21:18:17 -0700
committerMichael Pavone <pavone@retrodev.com>2017-08-23 21:18:17 -0700
commitfacf0dd0e1606223da276bbf3984c55ca84e83d9 (patch)
tree1034b38f7f86d1f9a6de1ae7ae1d8cbef01d2930 /util.c
parentf46eaaf8651d2c763de76ce82999d9d7e1230719 (diff)
Allow reloading current ROM with a hotkey (default F5) and allow locking on a cartridge via menu
Diffstat (limited to 'util.c')
-rw-r--r--util.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/util.c b/util.c
index 8bb1184..8601fca 100644
--- a/util.c
+++ b/util.c
@@ -270,6 +270,26 @@ char *path_extension(char *path)
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;