When the path contains a mountpoint on Unix or a junction point to another drive on Windows, cmd.exe should show free space for the path instead of the root of the drive.
From: Akihiro Sagawa sagawa.aki@gmail.com
Found with Coccinelle. --- programs/cmd/builtins.c | 2 +- programs/cmd/directory.c | 8 ++++---- programs/cmd/wcmdmain.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 397eb567277..419e812103a 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -3496,7 +3496,7 @@ void WCMD_setshow_default (const WCHAR *args) { /* Restore old directory if drive letter would change, and CD x:\directory /D (or pushd c:\directory) not supplied */ if ((wcsstr(quals, L"/D") == NULL) && - (param1[1] == ':') && (toupper(param1[0]) != toupper(cwd[0]))) { + (param1[1] == ':') && (towupper(param1[0]) != towupper(cwd[0]))) { SetCurrentDirectoryW(cwd); } } diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c index dfe7e925419..3e2e4528f41 100644 --- a/programs/cmd/directory.c +++ b/programs/cmd/directory.c @@ -330,7 +330,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le /* /L convers all names to lower case */ if (lower) { WCHAR *p = fd[i].cFileName; - while ( (*p = tolower(*p)) ) ++p; + while ( (*p = towlower(*p)) ) ++p; }
/* /Q gets file ownership information */ @@ -559,7 +559,7 @@ void WCMD_directory (WCHAR *args) /* Prefill quals with (uppercased) DIRCMD env var */ if (GetEnvironmentVariableW(L"DIRCMD", string, ARRAY_SIZE(string))) { p = string; - while ( (*p = toupper(*p)) ) ++p; + while ( (*p = towupper(*p)) ) ++p; lstrcatW(string,quals); lstrcpyW(quals, string); } @@ -827,7 +827,7 @@ void WCMD_directory (WCHAR *args)
/* Output disk free (trailer) and volume information (header) if the drive letter changes */ - if (lastDrive != toupper(thisEntry->dirName[0])) { + if (lastDrive != towupper(thisEntry->dirName[0])) {
/* Trailer Information */ if (lastDrive != '?') { @@ -835,7 +835,7 @@ void WCMD_directory (WCHAR *args) WCMD_dir_trailer(prevEntry->dirName[0]); }
- lastDrive = toupper(thisEntry->dirName[0]); + lastDrive = towupper(thisEntry->dirName[0]);
if (!bare) { WCHAR drive[3]; diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 298606f6caa..528e4a83800 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -347,7 +347,7 @@ static void WCMD_show_prompt (BOOL newLine) { } else { p++; - switch (toupper(*p)) { + switch (towupper(*p)) { case '$': *q++ = '$'; break;
From: Akihiro Sagawa sagawa.aki@gmail.com
When the path contains a mountpoint on Unix or a junction point to another drive on Windows, cmd.exe should show free space for the path instead of the root of the drive. --- programs/cmd/directory.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c index 3e2e4528f41..f88baa82bd5 100644 --- a/programs/cmd/directory.c +++ b/programs/cmd/directory.c @@ -506,16 +506,14 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le /***************************************************************************** * WCMD_dir_trailer * - * Print out the trailer for the supplied drive letter + * Print out the trailer for the supplied path */ -static void WCMD_dir_trailer(WCHAR drive) { - ULARGE_INTEGER avail, total, freebytes; - DWORD status; - WCHAR driveName[] = L"c:\"; - - driveName[0] = drive; - status = GetDiskFreeSpaceExW(driveName, &avail, &total, &freebytes); - WINE_TRACE("Writing trailer for '%s' gave %ld(%ld)\n", wine_dbgstr_w(driveName), +static void WCMD_dir_trailer(const WCHAR *path) { + ULARGE_INTEGER freebytes; + BOOL status; + + status = GetDiskFreeSpaceExW(path, NULL, NULL, &freebytes); + WINE_TRACE("Writing trailer for '%s' gave %d(%ld)\n", wine_dbgstr_w(path), status, GetLastError());
if (errorlevel==0 && !bare) { @@ -832,7 +830,7 @@ void WCMD_directory (WCHAR *args) /* Trailer Information */ if (lastDrive != '?') { trailerReqd = FALSE; - WCMD_dir_trailer(prevEntry->dirName[0]); + WCMD_dir_trailer(prevEntry->dirName); }
lastDrive = towupper(thisEntry->dirName[0]); @@ -862,7 +860,7 @@ void WCMD_directory (WCHAR *args)
/* Trailer Information */ if (trailerReqd) { - WCMD_dir_trailer(prevEntry->dirName[0]); + WCMD_dir_trailer(prevEntry->dirName); }
exit: