Index: src/chext/TContextMenuHandler.cpp
===================================================================
diff -u -N -r8a2ff3b2b71b45fb525e030167e62f316cb32869 -r3c248d4f6d0fdb1e487cc868b2f0b219eec37ef4
--- src/chext/TContextMenuHandler.cpp	(.../TContextMenuHandler.cpp)	(revision 8a2ff3b2b71b45fb525e030167e62f316cb32869)
+++ src/chext/TContextMenuHandler.cpp	(.../TContextMenuHandler.cpp)	(revision 3c248d4f6d0fdb1e487cc868b2f0b219eec37ef4)
@@ -23,11 +23,13 @@
 #include "stdafx.h"
 #include "TContextMenuHandler.h"
 #include "../common/TShellExtMenuConfig.h"
+#include "Logger.h"
 
 TContextMenuHandler::TContextMenuHandler() :
 	m_uiNextMenuID(0),
 	m_uiFirstMenuID(0),
-	m_bEnableOwnerDrawnPaths(false)
+	m_bEnableOwnerDrawnPaths(false),
+	m_fsLocal(GetLogFileData())
 {
 }
 
@@ -36,18 +38,20 @@
 	Clear();
 }
 
-void TContextMenuHandler::Init(const TShellMenuItemPtr& spRootMenuItem, HMENU hMenu, UINT uiFirstItemID, UINT uiFirstItemPosition, const TShellExtData& rShellExtData, bool bEnableOwnerDrawnPaths, bool bOverrideDefaultItem)
+void TContextMenuHandler::Init(const TShellMenuItemPtr& spRootMenuItem, HMENU hMenu, UINT uiFirstItemID, UINT uiFirstItemPosition, const TShellExtData& rShellExtData,
+	const chcore::TSizeFormatterPtr& spFormatter, bool bShowFreeSpace, bool bEnableOwnerDrawnPaths, bool bOverrideDefaultItem)
 {
 	Clear();
 
 	m_uiFirstMenuID = uiFirstItemID;
 	m_uiNextMenuID = uiFirstItemID;
 	m_bEnableOwnerDrawnPaths = bEnableOwnerDrawnPaths;
 
-	UpdateMenuRecursive(spRootMenuItem, hMenu, uiFirstItemPosition, rShellExtData, bOverrideDefaultItem);
+	UpdateMenuRecursive(spRootMenuItem, hMenu, uiFirstItemPosition, rShellExtData, spFormatter, bShowFreeSpace, bOverrideDefaultItem);
 }
 
-void TContextMenuHandler::UpdateMenuRecursive(const TShellMenuItemPtr& spRootMenuItem, HMENU hMenu, UINT uiFirstItemPosition, const TShellExtData& rShellExtData, bool bOverrideDefaultItem)
+void TContextMenuHandler::UpdateMenuRecursive(const TShellMenuItemPtr& spRootMenuItem, HMENU hMenu, UINT uiFirstItemPosition,
+	const TShellExtData& rShellExtData, const chcore::TSizeFormatterPtr& spFormatter, bool bShowFreeSpace, bool bOverrideDefaultItem)
 {
 	for(size_t stIndex = 0; stIndex < spRootMenuItem->GetChildrenCount(); ++stIndex)
 	{
@@ -58,7 +62,7 @@
 			{
 				// special handling
 				HMENU hSubMenu = CreatePopupMenu();
-				UpdateMenuRecursive(spMenuItem, hSubMenu, 0, rShellExtData, bOverrideDefaultItem);
+				UpdateMenuRecursive(spMenuItem, hSubMenu, 0, rShellExtData, spFormatter, bShowFreeSpace, bOverrideDefaultItem);
 
 				MENUITEMINFO mii;
 				mii.cbSize = sizeof(MENUITEMINFO);
@@ -67,7 +71,7 @@
 				mii.fState = (spRootMenuItem->GetChildrenCount() > 0) ? MFS_ENABLED : MFS_GRAYED;
 				mii.wID = m_uiNextMenuID++;
 				mii.hSubMenu = hSubMenu;
-				mii.dwTypeData = (PTSTR)spMenuItem->GetName().c_str();
+				mii.dwTypeData = (PTSTR)spMenuItem->GetLocalName().c_str();
 				mii.cch = 0;
 
 				::InsertMenuItem(hMenu, uiFirstItemPosition++, TRUE, &mii);
@@ -83,8 +87,11 @@
 				bool bEnableOwnerDrawnItem = m_bEnableOwnerDrawnPaths && spMenuItem->SpecifiesDestinationPath();
 				bool bEnableItem = rShellExtData.VerifyItemCanBeExecuted(spMenuItem);
 
-				::InsertMenu(hMenu, uiFirstItemPosition++, MF_BYPOSITION | MF_STRING | (bEnableItem ? MF_ENABLED : MF_GRAYED) | (bEnableOwnerDrawnItem ? MF_OWNERDRAW : 0), m_uiNextMenuID, spMenuItem->GetName().c_str());
+				std::wstring wstrItemName = GetDisplayText(spMenuItem, spFormatter, bShowFreeSpace);
 
+				::InsertMenu(hMenu, uiFirstItemPosition++, MF_BYPOSITION | MF_STRING | (bEnableItem ? MF_ENABLED : MF_GRAYED) | (bEnableOwnerDrawnItem ? MF_OWNERDRAW : 0),
+					m_uiNextMenuID, wstrItemName.c_str());
+
 				if(bOverrideDefaultItem && rShellExtData.IsDefaultItem(spMenuItem))
 					::SetMenuDefaultItem(hMenu, m_uiNextMenuID, FALSE);
 				++m_uiNextMenuID;
@@ -98,6 +105,35 @@
 	}
 }
 
+std::wstring TContextMenuHandler::GetDisplayText(const TShellMenuItemPtr& spMenuItem, const chcore::TSizeFormatterPtr& spFormatter, bool bShowFreeSpace)
+{
+	std::wstring wstrItemName = spMenuItem->GetLocalName(false).c_str();
+
+	if(wstrItemName.empty())
+	{
+		wstrItemName = spMenuItem->GetName().c_str();
+
+		if(bShowFreeSpace && spMenuItem->SpecifiesDestinationPath())
+		{
+			unsigned long long ullSize = 0, ullTotal = 0;
+			try
+			{
+				m_fsLocal.GetDynamicFreeSpace(spMenuItem->GetDestinationPathInfo().GetDefaultDestinationPath(), ullSize, ullTotal);
+
+				wstrItemName += std::wstring(L" (") + spFormatter->GetSizeString(ullSize) + L")";
+				spMenuItem->SetLocalName(wstrItemName.c_str());
+			}
+			catch(const std::exception&)
+			{
+			}
+		}
+		else
+			spMenuItem->SetLocalName(wstrItemName.c_str());
+	}
+
+	return wstrItemName;
+}
+
 void TContextMenuHandler::Clear()
 {
 	m_mapMenuItems.clear();