Browse Source

win32: dirs-uap: handle VLC_PKG_LIB_DIR/VLC_PKG_LIBEXEC_DIR

This is the same implementation as in desktop Windows.

GetModuleFileNameW [^1] and VirtualQuery [^2] are available in UWP.

[^1]: https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamew#requirements
[^2]: https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualquery#requirements
mmdevice-clean/8
Steve Lhomme 7 months ago
parent
commit
48eb3c22c4
  1. 44
      src/win32/dirs-uap.c

44
src/win32/dirs-uap.c

@ -153,10 +153,47 @@ end_other:
return GetFolderName(folder);
}
char *config_GetLibDir (void)
{
/* Get our full path */
MEMORY_BASIC_INFORMATION mbi;
if (!VirtualQuery (config_GetLibDir, &mbi, sizeof(mbi)))
goto error;
wchar_t wpath[MAX_PATH];
if (!GetModuleFileNameW ((HMODULE) mbi.AllocationBase, wpath, MAX_PATH))
goto error;
wchar_t *file = wcsrchr (wpath, L'\\');
if (file == NULL)
goto error;
*file = L'\0';
return FromWide (wpath);
error:
abort ();
}
static char *config_GetLibexecDir (void)
{
wchar_t wpath[MAX_PATH];
if (!GetModuleFileNameW (NULL, wpath, MAX_PATH))
goto error;
wchar_t *file = wcsrchr (wpath, L'\\');
if (file == NULL)
goto error;
*file = L'\0';
return FromWide (wpath);
error:
abort ();
}
static char *config_GetDataDir(void)
{
const char *path = getenv ("VLC_DATA_PATH");
return (path != NULL) ? strdup (path) : NULL;
return (path != NULL) ? strdup (path) : config_GetLibDir ();
}
char *config_GetSysPath(vlc_sysdir_t type, const char *filename)
@ -172,8 +209,11 @@ char *config_GetSysPath(vlc_sysdir_t type, const char *filename)
dir = getenv ("VLC_LIB_PATH");
if (dir)
return strdup( dir );
/* fallthrough */
dir = config_GetLibDir();
break;
case VLC_PKG_LIBEXEC_DIR:
dir = config_GetLibexecDir();
break;
case VLC_SYSDATA_DIR:
return NULL;
case VLC_LOCALE_DIR:

Loading…
Cancel
Save