- Fixed the recursive scan and if there is given a path spec.

- Fixed the displaying of empty dir levels on recursive scans.
- Fixed the call to GetProcAddress for using unicode functions.
- Added more parameters for the call to GetDiskFreeSpaceEx.

svn path=/trunk/; revision=7070
This commit is contained in:
Hartmut Birr
2003-12-14 22:51:52 +00:00
parent c0253014fd
commit 08baddcab7
+44 -28
View File
@@ -1,4 +1,4 @@
/* $Id: dir.c,v 1.4 2003/10/18 17:59:29 ekohl Exp $
/* $Id: dir.c,v 1.5 2003/12/14 22:51:52 hbirr Exp $
*
* DIR.C - dir internal command.
*
@@ -444,18 +444,33 @@ DirParsePathspec (LPTSTR szPathspec, LPTSTR szPath, LPTSTR szFilespec)
_tcscpy (szFilespec, tmp+1);
ExtendFilespec (szFilespec);
*tmp = _T('\0');
/* change to this directory and get its full name */
if (!SetCurrentDirectory (start))
if (tmp == start)
{
*tmp = _T('\\');
szFilespec[0] = _T('\0');
SetCurrentDirectory (szOrigPath);
error_path_not_found ();
return 1;
/* change to the root directory */
if (!SetCurrentDirectory (_T("\\")))
{
szFilespec[0] = _T('\0');
SetCurrentDirectory (szOrigPath);
error_path_not_found ();
return 1;
}
}
else
{
*tmp = _T('\0');
/* change to this directory */
if (!SetCurrentDirectory (start))
{
*tmp = _T('\\');
szFilespec[0] = _T('\0');
SetCurrentDirectory (szOrigPath);
error_path_not_found ();
return 1;
}
}
/* get the full name of the directory */
if (!GetCurrentDirectory (MAX_PATH, szPath))
{
*tmp = _T('\\');
@@ -701,6 +716,7 @@ GetUserDiskFreeSpace(LPCTSTR lpRoot,
DWORD dwBytPerSec;
DWORD dwFreeCl;
DWORD dwTotCl;
ULARGE_INTEGER TotalNumberOfBytes, TotalNumberOfFreeBytes;
lpFreeSpace->QuadPart = 0;
@@ -709,13 +725,13 @@ GetUserDiskFreeSpace(LPCTSTR lpRoot,
{
pGetFreeDiskSpaceEx = (PGETFREEDISKSPACEEX)GetProcAddress(hInstance,
#ifdef _UNICODE
_T("GetDiskFreeSpaceExW"));
"GetDiskFreeSpaceExW");
#else
_T("GetDiskFreeSpaceExA"));
"GetDiskFreeSpaceExA");
#endif
if (pGetFreeDiskSpaceEx != NULL)
{
if (pGetFreeDiskSpaceEx(lpRoot, lpFreeSpace, NULL, NULL) == TRUE)
if (pGetFreeDiskSpaceEx(lpRoot, lpFreeSpace, &TotalNumberOfBytes, &TotalNumberOfFreeBytes) == TRUE)
return;
}
FreeLibrary(hInstance);
@@ -775,10 +791,21 @@ PrintSummary(LPTSTR szPath,
GetUserDiskFreeSpace(szRoot, &uliFree);
ConvertULargeInteger (uliFree, buffer, sizeof(buffer));
ConOutPrintf (_T(" %15s bytes free\n"), buffer);
if (IncLine (pLine, dwFlags))
return 1;
}
else
{
if ((dwFlags & DIR_BARE) == 0)
{
ConOutPrintf (_T("\n"));
if (IncLine (pLine, dwFlags))
return 1;
ConOutPrintf (_T("\n"));
}
if (IncLine (pLine, dwFlags))
return 1;
}
if (IncLine (pLine, dwFlags))
return 1;
return 0;
}
@@ -1068,7 +1095,7 @@ DirRead (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
_tcscpy (szFullPath, szPath);
if (szFullPath[_tcslen (szFullPath) - 1] != _T('\\'))
_tcscat (szFullPath, _T("\\"));
_tcscat (szFullPath, szFilespec);
_tcscat (szFullPath, _T("*"));
hFile = FindFirstFile (szFullPath, &file);
if (hFile == INVALID_HANDLE_VALUE)
@@ -1093,17 +1120,6 @@ DirRead (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
FindClose (hFile);
return 1;
}
if ((dwFlags & DIR_BARE) == 0)
{
ConOutPrintf (_T("\n"));
if (IncLine (pLine, dwFlags) != 0)
return 1;
ConOutPrintf (_T("\n"));
if (IncLine (pLine, dwFlags) != 0)
return 1;
}
if (DirRead (szFullPath, szFilespec, pLine, dwFlags) == 1)
{
FindClose (hFile);