[Ttssh2-commit] [8389] SCPでファイルが開けなかった時のメッセージを変更

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 11月 21日 (木) 20:30:18 JST


Revision: 8389
          https://osdn.net/projects/ttssh2/scm/svn/commits/8389
Author:   doda
Date:     2019-11-21 20:30:17 +0900 (Thu, 21 Nov 2019)
Log Message:
-----------
SCPでファイルが開けなかった時のメッセージを変更

Ticket: #39682

問題:
  SCP でローカルのファイルが開けなかった時のエラーメッセージが判りづらい。

対処:
  エラーメッセージに FormatMessage() のメッセージを含めるようにした。

備考:
  FormatMessage() で得られるメッセージはシステムのロケールに合わせて言語が
  変わるので、例えば日本語環境では

  Can't open file for reading: 指定されたファイルが見つかりません。

  のような不格好な物になる。将来的に対処するかは要検討。

Ticket Links:
------------
    https://osdn.net/projects/ttssh2/tracker/detail/39682

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/history.html
    trunk/ttssh2/ttxssh/ssh.c

-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2019-11-21 11:30:13 UTC (rev 8388)
+++ trunk/doc/en/html/about/history.html	2019-11-21 11:30:17 UTC (rev 8389)
@@ -3238,6 +3238,7 @@
       <li>The LogLevel entry is added on the <a href="../menu/setup-ssh.html#LogLevel">Setup dialog</a>.</li>
       <li>The help button are added on the <a href="../menu/setup-ssh.html">Setup dialog</a>, <a href="../menu/setup-sshauth.html">Authentication Setup dialog</a>, <a href="../menu/setup-sshforward.html">Forwarding dialog</a> and <a href="../menu/setup-sshkeygenerator.html">Key Generator dialog</a>.</li>
       <li>When the network is disconnected from SSH server side, the known_hosts and user authentication dialog are automatically closed while the dialog is shown.</li>
+      <li>Changed the error message when unable to open local file.</li>
     </ul>
   </li>
 

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2019-11-21 11:30:13 UTC (rev 8388)
+++ trunk/doc/ja/html/about/history.html	2019-11-21 11:30:17 UTC (rev 8389)
@@ -3244,6 +3244,7 @@
       <li><a href="../menu/setup-ssh.html#LogLevel">Setup\x83_\x83C\x83A\x83\x8D\x83O</a>\x82\xC9LogLevel\x82\xF0\x92lj\xC1\x82\xB5\x82\xBD\x81B</li>
       <li><a href="../menu/setup-ssh.html">Setup\x83_\x83C\x83A\x83\x8D\x83O</a>\x81A<a href="../menu/setup-sshauth.html">Authentication Setup\x83_\x83C\x83A\x83\x8D\x83O</a>\x81A<a href="../menu/setup-sshforward.html">Forwarding\x83_\x83C\x83A\x83\x8D\x83O</a>\x81A<a href="../menu/setup-sshkeygenerator.html">Key Generator\x83_\x83C\x83A\x83\x8D\x83O</a>\x82Ƀw\x83\x8B\x83v\x83{\x83^\x83\x93\x82\xF0\x92lj\xC1\x82\xB5\x82\xBD\x81B</li>
       <li>known_hosts\x83_\x83C\x83A\x83\x8D\x83O\x82\xA8\x82\xE6\x82у\x86\x81[\x83U\x94F\x8F؃_\x83C\x83A\x83\x8D\x83O\x82̕\\x8E\xA6\x92\x86\x82ɁASSH\x83T\x81[\x83o\x91\xA4\x82\xA9\x82\xE7\x83l\x83b\x83g\x83\x8F\x81[\x83N\x90ؒf\x82\xB3\x82ꂽ\x8Fꍇ\x81A\x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8E\xA9\x93\xAE\x82ŕ‚\xB6\x82\xE9\x82悤\x82ɂ\xB5\x82\xBD\x81B</li>
+      <li>SCP \x82Ń\x8D\x81[\x83J\x83\x8B\x91\xA4\x82̃t\x83@\x83C\x83\x8B\x82\xAA\x8AJ\x82\xAF\x82Ȃ\xA9\x82\xC1\x82\xBD\x8E\x9E\x82̃\x81\x83b\x83Z\x81[\x83W\x82\xF0\x95ύX\x82\xB5\x82\xBD\x81B</li>
     </ul>
   </li>
 

Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2019-11-21 11:30:13 UTC (rev 8388)
+++ trunk/ttssh2/ttxssh/ssh.c	2019-11-21 11:30:17 UTC (rev 8389)
@@ -4103,8 +4103,18 @@
 	if (direction == TOREMOTE) {  // copy local to remote
 		fp = fopen(sendfile, "rb");
 		if (fp == NULL) {
-			char buf[80];
-			_snprintf_s(buf, sizeof(buf), _TRUNCATE, "fopen: %d", GetLastError());
+			char buf[1024];
+			int len;
+			strcpy_s(buf, sizeof(buf), "Can't open file for reading: ");
+			len = strlen(buf);
+			FormatMessage(
+			    FORMAT_MESSAGE_FROM_SYSTEM,
+			    NULL,
+			    GetLastError(),
+			    0,
+			    buf+len,
+			    sizeof(buf)-len,
+			    NULL);
 			MessageBox(NULL, buf, "TTSSH: file open error", MB_OK | MB_ICONERROR);
 			goto error;
 		}
@@ -4159,9 +4169,19 @@
 
 		fp = fopen(c->scp.localfilefull, "wb");
 		if (fp == NULL) {
-			char buf[512];
-			_snprintf_s(buf, sizeof(buf), _TRUNCATE, "fopen: %d", GetLastError());
-			MessageBox(NULL, buf, "TTSSH: file open write error", MB_OK | MB_ICONERROR);
+			char buf[1024];
+			int len;
+			strcpy_s(buf, sizeof(buf), "Can't open file for writing: ");
+			len = strlen(buf);
+			FormatMessage(
+			    FORMAT_MESSAGE_FROM_SYSTEM,
+			    NULL,
+			    GetLastError(),
+			    0,
+			    buf+len,
+			    sizeof(buf)-len,
+			    NULL);
+			MessageBox(NULL, buf, "TTSSH: file open error", MB_OK | MB_ICONERROR);
 			goto error;
 		}
 


Ttssh2-commit メーリングリストの案内
Back to archive index