mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
config: use the same signature for win32/OSX specific path functions
Seems like a good idea, even if it's basically unused (yet). Also document requirements on the functions (they're not obvious). OSX changes untested.
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
#include "osdep/io.h"
|
#include "osdep/io.h"
|
||||||
#include "osdep/path.h"
|
#include "osdep/path.h"
|
||||||
|
|
||||||
static void mp_add_xdg_config_dirs(struct mpv_global *global, char **dirs, int i)
|
static int mp_add_xdg_config_dirs(struct mpv_global *global, char **dirs, int i)
|
||||||
{
|
{
|
||||||
void *talloc_ctx = dirs;
|
void *talloc_ctx = dirs;
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ static void mp_add_xdg_config_dirs(struct mpv_global *global, char **dirs, int i
|
|||||||
dirs[i++] = old_home;
|
dirs[i++] = old_home;
|
||||||
|
|
||||||
#if HAVE_COCOA
|
#if HAVE_COCOA
|
||||||
dirs[i++] = mp_get_macosx_bundle_dir(talloc_ctx);
|
i = mp_add_macosx_bundle_dir(global, dirs, i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tmp = getenv("XDG_CONFIG_DIRS");
|
tmp = getenv("XDG_CONFIG_DIRS");
|
||||||
@@ -93,10 +93,11 @@ static void mp_add_xdg_config_dirs(struct mpv_global *global, char **dirs, int i
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
dirs[i++] = MPLAYER_CONFDIR;
|
dirs[i++] = MPLAYER_CONFDIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return NULL-terminated array of config directories, from highest to lowest
|
// Return NULL-terminated array of config directories, from highest to lowest
|
||||||
@@ -123,9 +124,9 @@ static char **mp_config_dirs(void *talloc_ctx, struct mpv_global *global)
|
|||||||
ret[i++] = talloc_strdup(ret, tmp);
|
ret[i++] = talloc_strdup(ret, tmp);
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
mp_add_win_config_dirs(global, ret, i);
|
i = mp_add_win_config_dirs(global, ret, i);
|
||||||
#else
|
#else
|
||||||
mp_add_xdg_config_dirs(global, ret, i);
|
i = mp_add_xdg_config_dirs(global, ret, i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MP_VERBOSE(global, "search dirs:");
|
MP_VERBOSE(global, "search dirs:");
|
||||||
|
|||||||
@@ -20,11 +20,12 @@
|
|||||||
#include "options/path.h"
|
#include "options/path.h"
|
||||||
#include "osdep/path.h"
|
#include "osdep/path.h"
|
||||||
|
|
||||||
char *mp_get_macosx_bundle_dir(void *talloc_ctx)
|
int mp_add_macosx_bundle_dir(struct mpv_global *global, char **dirs, int i)
|
||||||
{
|
{
|
||||||
|
void *talloc_ctx = dirs;
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSString *path = [[NSBundle mainBundle] resourcePath];
|
NSString *path = [[NSBundle mainBundle] resourcePath];
|
||||||
char *rv = talloc_strdup(talloc_ctx, [path UTF8String]);
|
dirs[i++] = talloc_strdup(talloc_ctx, [path UTF8String]);
|
||||||
[pool release];
|
[pool release];
|
||||||
return rv;
|
return i;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ static char *mp_get_win_app_dir(void *talloc_ctx)
|
|||||||
return talloc_asprintf(talloc_ctx, "%s/mpv", mp_to_utf8(talloc_ctx, w_appdir));
|
return talloc_asprintf(talloc_ctx, "%s/mpv", mp_to_utf8(talloc_ctx, w_appdir));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mp_add_win_config_dirs(struct mpv_global *global, char **dirs, int i)
|
int mp_add_win_config_dirs(struct mpv_global *global, char **dirs, int i)
|
||||||
{
|
{
|
||||||
void *talloc_ctx = dirs;
|
void *talloc_ctx = dirs;
|
||||||
if ((dirs[i] = mp_get_win_exe_subdir(talloc_ctx)))
|
if ((dirs[i] = mp_get_win_exe_subdir(talloc_ctx)))
|
||||||
@@ -67,4 +67,5 @@ void mp_add_win_config_dirs(struct mpv_global *global, char **dirs, int i)
|
|||||||
i++;
|
i++;
|
||||||
if ((dirs[i] = mp_get_win_app_dir(talloc_ctx)))
|
if ((dirs[i] = mp_get_win_app_dir(talloc_ctx)))
|
||||||
i++;
|
i++;
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|||||||
10
osdep/path.h
10
osdep/path.h
@@ -5,9 +5,11 @@
|
|||||||
|
|
||||||
struct mpv_global;
|
struct mpv_global;
|
||||||
|
|
||||||
void mp_add_win_config_dirs(struct mpv_global *global, char **dirs, int i);
|
// 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
|
||||||
// Returns Mac OS X application bundle directory.
|
// added without checking for i>=MAX_CONFIG_PATHS.
|
||||||
char *mp_get_macosx_bundle_dir(void *talloc_ctx);
|
// 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);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user