Revision: 8441 https://osdn.net/projects/ttssh2/scm/svn/commits/8441 Author: zmatsuo Date: 2019-12-14 00:12:51 +0900 (Sat, 14 Dec 2019) Log Message: ----------- ttxsshでファイル名に漢字等が含まれていても送信できるようにした - ファイルドロップでファル送信時 Modified Paths: -------------- branches/unicode_buf/ttssh2/ttxssh/ssh.c -------------- next part -------------- Modified: branches/unicode_buf/ttssh2/ttxssh/ssh.c =================================================================== --- branches/unicode_buf/ttssh2/ttxssh/ssh.c 2019-12-13 15:12:40 UTC (rev 8440) +++ branches/unicode_buf/ttssh2/ttxssh/ssh.c 2019-12-13 15:12:51 UTC (rev 8441) @@ -4069,7 +4069,31 @@ } +/** + * fopen utf-8 wrapper + */ +static FILE *fopenU8(const char *filenameU8, const char *mode) +{ + wchar_t *filenameW = ToWcharU8(filenameU8); + wchar_t *modeW = ToWcharU8(mode); + FILE *fp; + _wfopen_s(&fp, filenameW, modeW); + free(modeW); + free(filenameW); + return fp; +} +/** + * stat UTF-8 wrapper + */ +static int statU8(const char *filenameU8, struct __stat64 *st) +{ + wchar_t *filenameW = ToWcharU8(filenameU8); + int r = _wstat64(filenameW, st); + free(filenameW); + return r; +} + // // SCP support // @@ -4102,7 +4126,7 @@ } if (direction == TOREMOTE) { // copy local to remote - fp = fopen(sendfile, "rb"); + fp = fopenU8(sendfile, "rb"); if (fp == NULL) { char buf[1024]; int len; @@ -4129,7 +4153,7 @@ } c->scp.localfp = fp; // file pointer - if (_stat64(c->scp.localfilefull, &st) == 0) { + if (statU8(c->scp.localfilefull, &st) == 0) { c->scp.filestat = st; } else { goto error;