* fhandler_disk_file.cc (fhandler_disk_file::fstat_by_name): Force

FindFirstFile on first file of directory when asking for x:\ .
This commit is contained in:
Christopher Faylor 2002-06-27 03:06:44 +00:00
parent b3e2d035bb
commit 75c6a983c6
2 changed files with 37 additions and 13 deletions

View File

@ -1,3 +1,8 @@
2002-06-26 Christopher Faylor <cgf@redhat.com>
* 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 <cgf@redhat.com> 2002-06-26 Christopher Faylor <cgf@redhat.com>
* cygheap.cc (cygheap_user::set_name): Correct thinko in below change. * cygheap.cc (cygheap_user::set_name): Correct thinko in below change.

View File

@ -25,6 +25,7 @@ details. */
#include "shared_info.h" #include "shared_info.h"
#include "pinfo.h" #include "pinfo.h"
#include <assert.h> #include <assert.h>
#include <ctype.h>
#define _COMPILING_NEWLIB #define _COMPILING_NEWLIB
#include <dirent.h> #include <dirent.h>
@ -107,21 +108,39 @@ fhandler_disk_file::fstat_by_name (struct __stat64 *buf, path_conv *pc)
set_errno (ENOENT); set_errno (ENOENT);
res = -1; res = -1;
} }
else if ((handle = FindFirstFile ((char *) pc, &local)) == INVALID_HANDLE_VALUE)
{
debug_printf ("FindFirstFile failed, %E");
__seterrno ();
res = -1;
}
else else
{ {
FindClose (handle); char drivebuf[5];
res = fstat_helper (buf, pc, char *name;
local.ftCreationTime, if ((*pc)[3] != '\0' || !isalpha ((*pc)[0]) || (*pc)[1] != ':' || (*pc)[2] != '\\')
local.ftLastAccessTime, name = *pc;
local.ftLastWriteTime, else
local.nFileSizeHigh, {
local.nFileSizeLow); /* 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; return res;
} }