1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 19:42:48 -05:00

Add and use cmdline_arg_to_filename().

Converting a CmdlineArg straight to a Filename allows us to make the
filename out of the wide-character version of the string on Windows.
So now filenames specified on the command line should generally be
able to handle pathnames containing Unicode characters not in the
system code page.

This change also involves making some char pointers _into_ Filename
structs where they weren't previously: for example, the
'openssh_config_file' variable in Windows Pageant's WinMain().
This commit is contained in:
Simon Tatham
2024-09-24 17:50:19 +01:00
parent b57fb48b27
commit 74150633f1
12 changed files with 61 additions and 41 deletions

View File

@ -162,6 +162,15 @@ const char *cmdline_arg_to_utf8(CmdlineArg *argp)
return arg->utf8;
}
Filename *cmdline_arg_to_filename(CmdlineArg *argp)
{
if (!argp)
return NULL;
CmdlineArgWin *arg = container_of(argp, CmdlineArgWin, argp);
return filename_from_wstr(arg->wide);
}
void cmdline_arg_wipe(CmdlineArg *argp)
{
if (!argp)

View File

@ -4,7 +4,7 @@
#include <dwmapi.h>
char *save_screenshot(HWND hwnd, const char *outfile)
char *save_screenshot(HWND hwnd, Filename *outfile)
{
HDC dcWindow = NULL, dcSave = NULL;
HBITMAP bmSave = NULL;
@ -89,9 +89,9 @@ char *save_screenshot(HWND hwnd, const char *outfile)
err = dupprintf("GetDIBits (get data): %s",
win_strerror(GetLastError()));
FILE *fp = fopen(outfile, "wb");
FILE *fp = f_open(outfile, "wb", false);
if (!fp) {
err = dupprintf("'%s': unable to open file", outfile);
err = dupprintf("'%s': unable to open file", filename_to_str(outfile));
goto out;
}
@ -118,7 +118,7 @@ char *save_screenshot(HWND hwnd, const char *outfile)
#else /* HAVE_DWMAPI_H */
/* Without <dwmapi.h> we can't get the right window rectangle */
char *save_screenshot(HWND hwnd, const char *outfile)
char *save_screenshot(HWND hwnd, Filename *outfile)
{
return dupstr("Demo screenshots not compiled in to this build");
}