diff options
Diffstat (limited to 'compat')
-rw-r--r-- | compat/mingw.c | 22 | ||||
-rw-r--r-- | compat/mingw.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/compat/mingw.c b/compat/mingw.c index 3a05fe7da6..c0bc849e45 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -1017,3 +1017,25 @@ sig_handler_t mingw_signal(int sig, sig_handler_t handler) timer_fn = handler; return old; } + +static const char *make_backslash_path(const char *path) +{ + static char buf[PATH_MAX + 1]; + char *c; + + if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX) + die("Too long path: %.*s", 60, path); + + for (c = buf; *c; c++) { + if (*c == '/') + *c = '\\'; + } + return buf; +} + +void mingw_open_html(const char *unixpath) +{ + const char *htmlpath = make_backslash_path(unixpath); + printf("Launching default browser to display HTML ...\n"); + ShellExecute(NULL, "open", htmlpath, NULL, "\\", 0); +} diff --git a/compat/mingw.h b/compat/mingw.h index 6bc049ad99..5a3bcee29b 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -202,6 +202,9 @@ sig_handler_t mingw_signal(int sig, sig_handler_t handler); #define PATH_SEP ';' #define PRIuMAX "I64u" +void mingw_open_html(const char *path); +#define open_html mingw_open_html + /* * helpers */ |