display free and total disk space
Modified: trunk/reactos/subsys/system/winefile/de.rc
Modified: trunk/reactos/subsys/system/winefile/en.rc
Modified: trunk/reactos/subsys/system/winefile/resource.h
Modified: trunk/reactos/subsys/system/winefile/winefile.c

Modified: trunk/reactos/subsys/system/winefile/de.rc
--- trunk/reactos/subsys/system/winefile/de.rc	2005-05-13 15:35:55 UTC (rev 15264)
+++ trunk/reactos/subsys/system/winefile/de.rc	2005-05-13 17:11:16 UTC (rev 15265)
@@ -207,4 +207,6 @@
 	IDS_COL_LINKS	"Links"
 	IDS_COL_ATTR	"Attribute"
 	IDS_COL_SEC		"Sicherheit"
+
+	IDS_FREE_SPACE_FMT	"%s von %s frei"
 }

Modified: trunk/reactos/subsys/system/winefile/en.rc
--- trunk/reactos/subsys/system/winefile/en.rc	2005-05-13 15:35:55 UTC (rev 15264)
+++ trunk/reactos/subsys/system/winefile/en.rc	2005-05-13 17:11:16 UTC (rev 15265)
@@ -210,4 +210,6 @@
 	IDS_COL_LINKS	"Links"
 	IDS_COL_ATTR	"Attributes"
 	IDS_COL_SEC		"Security"
+
+	IDS_FREE_SPACE_FMT	"%s of %s free"
 }

Modified: trunk/reactos/subsys/system/winefile/resource.h
--- trunk/reactos/subsys/system/winefile/resource.h	2005-05-13 15:35:55 UTC (rev 15264)
+++ trunk/reactos/subsys/system/winefile/resource.h	2005-05-13 17:11:16 UTC (rev 15265)
@@ -102,6 +102,7 @@
 #define IDS_COL_LINKS					1216
 #define IDS_COL_ATTR					1217
 #define IDS_COL_SEC						1218
+#define IDS_FREE_SPACE_FMT				1219
 
 
 /* range for drive bar command ids: 0x9000..0x90FF */

Modified: trunk/reactos/subsys/system/winefile/winefile.c
--- trunk/reactos/subsys/system/winefile/winefile.c	2005-05-13 15:35:55 UTC (rev 15264)
+++ trunk/reactos/subsys/system/winefile/winefile.c	2005-05-13 17:11:16 UTC (rev 15265)
@@ -2446,6 +2446,40 @@
 }
 
 
+static void format_bytes(LPTSTR buffer, LONGLONG bytes)
+{
+	const static TCHAR sFmtGB[] = {'%', '.', '1', 'f', ' ', 'G', 'B', '\0'};
+	const static TCHAR sFmtMB[] = {'%', '.', '1', 'f', ' ', 'M', 'B', '\0'};
+	const static TCHAR sFmtkB[] = {'%', '.', '1', 'f', ' ', 'k', 'B', '\0'};
+
+	float fBytes = (float)bytes;
+
+	if (bytes >= 1073741824)	// 1 GB
+		_stprintf(buffer, sFmtGB, fBytes/1073741824.f+.5f);
+	else if (bytes >= 1048576)	// 1 MB
+		_stprintf(buffer, sFmtMB, fBytes/1048576.f+.5f);
+	else if (bytes >= 1024)		// 1 kB
+		_stprintf(buffer, sFmtMB, fBytes/1024.f+.5f);
+	else
+		_stprintf(buffer, sLongNumFmt, bytes);
+}
+
+static void set_space_status()
+{
+	ULARGE_INTEGER ulFreeBytesToCaller, ulTotalBytes, ulFreeBytes;
+	TCHAR fmt[64], b1[64], b2[64], buffer[BUFFER_LEN];
+
+	if (GetDiskFreeSpaceEx(NULL, &ulFreeBytesToCaller, &ulTotalBytes, &ulFreeBytes)) {
+		format_bytes(b1, ulFreeBytesToCaller.QuadPart);
+		format_bytes(b2, ulTotalBytes.QuadPart);
+		_stprintf(buffer, RS(fmt,IDS_FREE_SPACE_FMT), b1, b2);
+	} else
+		_tcscpy(buffer, sQMarks);
+
+	SendMessage(Globals.hstatusbar, SB_SETTEXT, 0, (LPARAM)buffer);
+}
+
+
 static WNDPROC g_orgTreeWndProc;
 
 static void create_tree_window(HWND parent, Pane* pane, int id, int id_header)
@@ -2755,13 +2789,13 @@
 #endif
 					)
 					LineTo(dis->hDC, x, dis->rcItem.bottom);
-
+/*@@
 				if (entry->down && entry->expanded) {
 					x += IMAGE_WIDTH+TREE_LINE_DX;
 					MoveToEx(dis->hDC, x, dis->rcItem.top+IMAGE_HEIGHT, 0);
 					LineTo(dis->hDC, x, dis->rcItem.bottom);
 				}
-
+*/
 				SelectClipRgn(dis->hDC, hrgn_org);
 				if (hrgn_org) DeleteObject(hrgn_org);
 				/* SelectObject(dis->hDC, holdPen); */
@@ -3299,7 +3333,8 @@
 		SetWindowText(child->hwnd, path);
 
 	if (path[0])
-		SetCurrentDirectory(path);
+		if (SetCurrentDirectory(path))
+			set_space_status();
 }
 
 
@@ -3728,7 +3763,8 @@
 #endif /* _NO_EXTENSIONS */
 
 		case WM_SETFOCUS:
-			SetCurrentDirectory(child->path);
+			if (SetCurrentDirectory(child->path))
+				set_space_status();
 			SetFocus(child->focus_pane? child->right.hwnd: child->left.hwnd);
 			break;