diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c index 1c4d0567a5..49984a668e 100644 --- a/programs/cmd/directory.c +++ b/programs/cmd/directory.c @@ -28,6 +28,9 @@ #define WIN32_LEAN_AND_MEAN #include "wcmd.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(cmd); int WCMD_dir_sort (const void *a, const void *b); void WCMD_list_directory (char *path, int level); @@ -59,7 +62,7 @@ static int shortname, usernames; static ULONGLONG byte_total; static DISPLAYTIME dirTime; static DISPLAYORDER dirOrder; -static BOOL orderReverse, orderGroupDirs, orderGroupDirsReverse; +static BOOL orderReverse, orderGroupDirs, orderGroupDirsReverse, orderByCol; /***************************************************************************** * WCMD_directory @@ -92,6 +95,7 @@ void WCMD_directory (void) { lower = (strstr(quals, "/L") != NULL); shortname = (strstr(quals, "/X") != NULL); usernames = (strstr(quals, "/Q") != NULL); + orderByCol = (strstr(quals, "/D") != NULL); if ((p = strstr(quals, "/T")) != NULL) { p = p + 2; @@ -136,6 +140,7 @@ void WCMD_directory (void) { if (bare || shortname) wide = FALSE; if (bare) shortname = FALSE; if (wide) usernames = FALSE; + if (orderByCol) wide = TRUE; if (wide) { if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &consoleInfo)) @@ -203,6 +208,8 @@ void WCMD_list_directory (char *search_path, int level) { SYSTEMTIME st; HANDLE hff; int status, dir_count, file_count, entry_count, i, widest, cur_width, tmp_width; + int numCols, numRows; + int rows, cols; ULARGE_INTEGER byte_count, file_size; dir_count = 0; @@ -248,7 +255,7 @@ void WCMD_list_directory (char *search_path, int level) { entry_count++; /* Keep running track of longest filename for wide output */ - if (wide) { + if (wide || orderByCol) { int tmpLen = strlen((fd+(entry_count-1))->cFileName) + 3; if ((fd+(entry_count-1))->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) tmpLen = tmpLen + 2; if (tmpLen > widest) widest = tmpLen; @@ -272,9 +279,31 @@ void WCMD_list_directory (char *search_path, int level) { WCMD_output ("Directory of %s\n\n", real_path); } - for (i=0; i= entry_count) continue; + } else { + i = (rows * numCols) + cols; + if (i >= entry_count) continue; + } + /* /L convers all names to lower case */ if (lower) { char *p = (fd+i)->cFileName; @@ -320,7 +349,6 @@ void WCMD_list_directory (char *search_path, int level) { cur_width = cur_width + widest; if ((cur_width + widest) > max_width) { - WCMD_output ("\n"); cur_width = 0; } else { WCMD_output ("%*.s", (tmp_width - cur_width) ,""); @@ -333,11 +361,11 @@ void WCMD_list_directory (char *search_path, int level) { WCMD_output ("%10s %8s ", datestring, timestring); if (shortname) WCMD_output ("%-13s", (fd+i)->cAlternateFileName); if (usernames) WCMD_output ("%-23s", username); - WCMD_output("%s\n",(fd+i)->cFileName); + WCMD_output("%s",(fd+i)->cFileName); } else { if (!((strcmp((fd+i)->cFileName, ".") == 0) || (strcmp((fd+i)->cFileName, "..") == 0))) { - WCMD_output ("%s%s\n", recurse?real_path:"", (fd+i)->cFileName); + WCMD_output ("%s%s", recurse?real_path:"", (fd+i)->cFileName); } } } @@ -351,15 +379,14 @@ void WCMD_list_directory (char *search_path, int level) { WCMD_filesize64(file_size.QuadPart)); if (shortname) WCMD_output ("%-13s", (fd+i)->cAlternateFileName); if (usernames) WCMD_output ("%-23s", username); - WCMD_output("%s\n",(fd+i)->cFileName); + WCMD_output("%s",(fd+i)->cFileName); } else { - WCMD_output ("%s%s\n", recurse?real_path:"", (fd+i)->cFileName); + WCMD_output ("%s%s", recurse?real_path:"", (fd+i)->cFileName); } } - } - - if (wide && cur_width>0) { - WCMD_output ("\n"); + } + WCMD_output ("\n"); + cur_width = 0; } if (!bare) {