2 * FREE.C - internal command.
7 * 01-Sep-1999 (Eric Kohl)
10 * 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
11 * Remove all hardcode string to En.rc
17 #ifdef INCLUDE_CMD_FREE
23 * insert commas into a number
27 ConvertULargeInteger (ULARGE_INTEGER num
, LPTSTR des
, INT len
)
33 if (num
.QuadPart
== 0)
42 while (num
.QuadPart
> 0)
44 if (((c
+ 1) % (nNumberGroups
+ 1)) == 0)
45 temp
[30 - c
++] = cThousandSeparator
;
46 temp
[30 - c
++] = (TCHAR
)(num
.QuadPart
% 10) + _T('0');
50 for (n
= 0; n
<= c
; n
++)
51 des
[n
] = temp
[31 - c
+ n
];
59 PrintDiskInfo (LPTSTR szDisk
)
61 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
62 TCHAR szRootPath
[4] = _T("A:\\");
63 TCHAR szDrive
[2] = _T("A");
70 ULARGE_INTEGER uliSize
;
76 if (_tcslen (szDisk
) < 2 || szDisk
[1] != _T(':'))
78 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR1
, szMsg
, RC_STRING_MAX_SIZE
);
83 szRootPath
[0] = szDisk
[0];
84 szDrive
[0] = _totupper (szRootPath
[0]);
86 if (!GetVolumeInformation (szRootPath
, szVolume
, 64, &dwSerial
,
89 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR1
, szMsg
, RC_STRING_MAX_SIZE
);
90 ConErrPrintf(_T("%s %s:\n"), szMsg
, szDrive
);
94 if (szVolume
[0] == _T('\0'))
97 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR2
, szMsg
, RC_STRING_MAX_SIZE
);
98 _tcscpy (szVolume
, szMsg
);
106 if (!GetDiskFreeSpace (szRootPath
, &dwSecPerCl
,
107 &dwBytPerSec
, &dwFreeCl
, &dwTotCl
))
109 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR1
, szMsg
, RC_STRING_MAX_SIZE
);
110 ConErrPrintf (_T("%s %s:\n"), szMsg
, szDrive
);
114 uliSize
.QuadPart
= dwSecPerCl
* dwBytPerSec
* dwTotCl
;
115 ConvertULargeInteger (uliSize
, szTotal
, 40);
117 uliSize
.QuadPart
= dwSecPerCl
* dwBytPerSec
* (dwTotCl
- dwFreeCl
);
118 ConvertULargeInteger (uliSize
, szUsed
, 40);
120 uliSize
.QuadPart
= dwSecPerCl
* dwBytPerSec
* dwFreeCl
;
121 ConvertULargeInteger (uliSize
, szFree
, 40);
124 LoadString(CMD_ModuleHandle
, STRING_FREE_HELP1
, szMsg
, RC_STRING_MAX_SIZE
);
125 ConOutPrintf(szMsg
, szDrive
, szVolume
, szSerial
, szTotal
, szUsed
, szFree
);
129 INT
CommandFree (LPTSTR cmd
, LPTSTR param
)
132 TCHAR szDefPath
[MAX_PATH
];
136 if (!_tcsncmp (param
, _T("/?"), 2))
138 ConOutResPaging(TRUE
,STRING_FREE_HELP2
);
142 if (!param
|| *param
== _T('\0'))
144 GetCurrentDirectory (MAX_PATH
, szDefPath
);
145 szDefPath
[2] = _T('\0');
151 arg
= split (szParam
, &argc
, FALSE
);
153 for (i
= 0; i
< argc
; i
++)
154 PrintDiskInfo (arg
[i
]);
161 #endif /* INCLUDE_CMD_FREE */