[PATCH 6/6] CMD.EXE: Partially fix 'dir *.' (ie files with no extension)

Jason Edmeades us at edmeades.me.uk
Thu Apr 5 16:47:58 CDT 2007


Note: This exposes a bug in the findfirst/findnext implementation
when *. is passed as a parameter:

The following test pgm shows this up:
void main() {
    WIN32_FIND_DATA fd;
    HANDLE hff = FindFirstFile ("*.", (&fd));
    char cmd[123];
    do {
        printf("%s\n", fd.cFileName);
    } while (FindNextFile(hff, &(fd)) != 0);
}

It lists limited files on windows, and all files on wine
(filed as bug#7961)
---
 programs/cmd/directory.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c
index 8739a68..e846420 100644
--- a/programs/cmd/directory.c
+++ b/programs/cmd/directory.c
@@ -316,7 +316,6 @@ void WCMD_directory (char *cmd) {
       WINE_TRACE("Using location '%s'\n", fullname);
 
       status = GetFullPathName (fullname, sizeof(path), path, NULL);
-      WINE_TRACE("Using path '%s'\n", path);
 
       /*
        *  If the path supplied does not include a wildcard, and the endpoint of the
@@ -333,8 +332,13 @@ void WCMD_directory (char *cmd) {
             strcat (path, "\\*");
           }
         }
+      } else {
+        /* Special case wildcard search with no extension (ie parameters ending in '.') as
+           GetFullPathName strips off the additional '.'                                  */
+        if (fullname[strlen(fullname)-1] == '.') strcat(path, ".");
       }
-
+      
+      WINE_TRACE("Using path '%s'\n", path);
       thisEntry = (DIRECTORY_STACK *) HeapAlloc(GetProcessHeap(),0,sizeof(DIRECTORY_STACK));
       if (fullParms == NULL) fullParms = thisEntry;
       if (prevEntry != NULL) prevEntry->next = thisEntry;
-- 
1.5.0




More information about the wine-patches mailing list