diff --git a/programs/wcmd/ChangeLog b/programs/wcmd/ChangeLog index ebef49dbef2..86698bf31da 100644 --- a/programs/wcmd/ChangeLog +++ b/programs/wcmd/ChangeLog @@ -1,3 +1,9 @@ +v0.17 - 4 June 2001 +- Simple pipes now work, using temporary files (the DOS way). + +v0.16 - 1 April 2001 +-File, directory and free space sizes are all now computed in 64 bits. + v0.15 - 31 October 2000 -Running console mode programs the interpreter now waits for the program to exit before issuing the next prompt. diff --git a/programs/wcmd/README b/programs/wcmd/README index 995c10ba955..7041c06a0e8 100644 --- a/programs/wcmd/README +++ b/programs/wcmd/README @@ -10,7 +10,6 @@ WHAT'S INCLUDED - A Makefile for Borland C++ (needs editing for directories). WHAT'S MISSING -- Pipes - Command-line qualifiers for most builtin commands - Wildcards and relative paths in COPY, MOVE and RENAME - Set functionality in DATE, TIME, ATTRIB, LABEL @@ -27,8 +26,6 @@ US date-time format is used. Set eg "LANG=en_GB" for DD/MM/YY dates and 24-hour times. - Line editing and command recall doesn't work due to missing functionality in Wine. -- File sizes in the DIR function are all given in 32 bits, though totals and -free space are computed to 64 bits. - DIR/S only works if no file specification is given, ie "DIR C:\TEMP /S" works but "DIR C:\TEMP\*.C" doesn't work if a matching file exists in a lower directory. diff --git a/programs/wcmd/builtins.c b/programs/wcmd/builtins.c index ba5352854f0..153a270ac02 100644 --- a/programs/wcmd/builtins.c +++ b/programs/wcmd/builtins.c @@ -11,7 +11,6 @@ /* * FIXME: * - No support for pipes, shell parameters - * - 32-bit limit on file sizes in DIR command * - Lots of functionality missing from builtins * - Messages etc need international support */ diff --git a/programs/wcmd/directory.c b/programs/wcmd/directory.c index 2799e1da5b3..8416f2212bf 100644 --- a/programs/wcmd/directory.c +++ b/programs/wcmd/directory.c @@ -10,7 +10,6 @@ /* * FIXME: - * - 32-bit limit on individual file sizes (directories and free space are 64-bit) * - DIR /S fails if the starting directory is not the current default. */ @@ -18,8 +17,7 @@ int WCMD_dir_sort (const void *a, const void *b); void WCMD_list_directory (char *path, int level); -char * WCMD_filesize64 (__int64 n); -char * WCMD_filesize32 (int n); +char * WCMD_filesize64 (__int64 free); char * WCMD_strrev (char *buff); @@ -46,8 +44,7 @@ void WCMD_directory () { char path[MAX_PATH], drive[8]; int status; -__int64 free_space; -DWORD spc, bps, fc, capacity; +ULARGE_INTEGER avail, total, free; line_count = 5; page_mode = (strstr(quals, "/P") != NULL); @@ -65,9 +62,8 @@ DWORD spc, bps, fc, capacity; } WCMD_list_directory (path, 0); lstrcpyn (drive, path, 4); - GetDiskFreeSpace (drive, &spc, &bps, &fc, &capacity); - free_space = bps * spc * fc; - WCMD_output (" %18s bytes free\n\n", WCMD_filesize64 (free_space)); + GetDiskFreeSpaceEx (drive, &avail, &total, &free); + WCMD_output (" %18s bytes free\n\n", WCMD_filesize64 (free.QuadPart)); if (recurse) { WCMD_output ("Total files listed:\n%8d files%25s bytes\n%8d directories\n\n", file_total, WCMD_filesize64 (byte_total), dir_total); @@ -80,7 +76,6 @@ DWORD spc, bps, fc, capacity; * List a single file directory. This function (and those below it) can be called * recursively when the /S switch is used. * - * FIXME: Assumes individual files are less than 2**32 bytes. * FIXME: Entries sorted by name only. Should we support DIRCMD?? * FIXME: Assumes 24-line display for the /P qualifier. * FIXME: Other command qualifiers not supported. @@ -98,12 +93,12 @@ FILETIME ft; SYSTEMTIME st; HANDLE hff; int status, dir_count, file_count, entry_count, i; -__int64 byte_count; +ULARGE_INTEGER byte_count, file_size; dir_count = 0; file_count = 0; entry_count = 0; - byte_count = 0; + byte_count.QuadPart = 0; /* * If the path supplied does not include a wildcard, and the endpoint of the @@ -166,10 +161,12 @@ __int64 byte_count; } else { file_count++; - byte_count += (fd+i)->nFileSizeLow; + file_size.LowPart = (fd+i)->nFileSizeLow; + file_size.HighPart = (fd+i)->nFileSizeHigh; + byte_count.QuadPart += file_size.QuadPart; WCMD_output ("%8s %8s %10s %s\n", datestring, timestring, - WCMD_filesize32((fd+i)->nFileSizeLow), (fd+i)->cFileName); + WCMD_filesize64(file_size.QuadPart), (fd+i)->cFileName); } if (page_mode) { if (++line_count > 23) { @@ -180,10 +177,10 @@ __int64 byte_count; } } if (file_count == 1) { - WCMD_output (" 1 file %25s bytes\n", WCMD_filesize64 (byte_count)); + WCMD_output (" 1 file %25s bytes\n", WCMD_filesize64 (byte_count.QuadPart)); } else { - WCMD_output ("%8d files %24s bytes\n", file_count, WCMD_filesize64 (byte_count)); + WCMD_output ("%8d files %24s bytes\n", file_count, WCMD_filesize64 (byte_count.QuadPart)); } if (page_mode) { if (++line_count > 23) { @@ -192,7 +189,7 @@ __int64 byte_count; ReadFile (GetStdHandle(STD_INPUT_HANDLE), string, sizeof(string), &count, NULL); } } - byte_total = byte_total + byte_count; + byte_total = byte_total + byte_count.QuadPart; file_total = file_total + file_count; dir_total = dir_total + dir_count; if (dir_count == 1) WCMD_output ("1 directory "); @@ -251,34 +248,6 @@ static char buff[32]; return buff; } -/***************************************************************************** - * WCMD_filesize32 - * - * Convert a 32-bit number into a character string, with commas every three digits. - * Result is returned in a static string overwritten with each call. - * FIXME: There must be a better algorithm! - */ - -char * WCMD_filesize32 (int n) { - -int r, i; -char *p, *q; -static char buff1[16], buff2[16]; - - wsprintf (buff1, "%i", n); - r = lstrlen (buff1); - WCMD_strrev (buff1); - p = buff1; - q = buff2; - for (i=0; i %s", command, temp_file); + WCMD_process_command (temp_cmd); + command = p; + while ((p = strchr(command, '|'))) { + *p++ = '\0'; + GetTempFileName (temp_path, "WCMD", 0, temp_file2); + wsprintf (temp_cmd, "%s < %s > %s", command, temp_file, temp_file2); + WCMD_process_command (temp_cmd); + DeleteFile (temp_file); + lstrcpy (temp_file, temp_file2); + command = p; + } + wsprintf (temp_cmd, "%s < %s", command, temp_file); + WCMD_process_command (temp_cmd); + DeleteFile (temp_file); +} +