mirror of https://github.com/mpv-player/mpv
path: add resolving desktop path to platform-specific paths
win32 has a special function for this. I'm not sure about OSX - it seems ~/Desktop can be hardcoded, and the OSX GUI actually localizes the _displayed_ path in its UI. For Unix, there is not much to be done, or is there.
This commit is contained in:
parent
7381db60e2
commit
8192500716
|
@ -338,6 +338,7 @@ Name Meaning
|
||||||
``~home/`` same as ``~~/``
|
``~home/`` same as ``~~/``
|
||||||
``~global/`` the global config path, if available
|
``~global/`` the global config path, if available
|
||||||
``~osxbundle/`` the OSX bundle resource path (OSX only)
|
``~osxbundle/`` the OSX bundle resource path (OSX only)
|
||||||
|
``~desktop/`` the path to the desktop (win32, OSX)
|
||||||
=============== ================================================================
|
=============== ================================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,5 +28,7 @@ const char *mp_get_platform_path_osx(void *talloc_ctx, const char *type)
|
||||||
[pool release];
|
[pool release];
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
if (strcmp(type, "desktop") == 0)
|
||||||
|
return mp_path_join(talloc_ctx, bstr0(getenv("HOME")), bstr0("Desktop"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,5 +60,7 @@ const char *mp_get_platform_path_unix(void *talloc_ctx, const char *type)
|
||||||
return old_home;
|
return old_home;
|
||||||
if (strcmp(type, "global") == 0)
|
if (strcmp(type, "global") == 0)
|
||||||
return MPV_CONFDIR;
|
return MPV_CONFDIR;
|
||||||
|
if (strcmp(type, "desktop") == 0)
|
||||||
|
return getenv("HOME");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ static char *mp_get_win_exe_subdir(void *talloc_ctx)
|
||||||
return talloc_asprintf(talloc_ctx, "%s/mpv", mp_get_win_exe_dir(talloc_ctx));
|
return talloc_asprintf(talloc_ctx, "%s/mpv", mp_get_win_exe_dir(talloc_ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *mp_get_win_app_dir(void *talloc_ctx)
|
static char *mp_get_win_shell_dir(void *talloc_ctx, int folder)
|
||||||
{
|
{
|
||||||
wchar_t w_appdir[MAX_PATH + 1] = {0};
|
wchar_t w_appdir[MAX_PATH + 1] = {0};
|
||||||
|
|
||||||
|
@ -55,7 +55,13 @@ static char *mp_get_win_app_dir(void *talloc_ctx)
|
||||||
SHGFP_TYPE_CURRENT, w_appdir) != S_OK)
|
SHGFP_TYPE_CURRENT, w_appdir) != S_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return talloc_asprintf(talloc_ctx, "%s/mpv", mp_to_utf8(talloc_ctx, w_appdir));
|
return mp_to_utf8(talloc_ctx, w_appdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *mp_get_win_app_dir(void *talloc_ctx)
|
||||||
|
{
|
||||||
|
char *path = mp_get_win_shell_dir(talloc_ctx, CSIDL_APPDATA);
|
||||||
|
return path ? mp_path_join(talloc_ctx, bstr0(path), bstr0("mpv")) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *mp_get_platform_path_win(void *talloc_ctx, const char *type)
|
const char *mp_get_platform_path_win(void *talloc_ctx, const char *type)
|
||||||
|
@ -67,5 +73,7 @@ const char *mp_get_platform_path_win(void *talloc_ctx, const char *type)
|
||||||
// Not really true, but serves as a way to return a lowest-priority dir.
|
// Not really true, but serves as a way to return a lowest-priority dir.
|
||||||
if (strcmp(type, "global") == 0)
|
if (strcmp(type, "global") == 0)
|
||||||
return mp_get_win_exe_subdir(talloc_ctx);
|
return mp_get_win_exe_subdir(talloc_ctx);
|
||||||
|
if (strcmp(type, "desktop") == 0)
|
||||||
|
return mp_get_win_shell_dir(talloc_ctx, CSIDL_DESKTOPDIRECTORY);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue