Promote ad-hoc OS-to-VFS path translation function
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 29 Nov 2010 19:00:25 +0000 (19:00 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 29 Nov 2010 19:00:25 +0000 (19:00 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@3382 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/main.c
share/fs.h
share/fs_common.c

index 7b83cd2..f2a5d34 100644 (file)
@@ -408,26 +408,6 @@ static void make_dirs_and_migrate(void)
 
 /*---------------------------------------------------------------------------*/
 
-static const char *game_path(const char *path)
-{
-    if (fs_exists(path))
-        return path;
-
-    /* Chop off directories until we have a match. */
-
-    while ((path = path_next_sep(path)))
-    {
-        /* Skip separator. */
-
-        path += 1;
-
-        if (fs_exists(path))
-            return path;
-    }
-
-    return NULL;
-}
-
 int main(int argc, char *argv[])
 {
     SDL_Joystick *joy = NULL;
@@ -492,7 +472,7 @@ int main(int argc, char *argv[])
     }
     else if (opt_level)
     {
-        const char *path = game_path(opt_level);
+        const char *path = fs_resolve(opt_level);
         int loaded = 0;
 
         if (path)
index 32a5e27..ad49ec4 100644 (file)
@@ -48,4 +48,6 @@ int fs_printf(fs_file, const char *fmt, ...);
 Array fs_dir_scan(const char *, int (*filter)(struct dir_item *));
 void  fs_dir_free(Array);
 
+const char *fs_resolve(const char *);
+
 #endif
index 007cc5f..8fdb20f 100644 (file)
@@ -287,3 +287,25 @@ void *fs_load(const char *path, int *datalen)
 }
 
 /*---------------------------------------------------------------------------*/
+
+const char *fs_resolve(const char *path)
+{
+    if (fs_exists(path))
+        return path;
+
+    /* Chop off directories until we have a match. */
+
+    while ((path = path_next_sep(path)))
+    {
+        /* Skip separator. */
+
+        path += 1;
+
+        if (fs_exists(path))
+            return path;
+    }
+
+    return NULL;
+}
+
+/*---------------------------------------------------------------------------*/