Mercurial > emacs
changeset 23622:0dc79ede9c53
(stat): GetFileInformationByHandle can legitimately fail, so don't
rely on it succeeding.
author | Andrew Innes <andrewi@gnu.org> |
---|---|
date | Tue, 03 Nov 1998 22:39:04 +0000 |
parents | 82325b2dbb5e |
children | f6c3cc94ae4f |
files | src/w32.c |
diffstat | 1 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/src/w32.c Tue Nov 03 22:26:56 1998 +0000 +++ b/src/w32.c Tue Nov 03 22:39:04 1998 +0000 @@ -1960,19 +1960,6 @@ if (GetFileInformationByHandle (fh, &info)) { - switch (GetFileType (fh)) - { - case FILE_TYPE_DISK: - buf->st_mode = _S_IFREG; - break; - case FILE_TYPE_PIPE: - buf->st_mode = _S_IFIFO; - break; - case FILE_TYPE_CHAR: - case FILE_TYPE_UNKNOWN: - default: - buf->st_mode = _S_IFCHR; - } buf->st_nlink = info.nNumberOfLinks; /* Might as well use file index to fake inode values, but this is not guaranteed to be unique unless we keep a handle open @@ -1980,13 +1967,27 @@ not unique). Reputedly, there are at most 48 bits of info (on NTFS, presumably less on FAT). */ fake_inode = info.nFileIndexLow ^ info.nFileIndexHigh; - CloseHandle (fh); } else { - errno = EACCES; - return -1; + buf->st_nlink = 1; + fake_inode = 0; } + + switch (GetFileType (fh)) + { + case FILE_TYPE_DISK: + buf->st_mode = _S_IFREG; + break; + case FILE_TYPE_PIPE: + buf->st_mode = _S_IFIFO; + break; + case FILE_TYPE_CHAR: + case FILE_TYPE_UNKNOWN: + default: + buf->st_mode = _S_IFCHR; + } + CloseHandle (fh); } else {