diff options
author | Dan Gudmundsson <dgud@erlang.org> | 2021-05-21 10:35:46 +0200 |
---|---|---|
committer | Dan Gudmundsson <dgud@erlang.org> | 2021-06-15 13:25:40 +0200 |
commit | 32bbc7e9dea1bbc57224c99b0a079f202e0eaa6e (patch) | |
tree | b2e9eb2de08ead04bb26bbd46a300f09e3695cd4 /lib/wx/c_src/wxe_ps_init.c | |
parent | 42a10f60c437a70ee1ad86e6334e37872097d866 (diff) | |
download | erlang-32bbc7e9dea1bbc57224c99b0a079f202e0eaa6e.tar.gz |
wx: Include the edge webview loader in wx
Include it so that the end users that install the prebuilt erlang don't need
to build the loader as well as install the edge-chromium library.
Diffstat (limited to 'lib/wx/c_src/wxe_ps_init.c')
-rw-r--r-- | lib/wx/c_src/wxe_ps_init.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/wx/c_src/wxe_ps_init.c b/lib/wx/c_src/wxe_ps_init.c index aa793f85bc..27e3be1a1c 100644 --- a/lib/wx/c_src/wxe_ps_init.c +++ b/lib/wx/c_src/wxe_ps_init.c @@ -93,10 +93,43 @@ void * wxe_ps_init2() { /* _MACOSX */ #else +#ifdef _WIN32 +#include <windows.h> + +void * wxe_ps_init() +{ + int res; + size_t dir_len = 1023; + char dir_utf8[1024]; + wchar_t *npath; + size_t path_len; + + res = enif_getenv("WX_PRIV_DIR", dir_utf8, &dir_len); + if(res == 0) { + dir_len = MultiByteToWideChar(CP_UTF8, 0, dir_utf8, dir_len+1, NULL, 0); + path_len = GetEnvironmentVariableW(L"PATH",NULL,0); + if( dir_len > 0 && dir_len < 1024 && path_len > 0 ) { + npath = (wchar_t *) malloc((path_len+dir_len+2)*sizeof(wchar_t)); + if(GetEnvironmentVariableW(L"PATH",npath,path_len) != (path_len-1)) { + free(npath); + return NULL; + } + npath[path_len-1] = L';'; + if(MultiByteToWideChar(CP_UTF8, 0, dir_utf8, dir_len, npath+path_len, dir_len+1) > 0) { + SetEnvironmentVariableW(L"PATH",npath); + } + free(npath); + } + } + return (void *) 0; +} +#else void * wxe_ps_init() { return (void *) 0; } +#endif + void * wxe_ps_init2() { return (void *) 0; |