2 * FREE.C - internal command.
7 * 01-Sep-1999 (Eric Kohl)
10 * 28-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
11 * Remove all hardcoded strings in En.rc
16 #ifdef INCLUDE_CMD_FREE
19 PrintDiskInfo (LPTSTR szDisk
)
21 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
22 TCHAR szRootPath
[4] = _T("A:\\");
23 TCHAR szDrive
[2] = _T("A");
36 if (_tcslen (szDisk
) < 2 || szDisk
[1] != _T(':'))
38 ConErrResPrintf(STRING_FREE_ERROR1
);
42 szRootPath
[0] = szDisk
[0];
43 szDrive
[0] = _totupper (szRootPath
[0]);
45 if (!GetVolumeInformation (szRootPath
, szVolume
, 64, &dwSerial
,
48 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR1
, szMsg
, ARRAYSIZE(szMsg
));
49 ConErrPrintf(_T("%s %s:\n"), szMsg
, szDrive
);
53 if (szVolume
[0] == _T('\0'))
56 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR2
, szMsg
, ARRAYSIZE(szMsg
));
57 _tcscpy (szVolume
, szMsg
);
65 if (!GetDiskFreeSpace (szRootPath
, &dwSecPerCl
,
66 &dwBytPerSec
, &dwFreeCl
, &dwTotCl
))
68 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR1
, szMsg
, ARRAYSIZE(szMsg
));
69 ConErrPrintf(_T("%s %s:\n"), szMsg
, szDrive
);
73 uliSize
= dwSecPerCl
* dwBytPerSec
* (ULONGLONG
)dwTotCl
;
74 ConvertULargeInteger(uliSize
, szTotal
, 40, TRUE
);
76 uliSize
= dwSecPerCl
* dwBytPerSec
* (ULONGLONG
)(dwTotCl
- dwFreeCl
);
77 ConvertULargeInteger(uliSize
, szUsed
, 40, TRUE
);
79 uliSize
= dwSecPerCl
* dwBytPerSec
* (ULONGLONG
)dwFreeCl
;
80 ConvertULargeInteger(uliSize
, szFree
, 40, TRUE
);
82 ConOutResPrintf(STRING_FREE_HELP1
, szDrive
, szVolume
, szSerial
, szTotal
, szUsed
, szFree
);
86 INT
CommandFree (LPTSTR param
)
89 TCHAR szDefPath
[MAX_PATH
];
93 if (!_tcsncmp (param
, _T("/?"), 2))
95 ConOutResPaging(TRUE
,STRING_FREE_HELP2
);
99 if (!param
|| *param
== _T('\0'))
101 GetCurrentDirectory (MAX_PATH
, szDefPath
);
102 szDefPath
[2] = _T('\0');
108 arg
= split (szParam
, &argc
, FALSE
, FALSE
);
110 for (i
= 0; i
< argc
; i
++)
111 PrintDiskInfo (arg
[i
]);
118 #endif /* INCLUDE_CMD_FREE */