Translate file name from unix to ANSI encoding in UnixFolder_IShellFolder2_GetDisplayNameOf
Dmitry Timoshkov
dmitry at baikal.ru
Mon Aug 29 23:03:04 CDT 2005
Hello,
This patch makes russian file names in UTF-8 and KOI8-R encodings
visible in GetOpenFileName dialog using unix shell folder extension.
Perhaps some other places in shfldr_unixfs.c need to be fixed as well.
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
Translate file name from unix to ANSI encoding in
UnixFolder_IShellFolder2_GetDisplayNameOf.
--- cvs/hq/wine/dlls/shell32/shfldr_unixfs.c 2005-08-30 12:30:20.000000000 +0900
+++ wine/dlls/shell32/shfldr_unixfs.c 2005-08-30 12:50:24.000000000 +0900
@@ -783,6 +783,22 @@ static HRESULT WINAPI UnixFolder_IShellF
}
}
+/******************************************************************************
+ * Translate file name from unix to ANSI encoding.
+ */
+static void strcpyn_U2A(char *win_fn, UINT win_fn_len, const char *unix_fn)
+{
+ UINT len;
+ WCHAR *unicode_fn;
+
+ len = MultiByteToWideChar(CP_UNIXCP, 0, unix_fn, -1, NULL, 0);
+ unicode_fn = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ MultiByteToWideChar(CP_UNIXCP, 0, unix_fn, -1, unicode_fn, len);
+
+ WideCharToMultiByte(CP_ACP, 0, unicode_fn, len, win_fn, win_fn_len, NULL, NULL);
+ HeapFree(GetProcessHeap(), 0, unicode_fn);
+}
+
static HRESULT WINAPI UnixFolder_IShellFolder2_GetDisplayNameOf(IShellFolder2* iface,
LPCITEMIDLIST pidl, SHGDNF uFlags, STRRET* lpName)
{
@@ -797,7 +813,7 @@ static HRESULT WINAPI UnixFolder_IShellF
if (!pidl || !pidl->mkid.cb) {
lpName->uType = STRRET_CSTR;
if (This->m_dwPathMode == PATHMODE_UNIX) {
- strcpy(lpName->u.cStr, This->m_pszPath);
+ strcpyn_U2A(lpName->u.cStr, MAX_PATH, This->m_pszPath);
} else {
WCHAR *pwszDosPath = wine_get_dos_file_name(This->m_pszPath);
if (!pwszDosPath)
@@ -819,7 +835,7 @@ static HRESULT WINAPI UnixFolder_IShellF
} else {
char *pszFileName = _ILGetTextPointer(pidl);
lpName->uType = STRRET_CSTR;
- strcpy(lpName->u.cStr, pszFileName ? pszFileName : "");
+ strcpyn_U2A(lpName->u.cStr, MAX_PATH, pszFileName ? pszFileName : "");
}
/* If in dos mode, do some post-processing on the path.
More information about the wine-patches
mailing list