diff options
author | Christopher Faylor <me@cgf.cx> | 2002-06-27 07:06:44 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-06-27 07:06:44 +0400 |
commit | 75c6a983c64a5ec0680be94587dd5946e0003363 (patch) | |
tree | 3b78570634f56096517347f15c609966b3c96759 /winsup/cygwin/fhandler_disk_file.cc | |
parent | b3e2d035bbf42433f48a966e1f73f9a67082d37e (diff) |
* fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Force
FindFirstFile on first file of directory when asking for x:\ .
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; } |