* 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>
* cygheap.cc (cygheap_user::set_name): Correct thinko in below change.

View File

@ -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;
}