std::string StringToUTF8(const tstring& string) {return WideToUTF8(MultibyteToWide(string));}
STDMETHODIMP CShellExt::GetItemData(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData) { PreserveChdir preserveChdir; if (!g_ShellCache.IsPathAllowed((TCHAR *)pscd->wszFile)) { return S_FALSE; } LoadLangDll(); ShellCache::CacheType cachetype = g_ShellCache.GetCacheType(); if (pscid->fmtid == CLSID_Tortoisegit_UPTODATE) { stdstring szInfo; const TCHAR * path = (TCHAR *)pscd->wszFile; // reserve for the path + trailing \0 TCHAR buf[MAX_STATUS_STRING_LENGTH+1]; SecureZeroMemory(buf, MAX_STATUS_STRING_LENGTH); switch (pscid->pid) { case 0: // Git Status GetColumnStatus(path, pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); GitStatus::GetStatusString(g_hResInst, filestatus, buf, _countof(buf), (WORD)CRegStdDWORD(_T("Software\\TortoiseGit\\LanguageID"), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT))); szInfo = buf; break; case 1: // Git Revision #if 0 GetColumnStatus(path, pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); if (columnrev >= 0) { V_VT(pvarData) = VT_I4; V_I4(pvarData) = columnrev; } #endif return S_OK; break; case 2: // Git Url GetColumnStatus(path, pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); szInfo = itemurl; break; case 3: // Git Short Url GetColumnStatus(path, pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); szInfo = itemshorturl; break; case 5: // Git eol-style #if 0 if (cachetype == ShellCache::none) return S_FALSE; if (g_ShellCache.IsPathAllowed(path)) { SVNProperties props = SVNProperties(CTSVNPath(path), false); for (int i=0; i<props.GetCount(); i++) { if (props.GetItemName(i).compare(_T("svn:eol-style"))==0) { szInfo = MultibyteToWide((char *)props.GetItemValue(i).c_str()); } } } #endif break; default: return S_FALSE; } const WCHAR * wsInfo = szInfo.c_str(); V_VT(pvarData) = VT_BSTR; V_BSTR(pvarData) = SysAllocString(wsInfo); return S_OK; } if (pscid->fmtid == FMTID_SummaryInformation) { stdstring szInfo; const TCHAR * path = pscd->wszFile; if (cachetype == ShellCache::none) return S_FALSE; switch (pscid->pid) { case PIDSI_AUTHOR: // Author and Git Author GetColumnStatus(path, pscd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); szInfo = columnauthor; break; default: return S_FALSE; } wide_string wsInfo = szInfo; V_VT(pvarData) = VT_BSTR; V_BSTR(pvarData) = SysAllocString(wsInfo.c_str()); return S_OK; } return S_FALSE; }