Revision: 10492 https://osdn.net/projects/ttssh2/scm/svn/commits/10492 Author: zmatsuo Date: 2023-01-15 15:31:06 +0900 (Sun, 15 Jan 2023) Log Message: ----------- パス,ファイル名をUTF-8で処理するようにした - ExtractFileNameU8() を追加(ssh.c内のみ) - ExtractFileName() の UTF-8版 - ttssh2/ttxssh/sch.c 内でのファイル名の扱いは UTF-8(仮) - 修正前に使用してた ExtractFileName() はACP(Multibyte)で処理を行っていた ticket #46514 Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/46514 Modified Paths: -------------- trunk/ttssh2/ttxssh/ssh.c -------------- next part -------------- Modified: trunk/ttssh2/ttxssh/ssh.c =================================================================== --- trunk/ttssh2/ttxssh/ssh.c 2023-01-14 16:15:08 UTC (rev 10491) +++ trunk/ttssh2/ttxssh/ssh.c 2023-01-15 06:31:06 UTC (rev 10492) @@ -4179,11 +4179,30 @@ return r; } -// -// SCP support -// -// (2007.12.21 yutaka) -// +/** + * ExtractFileName() UTF-8\x94\xC5 + */ +static void ExtractFileNameU8(const char *PathName, char *FileName, size_t destlen) +{ + const char *sep = strrchr(PathName, '/'); + if (sep == NULL) { + sep = strrchr(PathName, '\\'); + } + if (sep != NULL) { + strncpy_s(FileName, destlen, sep + 1, _TRUNCATE); + } + else { + strncpy_s(FileName, destlen, PathName, _TRUNCATE); + } +} + +/** + * SCP support + * + * @param sendfile UTF-8 + * @param dstfile UTF-8 + * @param direction + */ int SSH_scp_transaction(PTInstVar pvar, char *sendfile, char *dstfile, enum scp_dir direction) { buffer_t *msg; @@ -4230,7 +4249,7 @@ } strncpy_s(c->scp.localfilefull, sizeof(c->scp.localfilefull), sendfile, _TRUNCATE); // full path - ExtractFileName(sendfile, c->scp.localfile, sizeof(c->scp.localfile)); // file name only + ExtractFileNameU8(sendfile, c->scp.localfile, sizeof(c->scp.localfile)); // file name only if (dstfile == NULL || dstfile[0] == '\0') { // remote file path strncpy_s(c->scp.remotefile, sizeof(c->scp.remotefile), ".", _TRUNCATE); // full path } else {