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
20 PrintDiskInfo (LPTSTR szDisk
)
22 TCHAR szMsg
[RC_STRING_MAX_SIZE
];
23 TCHAR szRootPath
[4] = _T("A:\\");
24 TCHAR szDrive
[2] = _T("A");
31 ULARGE_INTEGER uliSize
;
37 if (_tcslen (szDisk
) < 2 || szDisk
[1] != _T(':'))
39 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR1
, szMsg
, RC_STRING_MAX_SIZE
);
44 szRootPath
[0] = szDisk
[0];
45 szDrive
[0] = _totupper (szRootPath
[0]);
47 if (!GetVolumeInformation (szRootPath
, szVolume
, 64, &dwSerial
,
50 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR1
, szMsg
, RC_STRING_MAX_SIZE
);
51 ConErrPrintf(_T("%s %s:\n"), szMsg
, szDrive
);
55 if (szVolume
[0] == _T('\0'))
58 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR2
, szMsg
, RC_STRING_MAX_SIZE
);
59 _tcscpy (szVolume
, szMsg
);
67 if (!GetDiskFreeSpace (szRootPath
, &dwSecPerCl
,
68 &dwBytPerSec
, &dwFreeCl
, &dwTotCl
))
70 LoadString(CMD_ModuleHandle
, STRING_FREE_ERROR1
, szMsg
, RC_STRING_MAX_SIZE
);
71 ConErrPrintf (_T("%s %s:\n"), szMsg
, szDrive
);
75 uliSize
.QuadPart
= dwSecPerCl
* dwBytPerSec
* dwTotCl
;
76 ConvertULargeInteger (uliSize
, szTotal
, 40, TRUE
);
78 uliSize
.QuadPart
= dwSecPerCl
* dwBytPerSec
* (dwTotCl
- dwFreeCl
);
79 ConvertULargeInteger (uliSize
, szUsed
, 40, TRUE
);
81 uliSize
.QuadPart
= dwSecPerCl
* dwBytPerSec
* dwFreeCl
;
82 ConvertULargeInteger (uliSize
, szFree
, 40, TRUE
);
85 LoadString(CMD_ModuleHandle
, STRING_FREE_HELP1
, szMsg
, RC_STRING_MAX_SIZE
);
86 ConOutPrintf(szMsg
, szDrive
, szVolume
, szSerial
, szTotal
, szUsed
, szFree
);
90 INT
CommandFree (LPTSTR cmd
, LPTSTR param
)
93 TCHAR szDefPath
[MAX_PATH
];
97 if (!_tcsncmp (param
, _T("/?"), 2))
99 ConOutResPaging(TRUE
,STRING_FREE_HELP2
);
103 if (!param
|| *param
== _T('\0'))
105 GetCurrentDirectory (MAX_PATH
, szDefPath
);
106 szDefPath
[2] = _T('\0');
112 arg
= split (szParam
, &argc
, FALSE
);
114 for (i
= 0; i
< argc
; i
++)
115 PrintDiskInfo (arg
[i
]);
122 #endif /* INCLUDE_CMD_FREE */