mirror of
https://github.com/reactos/reactos.git
synced 2025-06-08 19:00:42 +00:00
- Clean up code for DIR command
- Fix bug where "DIR directoryname /S" wouldn't list subdirectories (you needed to do directoryname\*.*) - Get rid of extra * that appeared in DIR /B /S output svn path=/trunk/; revision=39910
This commit is contained in:
parent
357903327b
commit
be7941b485
1 changed files with 68 additions and 217 deletions
|
@ -565,6 +565,21 @@ DirReadParam(LPTSTR Line, /* [IN] The line with the parameters & switches */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Print either with or without paging, depending on /P switch */
|
||||||
|
static INT
|
||||||
|
DirPrintf(LPDIRSWITCHFLAGS lpFlags, LPTSTR szFormat, ...)
|
||||||
|
{
|
||||||
|
INT iReturn = 0;
|
||||||
|
va_list arg_ptr;
|
||||||
|
va_start(arg_ptr, szFormat);
|
||||||
|
if (lpFlags->bPause)
|
||||||
|
iReturn = ConPrintfPaging(FALSE, szFormat, arg_ptr, STD_OUTPUT_HANDLE);
|
||||||
|
else
|
||||||
|
ConPrintf(szFormat, arg_ptr, STD_OUTPUT_HANDLE);
|
||||||
|
va_end(arg_ptr);
|
||||||
|
return iReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PrintDirectoryHeader
|
* PrintDirectoryHeader
|
||||||
|
@ -605,78 +620,22 @@ PrintDirectoryHeader(LPTSTR szPath, LPDIRSWITCHFLAGS lpFlags)
|
||||||
if (szVolName[0] != _T('\0'))
|
if (szVolName[0] != _T('\0'))
|
||||||
{
|
{
|
||||||
LoadString(CMD_ModuleHandle, STRING_DIR_HELP2, szMsg, RC_STRING_MAX_SIZE);
|
LoadString(CMD_ModuleHandle, STRING_DIR_HELP2, szMsg, RC_STRING_MAX_SIZE);
|
||||||
//needs to have first paramter as TRUE because
|
DirPrintf(lpFlags, szMsg, szRootName[0], szVolName);
|
||||||
//this is the first output and need to clear the static
|
|
||||||
if(lpFlags->bPause)
|
|
||||||
ConOutPrintfPaging(TRUE,szMsg, szRootName[0], szVolName);
|
|
||||||
else
|
|
||||||
ConOutPrintf(szMsg, szRootName[0], szVolName);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadString(CMD_ModuleHandle, STRING_DIR_HELP3, szMsg, RC_STRING_MAX_SIZE);
|
LoadString(CMD_ModuleHandle, STRING_DIR_HELP3, szMsg, RC_STRING_MAX_SIZE);
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, szMsg, szRootName[0]);
|
||||||
ConOutPrintfPaging(TRUE,szMsg, szRootName[0]);
|
|
||||||
else
|
|
||||||
ConOutPrintf(szMsg, szRootName[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print the volume serial number if the return was successful */
|
/* print the volume serial number if the return was successful */
|
||||||
LoadString(CMD_ModuleHandle, STRING_DIR_HELP4, (LPTSTR) szMsg, RC_STRING_MAX_SIZE);
|
LoadString(CMD_ModuleHandle, STRING_DIR_HELP4, (LPTSTR) szMsg, RC_STRING_MAX_SIZE);
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, szMsg, HIWORD(dwSerialNr), LOWORD(dwSerialNr));
|
||||||
ConOutPrintfPaging(FALSE,szMsg,
|
|
||||||
HIWORD(dwSerialNr),
|
|
||||||
LOWORD(dwSerialNr));
|
|
||||||
else
|
|
||||||
ConOutPrintf(szMsg,
|
|
||||||
HIWORD(dwSerialNr),
|
|
||||||
LOWORD(dwSerialNr));
|
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* convert
|
|
||||||
*
|
|
||||||
* insert commas into a number
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#if 0
|
|
||||||
static INT
|
|
||||||
ConvertULong (ULONG num, LPTSTR des, INT len)
|
|
||||||
{
|
|
||||||
TCHAR temp[32];
|
|
||||||
INT c = 0;
|
|
||||||
INT n = 0;
|
|
||||||
|
|
||||||
if (num == 0)
|
|
||||||
{
|
|
||||||
des[0] = _T('0');
|
|
||||||
des[1] = _T('\0');
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
temp[31] = 0;
|
|
||||||
while (num > 0)
|
|
||||||
{
|
|
||||||
if (((c + 1) % (nNumberGroups + 1)) == 0)
|
|
||||||
temp[30 - c++] = cThousandSeparator;
|
|
||||||
temp[30 - c++] = (TCHAR)(num % 10) + _T('0');
|
|
||||||
num /= 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (n = 0; n <= c; n++)
|
|
||||||
des[n] = temp[31 - c + n];
|
|
||||||
}
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
DirPrintFileDateTime(TCHAR *lpDate,
|
DirPrintFileDateTime(TCHAR *lpDate,
|
||||||
TCHAR *lpTime,
|
TCHAR *lpTime,
|
||||||
|
@ -685,8 +644,6 @@ DirPrintFileDateTime(TCHAR *lpDate,
|
||||||
{
|
{
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
SYSTEMTIME dt;
|
SYSTEMTIME dt;
|
||||||
TCHAR szDate[30];
|
|
||||||
TCHAR szTime[30];
|
|
||||||
WORD wYear;
|
WORD wYear;
|
||||||
|
|
||||||
/* Select the right time field */
|
/* Select the right time field */
|
||||||
|
@ -717,20 +674,20 @@ DirPrintFileDateTime(TCHAR *lpDate,
|
||||||
{
|
{
|
||||||
case 0: /* mmddyy */
|
case 0: /* mmddyy */
|
||||||
default:
|
default:
|
||||||
_stprintf (szDate, _T("%02d%c%02d%c%0*d"),
|
_stprintf(lpDate, _T("%02d%c%02d%c%0*d"),
|
||||||
dt.wMonth, cDateSeparator,
|
dt.wMonth, cDateSeparator,
|
||||||
dt.wDay, cDateSeparator,
|
dt.wDay, cDateSeparator,
|
||||||
lpFlags->b4Digit?4:2, wYear);
|
lpFlags->b4Digit?4:2, wYear);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* ddmmyy */
|
case 1: /* ddmmyy */
|
||||||
_stprintf (szDate, _T("%02d%c%02d%c%0*d"),
|
_stprintf(lpDate, _T("%02d%c%02d%c%0*d"),
|
||||||
dt.wDay, cDateSeparator, dt.wMonth,
|
dt.wDay, cDateSeparator, dt.wMonth,
|
||||||
cDateSeparator,lpFlags->b4Digit?4:2, wYear);
|
cDateSeparator,lpFlags->b4Digit?4:2, wYear);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* yymmdd */
|
case 2: /* yymmdd */
|
||||||
_stprintf (szDate, _T("%0*d%c%02d%c%02d"),
|
_stprintf(lpDate, _T("%0*d%c%02d%c%02d"),
|
||||||
lpFlags->b4Digit?4:2, wYear, cDateSeparator,
|
lpFlags->b4Digit?4:2, wYear, cDateSeparator,
|
||||||
dt.wMonth, cDateSeparator, dt.wDay);
|
dt.wMonth, cDateSeparator, dt.wDay);
|
||||||
break;
|
break;
|
||||||
|
@ -740,20 +697,17 @@ DirPrintFileDateTime(TCHAR *lpDate,
|
||||||
{
|
{
|
||||||
case 0: /* 12 hour format */
|
case 0: /* 12 hour format */
|
||||||
default:
|
default:
|
||||||
_stprintf (szTime,_T("%02d%c%02u%c"),
|
_stprintf(lpTime,_T("%02d%c%02u%c"),
|
||||||
(dt.wHour == 0 ? 12 : (dt.wHour <= 12 ? dt.wHour : dt.wHour - 12)),
|
(dt.wHour == 0 ? 12 : (dt.wHour <= 12 ? dt.wHour : dt.wHour - 12)),
|
||||||
cTimeSeparator,
|
cTimeSeparator,
|
||||||
dt.wMinute, (dt.wHour <= 11 ? _T('a') : _T('p')));
|
dt.wMinute, (dt.wHour <= 11 ? _T('a') : _T('p')));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* 24 hour format */
|
case 1: /* 24 hour format */
|
||||||
_stprintf (szTime, _T("%02d%c%02u"),
|
_stprintf(lpTime, _T("%02d%c%02u"),
|
||||||
dt.wHour, cTimeSeparator, dt.wMinute);
|
dt.wHour, cTimeSeparator, dt.wMinute);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Copy results */
|
|
||||||
_tcscpy(lpDate, szDate);
|
|
||||||
_tcscpy(lpTime, szTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -771,7 +725,7 @@ GetUserDiskFreeSpace(LPCTSTR lpRoot,
|
||||||
|
|
||||||
lpFreeSpace->QuadPart = 0;
|
lpFreeSpace->QuadPart = 0;
|
||||||
|
|
||||||
hInstance = LoadLibrary(_T("KERNEL32"));
|
hInstance = GetModuleHandle(_T("KERNEL32"));
|
||||||
if (hInstance != NULL)
|
if (hInstance != NULL)
|
||||||
{
|
{
|
||||||
pGetFreeDiskSpaceEx = (PGETFREEDISKSPACEEX)GetProcAddress(hInstance,
|
pGetFreeDiskSpaceEx = (PGETFREEDISKSPACEEX)GetProcAddress(hInstance,
|
||||||
|
@ -785,7 +739,6 @@ GetUserDiskFreeSpace(LPCTSTR lpRoot,
|
||||||
if (pGetFreeDiskSpaceEx(lpRoot, lpFreeSpace, &TotalNumberOfBytes, &TotalNumberOfFreeBytes) == TRUE)
|
if (pGetFreeDiskSpaceEx(lpRoot, lpFreeSpace, &TotalNumberOfBytes, &TotalNumberOfFreeBytes) == TRUE)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FreeLibrary(hInstance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetDiskFreeSpace(lpRoot,
|
GetDiskFreeSpace(lpRoot,
|
||||||
|
@ -837,10 +790,7 @@ PrintSummary(LPTSTR szPath,
|
||||||
{
|
{
|
||||||
ConvertULargeInteger(u64Bytes, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator);
|
ConvertULargeInteger(u64Bytes, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator);
|
||||||
LoadString(CMD_ModuleHandle, STRING_DIR_HELP5, szMsg, RC_STRING_MAX_SIZE);
|
LoadString(CMD_ModuleHandle, STRING_DIR_HELP5, szMsg, RC_STRING_MAX_SIZE);
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, szMsg, ulFiles, szBuffer);
|
||||||
ConOutPrintfPaging(FALSE,szMsg,ulFiles, szBuffer);
|
|
||||||
else
|
|
||||||
ConOutPrintf(szMsg,ulFiles, szBuffer);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -849,22 +799,16 @@ PrintSummary(LPTSTR szPath,
|
||||||
If we are not in bare format and if we have results! */
|
If we are not in bare format and if we have results! */
|
||||||
ConvertULargeInteger(u64Bytes, szBuffer, 20, lpFlags->bTSeperator);
|
ConvertULargeInteger(u64Bytes, szBuffer, 20, lpFlags->bTSeperator);
|
||||||
LoadString(CMD_ModuleHandle, STRING_DIR_HELP8, szMsg, RC_STRING_MAX_SIZE);
|
LoadString(CMD_ModuleHandle, STRING_DIR_HELP8, szMsg, RC_STRING_MAX_SIZE);
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, szMsg, ulFiles, szBuffer);
|
||||||
ConOutPrintfPaging(FALSE,szMsg,ulFiles, szBuffer);
|
|
||||||
else
|
|
||||||
ConOutPrintf(szMsg,ulFiles, szBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print total directories and freespace */
|
/* Print total directories and freespace */
|
||||||
if (!lpFlags->bRecursive || (TotalSummary && lpFlags->bRecursive))
|
if (!lpFlags->bRecursive || TotalSummary)
|
||||||
{
|
{
|
||||||
GetUserDiskFreeSpace(szPath, &uliFree);
|
GetUserDiskFreeSpace(szPath, &uliFree);
|
||||||
ConvertULargeInteger(uliFree, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator);
|
ConvertULargeInteger(uliFree, szBuffer, sizeof(szBuffer), lpFlags->bTSeperator);
|
||||||
LoadString(CMD_ModuleHandle, STRING_DIR_HELP6, (LPTSTR) szMsg, RC_STRING_MAX_SIZE);
|
LoadString(CMD_ModuleHandle, STRING_DIR_HELP6, (LPTSTR) szMsg, RC_STRING_MAX_SIZE);
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, szMsg, ulDirs, szBuffer);
|
||||||
ConOutPrintfPaging(FALSE,szMsg,ulDirs, szBuffer);
|
|
||||||
else
|
|
||||||
ConOutPrintf(szMsg,ulDirs, szBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -967,19 +911,7 @@ DirPrintNewList(LPWIN32_FIND_DATA ptrFiles[], /* [IN]Files' Info */
|
||||||
DirPrintFileDateTime(szDate, szTime, ptrFiles[i], lpFlags);
|
DirPrintFileDateTime(szDate, szTime, ptrFiles[i], lpFlags);
|
||||||
|
|
||||||
/* Print the line */
|
/* Print the line */
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, _T("%10s %-6s %*s%s %s\n"),
|
||||||
{
|
|
||||||
if (ConOutPrintfPaging(FALSE,_T("%10s %-6s %*s%s %s\n"),
|
|
||||||
szDate,
|
|
||||||
szTime,
|
|
||||||
iSizeFormat,
|
|
||||||
szSize,
|
|
||||||
szShortName,
|
|
||||||
ptrFiles[i]->cFileName) == 1)
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ConOutPrintf(_T("%10s %-6s %*s%s %s\n"),
|
|
||||||
szDate,
|
szDate,
|
||||||
szTime,
|
szTime,
|
||||||
iSizeFormat,
|
iSizeFormat,
|
||||||
|
@ -1065,17 +997,11 @@ DirPrintWideList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
|
||||||
else
|
else
|
||||||
_stprintf(szTempFname, _T("%s"), ptrFiles[temp]->cFileName);
|
_stprintf(szTempFname, _T("%s"), ptrFiles[temp]->cFileName);
|
||||||
|
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, _T("%-*s"), iLongestName + 1, szTempFname);
|
||||||
ConOutPrintfPaging(FALSE,_T("%-*s"), iLongestName + 1 , szTempFname);
|
|
||||||
else
|
|
||||||
ConOutPrintf(_T("%-*s"), iLongestName + 1 , szTempFname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a new line after the last item in the column */
|
/* Add a new line after the last item in the column */
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, _T("\n"));
|
||||||
ConOutPrintfPaging(FALSE,_T("\n"));
|
|
||||||
else
|
|
||||||
ConOutPrintf(_T("\n"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,21 +1061,7 @@ ULARGE_INTEGER u64FileSize; /* The file size */
|
||||||
DirPrintFileDateTime(szDate,szTime,ptrFiles[i],lpFlags);
|
DirPrintFileDateTime(szDate,szTime,ptrFiles[i],lpFlags);
|
||||||
|
|
||||||
/* Print the line */
|
/* Print the line */
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, _T("%-8s %-3s %*s %s %s\n"),
|
||||||
{
|
|
||||||
if (ConOutPrintfPaging(FALSE,_T("%-8s %-3s %*s %s %s\n"),
|
|
||||||
szName, /* The file's 8.3 name */
|
|
||||||
szExt, /* The file's 8.3 extension */
|
|
||||||
iSizeFormat, /* print format for size column */
|
|
||||||
szSize, /* The size of file or "<DIR>" for dirs */
|
|
||||||
szDate, /* The date of file/dir */
|
|
||||||
szTime) == 1) /* The time of file/dir */
|
|
||||||
{
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ConOutPrintf(_T("%-8s %-3s %*s %s %s\n"),
|
|
||||||
szName, /* The file's 8.3 name */
|
szName, /* The file's 8.3 name */
|
||||||
szExt, /* The file's 8.3 extension */
|
szExt, /* The file's 8.3 extension */
|
||||||
iSizeFormat, /* print format for size column */
|
iSizeFormat, /* print format for size column */
|
||||||
|
@ -1170,7 +1082,6 @@ DirPrintBareList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
|
||||||
LPTSTR lpCurPath, /* [IN] Full path of current directory */
|
LPTSTR lpCurPath, /* [IN] Full path of current directory */
|
||||||
LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */
|
LPDIRSWITCHFLAGS lpFlags) /* [IN] The flags used */
|
||||||
{
|
{
|
||||||
TCHAR szFullName[MAX_PATH];
|
|
||||||
DWORD i;
|
DWORD i;
|
||||||
|
|
||||||
for (i = 0; i < dwCount && !bCtrlBreak; i++)
|
for (i = 0; i < dwCount && !bCtrlBreak; i++)
|
||||||
|
@ -1184,30 +1095,12 @@ DirPrintBareList(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
|
||||||
if (lpFlags->bRecursive)
|
if (lpFlags->bRecursive)
|
||||||
{
|
{
|
||||||
/* at recursive mode we print full path of file */
|
/* at recursive mode we print full path of file */
|
||||||
_tcscpy(szFullName, lpCurPath);
|
DirPrintf(lpFlags, _T("%s\\%s\n"), lpCurPath, ptrFiles[i]->cFileName);
|
||||||
_tcscat(szFullName, ptrFiles[i]->cFileName);
|
|
||||||
if(lpFlags->bPause)
|
|
||||||
{
|
|
||||||
if (ConOutPrintfPaging(FALSE,_T("%s\n"), szFullName) == 1)
|
|
||||||
{
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ConOutPrintf(_T("%s\n"), szFullName);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* if we are not in recursive mode we print the file names */
|
/* if we are not in recursive mode we print the file names */
|
||||||
if(lpFlags->bPause)
|
DirPrintf(lpFlags, _T("%s\n"), ptrFiles[i]->cFileName);
|
||||||
{
|
|
||||||
if (ConOutPrintfPaging(FALSE,_T("%s\n"),ptrFiles[i]->cFileName) == 1)
|
|
||||||
{
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ConOutPrintf(_T("%s\n"),ptrFiles[i]->cFileName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1226,35 +1119,11 @@ DirPrintFiles(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
|
||||||
{
|
{
|
||||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||||
TCHAR szTemp[MAX_PATH]; /* A buffer to format the directory header */
|
TCHAR szTemp[MAX_PATH]; /* A buffer to format the directory header */
|
||||||
LPTSTR pszFilePart;
|
|
||||||
SIZE_T len;
|
|
||||||
|
|
||||||
/* We cut the trailing \ of the full path, unless the path is a drive */
|
/* Print trailing backslash for root directory of drive */
|
||||||
if (GetFullPathName(szCurPath, sizeof(szTemp) / sizeof(TCHAR), szTemp, &pszFilePart) == 0)
|
|
||||||
{
|
|
||||||
pszFilePart = NULL;
|
|
||||||
_tcscpy(szTemp, szCurPath);
|
_tcscpy(szTemp, szCurPath);
|
||||||
}
|
if (_tcslen(szTemp) == 2 && szTemp[1] == _T(':'))
|
||||||
else if (pszFilePart != NULL)
|
_tcscat(szTemp, _T("\\"));
|
||||||
*pszFilePart = _T('\0');
|
|
||||||
else
|
|
||||||
{
|
|
||||||
len = _tcslen(szTemp);
|
|
||||||
if (len > 0 && szTemp[len - 1] != _T('\\') &&
|
|
||||||
GetFileAttributes(szTemp) == INVALID_FILE_ATTRIBUTES &&
|
|
||||||
GetLastError() == ERROR_PATH_NOT_FOUND)
|
|
||||||
{
|
|
||||||
/* Special case for some fake dos devices, such as con:
|
|
||||||
GetFullPathName doesn't return a pszFilePart pointer
|
|
||||||
so we're going to fix this ourselves */
|
|
||||||
while (len > 0 && szTemp[len - 1] != _T('\\'))
|
|
||||||
szTemp[--len] = _T('\0');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
len = _tcslen(szTemp);
|
|
||||||
if ((len != 3 || szTemp[len - 2] != _T(':')) && szTemp[len - 1] == _T('\\'))
|
|
||||||
szTemp[len-1] = _T('\0');
|
|
||||||
|
|
||||||
/* Condition to print header:
|
/* Condition to print header:
|
||||||
We are not printing in bare format
|
We are not printing in bare format
|
||||||
|
@ -1262,16 +1131,9 @@ DirPrintFiles(LPWIN32_FIND_DATA ptrFiles[], /* [IN] Files' Info */
|
||||||
if (!(lpFlags->bBareFormat ) && !((lpFlags->bRecursive) && (dwCount <= 0)))
|
if (!(lpFlags->bBareFormat ) && !((lpFlags->bRecursive) && (dwCount <= 0)))
|
||||||
{
|
{
|
||||||
LoadString(CMD_ModuleHandle, STRING_DIR_HELP7, szMsg, RC_STRING_MAX_SIZE);
|
LoadString(CMD_ModuleHandle, STRING_DIR_HELP7, szMsg, RC_STRING_MAX_SIZE);
|
||||||
if(lpFlags->bPause)
|
if (DirPrintf(lpFlags, szMsg, szTemp))
|
||||||
{
|
|
||||||
if (ConOutPrintfPaging(FALSE,szMsg, szTemp) == 1)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
ConOutPrintf(szMsg, szTemp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lpFlags->bBareFormat)
|
if (lpFlags->bBareFormat)
|
||||||
{
|
{
|
||||||
|
@ -1400,10 +1262,7 @@ CompareFiles(LPWIN32_FIND_DATA lpFile1, /* [IN] A pointer to WIN32_FIND_DATA of
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Translate the value of iComp to boolean */
|
/* Translate the value of iComp to boolean */
|
||||||
if (iComp > 0)
|
return iComp > 0;
|
||||||
return TRUE;
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1491,18 +1350,17 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */
|
||||||
if (GetFullPathName(szPath, sizeof(szFullPath) / sizeof(TCHAR), szFullPath, &pszFilePart) == 0)
|
if (GetFullPathName(szPath, sizeof(szFullPath) / sizeof(TCHAR), szFullPath, &pszFilePart) == 0)
|
||||||
{
|
{
|
||||||
_tcscpy (szFullPath, szPath);
|
_tcscpy (szFullPath, szPath);
|
||||||
if (szFullPath[_tcslen(szFullPath) - 1] != _T('\\'))
|
|
||||||
_tcscat (szFullPath, _T("\\"));
|
|
||||||
pszFilePart = NULL;
|
pszFilePart = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If no wildcard or file was specified and this is a directory, then
|
/* If no wildcard or file was specified and this is a directory, then
|
||||||
display all files in it */
|
display all files in it */
|
||||||
wfdFileInfo.dwFileAttributes = GetFileAttributes(szFullPath);
|
if (pszFilePart == NULL || IsExistingDirectory(szFullPath))
|
||||||
if (wfdFileInfo.dwFileAttributes != INVALID_FILE_ATTRIBUTES &&
|
|
||||||
(wfdFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
|
||||||
{
|
{
|
||||||
_tcscat(szFullPath, _T("\\*"));
|
pszFilePart = &szFullPath[_tcslen(szFullPath)];
|
||||||
|
if (pszFilePart[-1] != _T('\\'))
|
||||||
|
*pszFilePart++ = _T('\\');
|
||||||
|
_tcscpy(pszFilePart, _T("*"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare the linked list, first node is allocated */
|
/* Prepare the linked list, first node is allocated */
|
||||||
|
@ -1520,9 +1378,9 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */
|
||||||
|
|
||||||
/* Collect the results for the current folder */
|
/* Collect the results for the current folder */
|
||||||
hSearch = FindFirstFile(szFullPath, &wfdFileInfo);
|
hSearch = FindFirstFile(szFullPath, &wfdFileInfo);
|
||||||
do
|
|
||||||
{
|
|
||||||
if (hSearch != INVALID_HANDLE_VALUE)
|
if (hSearch != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
do
|
||||||
{
|
{
|
||||||
/*If retrieved FileName has extension,and szPath doesnt have extension then JUMP the retrieved FileName*/
|
/*If retrieved FileName has extension,and szPath doesnt have extension then JUMP the retrieved FileName*/
|
||||||
if(_tcschr(wfdFileInfo.cFileName,_T('.'))&&(fPoint==TRUE))
|
if(_tcschr(wfdFileInfo.cFileName,_T('.'))&&(fPoint==TRUE))
|
||||||
|
@ -1543,6 +1401,7 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */
|
||||||
ptrStartNode = ptrNextNode;
|
ptrStartNode = ptrNextNode;
|
||||||
dwCount --;
|
dwCount --;
|
||||||
}
|
}
|
||||||
|
FindClose(hSearch);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,9 +1441,9 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} while (FindNextFile(hSearch, &wfdFileInfo));
|
} while (FindNextFile(hSearch, &wfdFileInfo));
|
||||||
FindClose(hSearch);
|
FindClose(hSearch);
|
||||||
|
}
|
||||||
|
|
||||||
/* Terminate list */
|
/* Terminate list */
|
||||||
ptrNextNode->ptrNext = NULL;
|
ptrNextNode->ptrNext = NULL;
|
||||||
|
@ -1622,7 +1481,9 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */
|
||||||
QsortFiles(ptrFileArray, 0, dwCount-1, lpFlags);
|
QsortFiles(ptrFileArray, 0, dwCount-1, lpFlags);
|
||||||
|
|
||||||
/* Print Data */
|
/* Print Data */
|
||||||
|
pszFilePart[-1] = _T('\0'); /* truncate to directory name only */
|
||||||
DirPrintFiles(ptrFileArray, dwCount, szFullPath, lpFlags);
|
DirPrintFiles(ptrFileArray, dwCount, szFullPath, lpFlags);
|
||||||
|
pszFilePart[-1] = _T('\\');
|
||||||
|
|
||||||
if (lpFlags->bRecursive)
|
if (lpFlags->bRecursive)
|
||||||
{
|
{
|
||||||
|
@ -1660,20 +1521,13 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */
|
||||||
if (lpFlags->bRecursive)
|
if (lpFlags->bRecursive)
|
||||||
{
|
{
|
||||||
/* The new search is involving any *.* file */
|
/* The new search is involving any *.* file */
|
||||||
if (pszFilePart != NULL)
|
|
||||||
{
|
|
||||||
memcpy(szSubPath, szFullPath, (pszFilePart - szFullPath) * sizeof(TCHAR));
|
memcpy(szSubPath, szFullPath, (pszFilePart - szFullPath) * sizeof(TCHAR));
|
||||||
szSubPath[pszFilePart - szFullPath] = _T('\0');
|
_tcscpy(&szSubPath[pszFilePart - szFullPath], _T("*.*"));
|
||||||
}
|
|
||||||
else
|
|
||||||
_tcscpy(szSubPath, szFullPath);
|
|
||||||
|
|
||||||
_tcscat(szSubPath, _T("*.*"));
|
|
||||||
|
|
||||||
hRecSearch = FindFirstFile (szSubPath, &wfdFileInfo);
|
hRecSearch = FindFirstFile (szSubPath, &wfdFileInfo);
|
||||||
do
|
|
||||||
{
|
|
||||||
if (hRecSearch != INVALID_HANDLE_VALUE)
|
if (hRecSearch != INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
do
|
||||||
{
|
{
|
||||||
/* We search for directories other than "." and ".." */
|
/* We search for directories other than "." and ".." */
|
||||||
if ((_tcsicmp(wfdFileInfo.cFileName, _T(".")) != 0) &&
|
if ((_tcsicmp(wfdFileInfo.cFileName, _T(".")) != 0) &&
|
||||||
|
@ -1681,27 +1535,20 @@ DirList(LPTSTR szPath, /* [IN] The path that dir starts */
|
||||||
(wfdFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
(wfdFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
{
|
{
|
||||||
/* Concat the path and the directory to do recursive */
|
/* Concat the path and the directory to do recursive */
|
||||||
if (pszFilePart != NULL)
|
|
||||||
{
|
|
||||||
memcpy(szSubPath, szFullPath, (pszFilePart - szFullPath) * sizeof(TCHAR));
|
memcpy(szSubPath, szFullPath, (pszFilePart - szFullPath) * sizeof(TCHAR));
|
||||||
szSubPath[pszFilePart - szFullPath] = _T('\0');
|
_tcscpy(&szSubPath[pszFilePart - szFullPath], wfdFileInfo.cFileName);
|
||||||
}
|
|
||||||
else
|
|
||||||
_tcscpy(szSubPath, szFullPath);
|
|
||||||
|
|
||||||
_tcscat(szSubPath, wfdFileInfo.cFileName);
|
|
||||||
_tcscat(szSubPath, _T("\\"));
|
_tcscat(szSubPath, _T("\\"));
|
||||||
if (pszFilePart != NULL)
|
|
||||||
_tcscat(szSubPath, pszFilePart);
|
_tcscat(szSubPath, pszFilePart);
|
||||||
|
|
||||||
/* We do the same for the folder */
|
/* We do the same for the folder */
|
||||||
if (DirList(szSubPath, lpFlags) != 0)
|
if (DirList(szSubPath, lpFlags) != 0)
|
||||||
{
|
{
|
||||||
|
FindClose(hRecSearch);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} while(FindNextFile(hRecSearch, &wfdFileInfo));
|
} while(FindNextFile(hRecSearch, &wfdFileInfo));
|
||||||
|
}
|
||||||
FindClose(hRecSearch);
|
FindClose(hRecSearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1776,6 +1623,10 @@ CommandDir(LPTSTR rest)
|
||||||
|
|
||||||
prev_volume[0] = _T('\0');
|
prev_volume[0] = _T('\0');
|
||||||
|
|
||||||
|
/* Reset paging state */
|
||||||
|
if (stFlags.bPause)
|
||||||
|
ConOutPrintfPaging(TRUE, _T(""));
|
||||||
|
|
||||||
for(loop = 0; loop < (UINT)entries; loop++)
|
for(loop = 0; loop < (UINT)entries; loop++)
|
||||||
{
|
{
|
||||||
if (CheckCtrlBreak(BREAK_INPUT))
|
if (CheckCtrlBreak(BREAK_INPUT))
|
||||||
|
|
Loading…
Reference in a new issue