Use FileGetString instead of ReadFile, because ReadFile doesn't return a null termina...
[reactos.git] / reactos / subsys / system / cmd / free.c
index 667fb62..2eba7d1 100644 (file)
@@ -6,18 +6,16 @@
  *
  *    01-Sep-1999 (Eric Kohl)
  *        Started.
+ *
+ *    28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
+ *        Remove all hardcode string to En.rc
  */
 
-#include "config.h"
+#include <precomp.h>
+#include "resource.h"
 
 #ifdef INCLUDE_CMD_FREE
 
-#include "precomp.h"
-#include <tchar.h>
-#include <string.h>
-#include <stdio.h>
-#include <ctype.h>
-
 
 /*
  * convert
@@ -60,6 +58,7 @@ ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len)
 static VOID
 PrintDiskInfo (LPTSTR szDisk)
 {
+       TCHAR szMsg[RC_STRING_MAX_SIZE];
        TCHAR szRootPath[4] = _T("A:\\");
        TCHAR szDrive[2] = _T("A");
        TCHAR szVolume[64];
@@ -76,7 +75,8 @@ PrintDiskInfo (LPTSTR szDisk)
 
        if (_tcslen (szDisk) < 2 || szDisk[1] != _T(':'))
        {
-               ConErrPrintf (_T("Invalid drive %s\n"), szDisk);
+               LoadString(CMD_ModuleHandle, STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE);
+               ConErrPrintf(szMsg);
                return;
        }
 
@@ -86,12 +86,17 @@ PrintDiskInfo (LPTSTR szDisk)
        if (!GetVolumeInformation (szRootPath, szVolume, 64, &dwSerial,
                                   NULL, NULL, NULL, 0))
        {
-               ConErrPrintf (_T("Invalid drive %s:\n"), szDrive);
+               LoadString(CMD_ModuleHandle, STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE);
+               ConErrPrintf(_T("%s %s:\n"), szMsg, szDrive);
                return;
        }
 
        if (szVolume[0] == _T('\0'))
-               _tcscpy (szVolume, _T("unlabeled"));
+       {
+
+               LoadString(CMD_ModuleHandle, STRING_FREE_ERROR2, szMsg, RC_STRING_MAX_SIZE);
+               _tcscpy (szVolume, szMsg);
+       }
 
        _stprintf (szSerial,
                   _T("%04X-%04X"),
@@ -101,7 +106,8 @@ PrintDiskInfo (LPTSTR szDisk)
        if (!GetDiskFreeSpace (szRootPath, &dwSecPerCl,
                               &dwBytPerSec, &dwFreeCl, &dwTotCl))
        {
-               ConErrPrintf (_T("Invalid drive %s:\n"), szDrive);
+               LoadString(CMD_ModuleHandle, STRING_FREE_ERROR1, szMsg, RC_STRING_MAX_SIZE);
+               ConErrPrintf (_T("%s %s:\n"), szMsg, szDrive);
                return;
        }
 
@@ -114,13 +120,9 @@ PrintDiskInfo (LPTSTR szDisk)
        uliSize.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl;
        ConvertULargeInteger (uliSize, szFree, 40);
 
-       ConOutPrintf (_T("\n"
-                        " Volume in drive %s is %-11s   Serial number is %s\n"
-                        "  %16s bytes total disk space\n"
-                        "  %16s bytes used\n"
-                        "  %16s bytes free\n"),
-                     szDrive, szVolume, szSerial,
-                     szTotal, szUsed, szFree);
+
+       LoadString(CMD_ModuleHandle, STRING_FREE_HELP1, szMsg, RC_STRING_MAX_SIZE);
+       ConOutPrintf(szMsg, szDrive, szVolume, szSerial, szTotal, szUsed, szFree);
 }
 
 
@@ -133,9 +135,7 @@ INT CommandFree (LPTSTR cmd, LPTSTR param)
 
        if (!_tcsncmp (param, _T("/?"), 2))
        {
-               ConOutPuts (_T("Displays drive information.\n"
-                              "\n"
-                              "FREE [drive: ...]"));
+               ConOutResPaging(TRUE,STRING_FREE_HELP2);
                return 0;
        }