From 5ba08a9238de802b899e08419e98d3ff0ee005fd Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Tue, 30 Jul 2002 14:17:17 +0000 Subject: [PATCH] * fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Incorporate . and .. processing here. (fhandler_cygdrive::readdir): Assume . and .. are already in pdrive. (fhandler_cygdrive::seekdir): Ditto. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/fhandler_disk_file.cc | 28 +++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 67fe78546..8114f834c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2002-07-30 Christopher Faylor + + * fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Incorporate . + and .. processing here. + (fhandler_cygdrive::readdir): Assume . and .. are already in pdrive. + (fhandler_cygdrive::seekdir): Ditto. + 2002-07-29 Christopher Faylor * dcrt0.cc (dll_crt0_1): Move debug_fixup_after_fork_exec. diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 738416fbf..84698efe9 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -730,9 +730,13 @@ void fhandler_cygdrive::set_drives () { const int len = 1 + 26 * DRVSZ; - char *p = (char *) crealloc ((void *) win32_path_name, len); + char *p = (char *) crealloc ((void *) win32_path_name, + sizeof (".") + sizeof ("..") + len); win32_path_name = pdrive = p; + strcpy (p, "."); + strcpy (p + sizeof ("."), ".."); + p += sizeof (".") + sizeof (".."); ndrives = GetLogicalDriveStrings (len, p) / DRVSZ; } @@ -770,28 +774,21 @@ fhandler_cygdrive::readdir (DIR *dir) set_errno (ENMFILE); return NULL; } - if (dir->__d_position == 0) + else if (dir->__d_position > 1 + && GetFileAttributes (pdrive) == INVALID_FILE_ATTRIBUTES) { - *dir->__d_dirent->d_name = '.'; - dir->__d_dirent->d_name[1] = '\0'; - } - else if (dir->__d_position == 1) - { - dir->__d_dirent->d_name[0] = dir->__d_dirent->d_name[1] = '.'; - dir->__d_dirent->d_name[2] = '\0'; - } - else if (GetFileAttributes (pdrive) == INVALID_FILE_ATTRIBUTES) - { - pdrive += DRVSZ; + pdrive = strchr (pdrive, '\0') + 1; return readdir (dir); } + else if (*pdrive == '.') + strcpy (dir->__d_dirent->d_name, pdrive); else { *dir->__d_dirent->d_name = cyg_tolower (*pdrive); dir->__d_dirent->d_name[1] = '\0'; } dir->__d_position++; - pdrive += DRVSZ; + pdrive = strchr (pdrive, '\0') + 1; syscall_printf ("%p = readdir (%p) (%s)", &dir->__d_dirent, dir, dir->__d_dirent->d_name); return dir->__d_dirent; @@ -809,7 +806,8 @@ fhandler_cygdrive::seekdir (DIR *dir, __off64_t loc) if (!iscygdrive_root ()) return fhandler_disk_file::seekdir (dir, loc); - for (pdrive = win32_path_name, dir->__d_position = -1; *pdrive; pdrive += DRVSZ) + for (pdrive = win32_path_name, dir->__d_position = -1; *pdrive; + pdrive = strchr (pdrive, '\0') + 1) if (++dir->__d_position >= loc) break; -- 2.43.5