[ttssh2-commit] [10499] TTXttyplayでUnicodeファイル名を使用できるようにした

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2023年 1月 16日 (月) 00:07:18 JST


Revision: 10499
          https://osdn.net/projects/ttssh2/scm/svn/commits/10499
Author:   zmatsuo
Date:     2023-01-16 00:07:18 +0900 (Mon, 16 Jan 2023)
Log Message:
-----------
TTXttyplayでUnicodeファイル名を使用できるようにした

- この修正で TTXttyplay 内はUnicode対応となった
- Tera Term本体の引数の処理がUnicode対応できていないためUnicodeファイル名は使用できない
  - /R オプション

Modified Paths:
--------------
    trunk/TTXSamples/TTXttyrec/TTXttyplay.c

-------------- next part --------------
Modified: trunk/TTXSamples/TTXttyrec/TTXttyplay.c
===================================================================
--- trunk/TTXSamples/TTXttyrec/TTXttyplay.c	2023-01-15 15:07:09 UTC (rev 10498)
+++ trunk/TTXSamples/TTXttyrec/TTXttyplay.c	2023-01-15 15:07:18 UTC (rev 10499)
@@ -59,7 +59,7 @@
 	BOOL open_error;
 	struct timeval last;
 	struct timeval wait;
-	char openfn[MAX_PATH];
+	wchar_t *openfnW;
 	char origTitle[TitleBuffSize];
 	char origOLDTitle[TitleBuffSize];
 } TInstVar;
@@ -450,7 +450,9 @@
 		else if (_wcsnicmp(buff, L"/TTYPLAY", 9) == 0 || _wcsnicmp(buff, L"/TP", 4) == 0) {
 			pvar->enable = TRUE;
 			if (ts->PortType == IdFile && strlen(ts->HostName) > 0) {
-				strncpy_s(pvar->openfn, sizeof(pvar->openfn), ts->HostName, _TRUNCATE);
+				wchar_t *HostNameW = ToWcharA(ts->HostName);
+				free(pvar->openfnW);
+				pvar->openfnW = HostNameW;
 			}
 		}
 	}
@@ -485,8 +487,8 @@
 			ofn.Flags = OFN_FILEMUSTEXIST;
 
 			if (TTGetOpenFileNameW(&ofn, &openfn)) {
-				WideCharToACP_t(openfn, pvar->openfn, sizeof(pvar->openfn));
-				free(openfn);
+				free(pvar->openfnW);
+				pvar->openfnW = openfn;
 				pvar->ReplaceHostDlg = TRUE;
 				// Call New-Connection dialog
 				SendMessage(hWin, WM_COMMAND, MAKELONG(ID_FILE_NEWCONNECTION, 0), 0);
@@ -513,7 +515,7 @@
 
 static BOOL PASCAL TTXGetHostName(HWND parent, PGetHNRec GetHNRec) {
 	GetHNRec->PortType = IdTCPIP;
-	_snwprintf_s(GetHNRec->HostName, MAXPATHLEN, _TRUNCATE, L"/R=\"%hs\" /TP", pvar->openfn);
+	_snwprintf_s(GetHNRec->HostName, HostNameMaxLength, _TRUNCATE, L"/R=\"%s\" /TP", pvar->openfnW);
 	return (TRUE);
 }
 
@@ -578,6 +580,8 @@
 			break;
 		case DLL_PROCESS_DETACH:
 			/* do process cleanup */
+			free(pvar->openfnW);
+			pvar->openfnW = NULL;
 			break;
 	}
 	return TRUE;


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