take care of Bug#: 1084
[reactos.git] / reactos / subsys / system / cmd / dir.c
index 90361e7..7239811 100644 (file)
@@ -982,38 +982,6 @@ ConvertULong (ULONG num, LPTSTR des, INT len)
 }
 #endif
 
-static INT
-ConvertULargeInteger (ULARGE_INTEGER num, LPTSTR des, INT len, BOOL bPutSeperator)
-{
-       TCHAR temp[32];
-       INT c = 0;
-       INT n = 0;
-
-       if (num.QuadPart == 0)
-       {
-               des[0] = _T('0');
-               des[1] = _T('\0');
-               n = 1;
-       }
-       else
-       {
-               temp[31] = 0;
-               while (num.QuadPart > 0)
-               {
-                       if ((((c + 1) % (nNumberGroups + 1)) == 0) && (bPutSeperator))
-                               temp[30 - c++] = cThousandSeparator;
-   temp[30 - c++] = (TCHAR)(num.QuadPart % 10) + _T('0');
-                       num.QuadPart /= 10;
-               }
-
-               for (n = 0; n <= c; n++)
-                       des[n] = temp[31 - c + n];
-       }
-
-       return n;
-}
-
-
 static VOID
 DirPrintFileDateTime(TCHAR *lpDate,
                      TCHAR *lpTime,
@@ -1162,11 +1130,14 @@ PrintSummary(LPTSTR szPath,
                return 1;
        }
 
+
        /* In bare format we don't print results */
        if (lpFlags->bBareFormat)
                return 0;
 
        /* Print recursive specific results */
+       
+    /* Take this code offline to fix /S does not print duoble info */
        if (lpFlags->bRecursive)
        {
                ConvertULargeInteger(u64Bytes, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator);
@@ -1176,8 +1147,22 @@ PrintSummary(LPTSTR szPath,
                   ConOutPrintfPaging(FALSE,szMsg,ulFiles, szBuffer);
                else
                   ConOutPrintf(szMsg,ulFiles, szBuffer);
-       }
+                  
+                  if (ulFiles > 0)
+       {
+               ConvertULargeInteger(u64Bytes, szBuffer, 20, lpFlags->bTSeperator);
+               LoadString(CMD_ModuleHandle, STRING_DIR_HELP8, szMsg, RC_STRING_MAX_SIZE);
+               if(lpFlags->bPause)
+                  ConOutPrintfPaging(FALSE,szMsg,ulFiles, szBuffer);
+               else
+                  ConOutPrintf(szMsg,ulFiles, szBuffer);
 
+       }
+       
+       }
+     else
+     {
+     
        /* Print File Summary */
        /* Condition to print summary is:
           If we are not in bare format and if we have results! */
@@ -1191,7 +1176,8 @@ PrintSummary(LPTSTR szPath,
                   ConOutPrintf(szMsg,ulFiles, szBuffer);
 
        }
-
+       
+}
        /* Print total directories and freespace */
        szRoot[0] = szPath[0];
        GetUserDiskFreeSpace(szRoot, &uliFree);
@@ -1985,7 +1971,7 @@ CommandDir(LPTSTR first, LPTSTR rest)
        TCHAR   szPath[MAX_PATH];
        TCHAR   szFilespec[MAX_PATH];
        LPTSTR* params;
-       UINT    entries = 0;
+       INT             entries = 0;
        INT             nLine = 0;
        UINT    loop = 0;
        DIRSWITCHFLAGS stFlags;
@@ -2027,7 +2013,7 @@ CommandDir(LPTSTR first, LPTSTR rest)
                }
 
        /* read the parameters */
-       if (!DirReadParam(rest, &params, &entries, &stFlags))
+       if (!DirReadParam(rest, &params, &entries, &stFlags) || CheckCtrlBreak(BREAK_INPUT))
        {
                nErrorLevel = 1;
                return 1;
@@ -2044,7 +2030,7 @@ CommandDir(LPTSTR first, LPTSTR rest)
        for(loop = 0; loop < entries; loop++)
        {
                /* parse the directory info */
-               if (DirParsePathspec (params[loop], szPath, szFilespec))
+               if (DirParsePathspec (params[loop], szPath, szFilespec) || CheckCtrlBreak(BREAK_INPUT))
                {
                        nErrorLevel = 1;
                        return 1;