summaryrefslogtreecommitdiffstats
path: root/osdep/path.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-01 21:13:44 +0200
committerwm4 <wm4@nowhere>2015-05-01 21:51:10 +0200
commitd3a3cfe54c26055c0686ea1b9a245eb7f88af521 (patch)
tree98d1f00e030f5c2d1fa8a94515bbedb97489f335 /osdep/path.h
parent60958ddf9b1db1101f81c3db59b8e8c980af7cf2 (diff)
downloadmpv-d3a3cfe54c26055c0686ea1b9a245eb7f88af521.tar.bz2
mpv-d3a3cfe54c26055c0686ea1b9a245eb7f88af521.tar.xz
path: refactor
Somewhat less ifdeffery, higher flexibility. Now there are 3 separate config file resolvers for 3 platforms (unix, win, osx), and they can still interact with each other somewhat. For example, OSX for now uses most of Unix, but adds the OSX bundle path. This can be extended to resolve very specific platform paths, such as location of the desktop. Most of the Unix specific code moves to path-unix.c. The behavior should be the same - if not, it is likely a bug.
Diffstat (limited to 'osdep/path.h')
-rw-r--r--osdep/path.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/osdep/path.h b/osdep/path.h
index c697453fcc..59a3ba7590 100644
--- a/osdep/path.h
+++ b/osdep/path.h
@@ -1,15 +1,22 @@
#ifndef OSDEP_PATH_H
#define OSDEP_PATH_H
-#define MAX_CONFIG_PATHS 32
+// Return a platform-specific path, identified by the type parameter. If the
+// return value is allocated, talloc_ctx is used as talloc parent context.
+//
+// The following type values are defined:
+// "home" the native mpv-specific user config dir
+// "old_home" same as "home", but lesser priority (compatibility)
+// "osxbundle" OSX bundle path
+// "global" the least priority, global config file location
+//
+// It is allowed to return a static string, so the caller must set talloc_ctx
+// to something other than NULL to avoid memory leaks.
+typedef const char *(*mp_get_platform_path_cb)(void *talloc_ctx, const char *type);
-struct mpv_global;
-
-// Append paths starting at dirs[i]. The dirs array has place only for at most
-// MAX_CONFIG_PATHS paths, but it's guaranteed that at least 4 paths can be
-// added without checking for i>=MAX_CONFIG_PATHS.
-// Return the new value of i.
-int mp_add_win_config_dirs(struct mpv_global *global, char **dirs, int i);
-int mp_add_macosx_bundle_dir(struct mpv_global *global, char **dirs, int i);
+// Conforming to mp_get_platform_path_cb.
+const char *mp_get_platform_path_win(void *talloc_ctx, const char *type);
+const char *mp_get_platform_path_osx(void *talloc_ctx, const char *type);
+const char *mp_get_platform_path_unix(void *talloc_ctx, const char *type);
#endif