remove empty dir
[reactos.git] / rosapps / winfile / drivebar.c
1 /*
2 * ReactOS winfile
3 *
4 * drivebar.c
5 *
6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
24 #include <windows.h>
25 #include <commctrl.h>
26 #include <stdlib.h>
27 #include <malloc.h>
28 #include <memory.h>
29 #include <tchar.h>
30 #include <process.h>
31 #include <stdio.h>
32
33 #include "main.h"
34 #include "settings.h"
35 #include "framewnd.h"
36 #include "childwnd.h"
37
38
39 ////////////////////////////////////////////////////////////////////////////////
40 // Global Variables:
41 //
42
43
44 void ConfigureDriveBar(HWND hDriveBar)
45 {
46 static DWORD dwLogicalDrivesSaved;
47 DWORD dwLogicalDrives = GetLogicalDrives();
48
49 if (!hDriveBar) return;
50 #ifndef __GNUC__
51 if (dwLogicalDrives != dwLogicalDrivesSaved) {
52 TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP};
53 COMBOBOXEXITEM cbei;
54 int btn = 1;
55 PTSTR p;
56 int count = SendMessage(hDriveBar, TB_BUTTONCOUNT, 0, 0);
57 while (count) {
58 SendMessage(hDriveBar, TB_DELETEBUTTON, (WPARAM)--count, 0);
59 }
60 count = SendMessage(Globals.hDriveCombo, CB_GETCOUNT, 0, 0);
61 while (count) {
62 // SendMessage(Globals.hDriveCombo, CB_DELETESTRING, (WPARAM)--count, 0);
63 }
64 SendMessage(Globals.hDriveCombo, CB_RESETCONTENT, 0, 0);
65
66 memset(Globals.drives, 0, BUFFER_LEN);
67 GetLogicalDriveStrings(BUFFER_LEN, Globals.drives);
68 drivebarBtn.fsStyle = TBSTYLE_BUTTON;
69 drivebarBtn.idCommand = ID_DRIVE_FIRST;
70 for (p = Globals.drives; *p;) {
71 // insert drive letter
72 // TCHAR b[3] = { tolower(*p) };
73 // SendMessage(hDriveBar, TB_ADDSTRING, 0, (LPARAM)b);
74 TCHAR szVolumeNameBuffer[MAX_PATH];
75 TCHAR vol[MAX_PATH] = { tolower(*p) };
76 SendMessage(hDriveBar, TB_ADDSTRING, 0, (LPARAM)vol);
77 switch(GetDriveType(p)) {
78 case DRIVE_REMOVABLE: drivebarBtn.iBitmap = 1; break;
79 case DRIVE_CDROM: drivebarBtn.iBitmap = 3; break;
80 case DRIVE_REMOTE: drivebarBtn.iBitmap = 4; break;
81 case DRIVE_RAMDISK: drivebarBtn.iBitmap = 5; break;
82 default:/*DRIVE_FIXED*/ drivebarBtn.iBitmap = 2;
83 }
84 SendMessage(hDriveBar, TB_INSERTBUTTON, btn, (LPARAM)&drivebarBtn);
85
86 vol[0] = toupper(vol[0]);
87 vol[1] = _T(':'); vol[2] = _T('\\'); vol[3] = _T('\0');
88 if (drivebarBtn.iBitmap != 1 /*DRIVE_REMOVABLE*/ &&
89 GetVolumeInformation(vol, szVolumeNameBuffer,
90 sizeof(szVolumeNameBuffer)/sizeof(TCHAR),
91 NULL, NULL, NULL, NULL, 0) &&
92 szVolumeNameBuffer[0] != _T('\0')) {
93 vol[2] = _T(' '); vol[3] = _T('['); vol[4] = _T('\0');
94 _tcscat(vol, szVolumeNameBuffer);
95 _tcscat(vol, _T("] "));
96 } else {
97 vol[2] = _T(' ');
98 }
99 // cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE;
100 cbei.mask = CBEIF_TEXT/* | CBEIF_IMAGE*/;
101 cbei.iItem = btn - 1;
102 cbei.pszText = vol;
103 cbei.cchTextMax = _tcslen(cbei.pszText);
104 cbei.iImage = drivebarBtn.iBitmap;
105 // cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
106 // cbei.iIndent = IInf[iCnt].iIndent;
107 SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
108
109 drivebarBtn.idCommand++;
110 drivebarBtn.iString++;
111 while(*p++);
112 ++btn;
113 }
114 dwLogicalDrivesSaved = dwLogicalDrives;
115 // SendMessage(Globals.hDriveCombo, CB_SHOWDROPDOWN, (WPARAM)TRUE, (LPARAM)0);
116 }
117 #endif
118 }
119 /*
120 #ifndef __GNUC__
121 {
122 #define MAX_ITEMS 7
123
124 typedef struct {
125 int iImage;
126 int iSelectedImage;
127 int iIndent;
128 LPTSTR pszText;
129 } ITEMINFO, *PITEMINFO;
130
131 ITEMINFO IInf[] = {
132 { 0, 3, 0, _T("A:")},
133 { 1, 4, 1, _T("C: [SYSTEM]")},
134 { 2, 5, 2, _T("D:")},
135 { 0, 3, 0, _T("E: [SOFT_RAID_1]")},
136 { 1, 4, 1, _T("F: [DATAVOL]")},
137 { 2, 5, 2, _T("sixth")},
138 { 0, 3, 0, _T("seventh")},
139 };
140
141 COMBOBOXEXITEM cbei;
142 int iCnt;
143
144 for (iCnt = 0; iCnt < MAX_ITEMS; iCnt++) {
145 // cbei.mask = CBEIF_TEXT | CBEIF_INDENT | CBEIF_IMAGE| CBEIF_SELECTEDIMAGE;
146 cbei.mask = CBEIF_TEXT;
147 cbei.iItem = iCnt;
148 cbei.pszText = IInf[iCnt].pszText;
149 // cbei.cchTextMax = sizeof(IInf[iCnt].pszText);
150 cbei.cchTextMax = _tcslen(IInf[iCnt].pszText);
151 // cbei.iImage = IInf[iCnt].iImage;
152 // cbei.iSelectedImage = IInf[iCnt].iSelectedImage;
153 // cbei.iIndent = IInf[iCnt].iIndent;
154 SendMessage(Globals.hDriveCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);
155 }
156 }
157 }
158 #endif
159 */
160
161 void _GetFreeSpaceEx(void)
162 {
163 BOOL fResult;
164 TCHAR szDrive[MAX_PATH];
165 ULARGE_INTEGER i64FreeBytesToCaller;
166 ULARGE_INTEGER i64TotalBytes;
167 ULARGE_INTEGER i64FreeBytes;
168
169 fResult = GetDiskFreeSpaceEx(szDrive,
170 (PULARGE_INTEGER)&i64FreeBytesToCaller,
171 (PULARGE_INTEGER)&i64TotalBytes,
172 (PULARGE_INTEGER)&i64FreeBytes);
173 }
174