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:
@ -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)
|
||||
|
@ -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");
|
||||
}
|
||||
|
Reference in New Issue
Block a user