[Ttssh2-commit] [8444] openDirectoryWithExplorer() の引数を char * から wchar_t * に変更

scmno****@osdn***** scmno****@osdn*****
2019年 12月 14日 (土) 00:13:22 JST


Revision: 8444
          https://osdn.net/projects/ttssh2/scm/svn/commits/8444
Author:   zmatsuo
Date:     2019-12-14 00:13:21 +0900 (Sat, 14 Dec 2019)
Log Message:
-----------
openDirectoryWithExplorer() の引数を char * から wchar_t * に変更

- プロジェクト内から mbstowcs() がなくなった

Modified Paths:
--------------
    branches/unicode_buf/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: branches/unicode_buf/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/vtwin.cpp	2019-12-13 15:13:11 UTC (rev 8443)
+++ branches/unicode_buf/teraterm/teraterm/vtwin.cpp	2019-12-13 15:13:21 UTC (rev 8444)
@@ -5163,38 +5163,29 @@
 // return TRUE: success
 //        FALSE: failure
 //
-static BOOL openDirectoryWithExplorer(char *path)
+static BOOL openDirectoryWithExplorer(const wchar_t *path)
 {
 	LPSHELLFOLDER pDesktopFolder;
 	LPMALLOC pMalloc;
 	LPITEMIDLIST pIDL;
-	WCHAR pwszDisplayName[1024];
-	size_t szRet, DisplayNameMax;
 	SHELLEXECUTEINFO si;
 	BOOL ret = FALSE;
 
-	DisplayNameMax = sizeof(pwszDisplayName) / sizeof(pwszDisplayName[0]);
-
 	if (SHGetDesktopFolder(&pDesktopFolder) == S_OK) {
 		if (SHGetMalloc(&pMalloc) == S_OK) {
-			szRet = mbstowcs(pwszDisplayName, path, DisplayNameMax - 1);
-			if (szRet != -1) {
-				pwszDisplayName[szRet] = L'\0';
+			if (pDesktopFolder->ParseDisplayName(NULL, NULL, (LPWSTR)path, NULL, &pIDL, NULL) == S_OK) {
+				::ZeroMemory(&si, sizeof(si));
+				si.cbSize = sizeof(si);
+				si.fMask = SEE_MASK_IDLIST;
+				si.lpVerb = _T("open");
+				si.lpIDList = pIDL;
+				si.nShow = SW_SHOWNORMAL;
+				::ShellExecuteEx(&si);
+				pMalloc->Free((void *)pIDL);
 
-				if (pDesktopFolder->ParseDisplayName(NULL, NULL, pwszDisplayName, NULL, &pIDL, NULL) == S_OK) {
-					::ZeroMemory(&si, sizeof(si));
-					si.cbSize = sizeof(si);
-					si.fMask = SEE_MASK_IDLIST;
-					si.lpVerb = _T("open");
-					si.lpIDList = pIDL;
-					si.nShow = SW_SHOWNORMAL;
-					::ShellExecuteEx(&si);
-					pMalloc->Free((void*)pIDL);
+				ret = TRUE;
+			}
 
-					ret = TRUE;
-				}
-
-			}
 			pMalloc->Release();
 		}
 		pDesktopFolder->Release();
@@ -5203,7 +5194,6 @@
 	return (ret);
 }
 
-
 //
 // \x83t\x83H\x83\x8B\x83_\x82\xE0\x82\xB5\x82\xAD\x82̓t\x83@\x83C\x83\x8B\x82\xF0\x8AJ\x82\xAD\x81B
 //
@@ -5210,7 +5200,9 @@
 static void openFileDirectory(char *path, char *filename, BOOL open_directory_only, char *open_editor)
 {
 	if (open_directory_only) {
-		openDirectoryWithExplorer(path);
+		wchar_t *pathW = ToWcharA(path);
+		openDirectoryWithExplorer(pathW);
+		free(pathW);
 	}
 	else {
 		openFileWithApplication(path, filename, open_editor);


Ttssh2-commit メーリングリストの案内