diff options
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 45 |
1 files changed, 32 insertions, 13 deletions
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 <assert.h> +#include <ctype.h> #define _COMPILING_NEWLIB #include <dirent.h> @@ -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; } |