From 75c6a983c64a5ec0680be94587dd5946e0003363 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 27 Jun 2002 03:06:44 +0000 Subject: * fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Force FindFirstFile on first file of directory when asking for x:\ . --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler_disk_file.cc | 45 ++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 13 deletions(-) (limited to 'winsup') diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 85eb55d45..18dd012aa 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2002-06-26 Christopher Faylor + + * fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Force + FindFirstFile on first file of directory when asking for x:\ . + 2002-06-26 Christopher Faylor * cygheap.cc (cygheap_user::set_name): Correct thinko in below change. diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index c412e2109..db843a41c 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -25,6 +25,7 @@ details. */ #include "shared_info.h" #include "pinfo.h" #include +#include #define _COMPILING_NEWLIB #include @@ -107,21 +108,39 @@ fhandler_disk_file::fstat_by_name (struct __stat64 *buf, path_conv *pc) set_errno (ENOENT); res = -1; } - else if ((handle = FindFirstFile ((char *) pc, &local)) == INVALID_HANDLE_VALUE) - { - debug_printf ("FindFirstFile failed, %E"); - __seterrno (); - res = -1; - } else { - FindClose (handle); - res = fstat_helper (buf, pc, - local.ftCreationTime, - local.ftLastAccessTime, - local.ftLastWriteTime, - local.nFileSizeHigh, - local.nFileSizeLow); + char drivebuf[5]; + char *name; + if ((*pc)[3] != '\0' || !isalpha ((*pc)[0]) || (*pc)[1] != ':' || (*pc)[2] != '\\') + name = *pc; + else + { + /* FIXME: Does this work on empty disks? */ + drivebuf[0] = (*pc)[0]; + drivebuf[1] = (*pc)[1]; + drivebuf[2] = (*pc)[2]; + drivebuf[3] = '*'; + drivebuf[4] = '\0'; + name = drivebuf; + } + + if ((handle = FindFirstFile (name, &local)) == INVALID_HANDLE_VALUE) + { + debug_printf ("FindFirstFile failed for '%s', %E", name); + __seterrno (); + res = -1; + } + else + { + FindClose (handle); + res = fstat_helper (buf, pc, + local.ftCreationTime, + local.ftLastAccessTime, + local.ftLastWriteTime, + local.nFileSizeHigh, + local.nFileSizeLow); + } } return res; } -- cgit v1.2.3