mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* file.c (w32_io_info): should not call GetFileInformationByHandle
for pipe. * file.c (w32_io_info): checks return value from rb_w32_get_osfhandle. * file.c (w32_io_info): now can identify directory on WinNT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
73cd292fcd
commit
29bcbe5c5e
2 changed files with 28 additions and 16 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Wed Nov 23 18:52:45 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||||
|
|
||||||
|
* file.c (w32_io_info): should not call GetFileInformationByHandle
|
||||||
|
for pipe.
|
||||||
|
|
||||||
|
* file.c (w32_io_info): checks return value from rb_w32_get_osfhandle.
|
||||||
|
|
||||||
|
* file.c (w32_io_info): now can identify directory on WinNT.
|
||||||
|
|
||||||
Wed Nov 23 18:46:53 2005 Kouhei Sutou <kou@cozmixng.org>
|
Wed Nov 23 18:46:53 2005 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
* lib/rss/: use #__send__ instead of #send.
|
* lib/rss/: use #__send__ instead of #send.
|
||||||
|
|
35
file.c
35
file.c
|
@ -637,28 +637,36 @@ rb_stat(VALUE file, struct stat *st)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static HANDLE
|
static BOOL
|
||||||
w32_io_info(VALUE *file, BY_HANDLE_FILE_INFORMATION *st)
|
w32_io_info(VALUE *file, BY_HANDLE_FILE_INFORMATION *st)
|
||||||
{
|
{
|
||||||
VALUE tmp;
|
VALUE tmp;
|
||||||
HANDLE f, ret = 0;
|
HANDLE f;
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
tmp = rb_check_convert_type(*file, T_FILE, "IO", "to_io");
|
tmp = rb_check_convert_type(*file, T_FILE, "IO", "to_io");
|
||||||
if (!NIL_P(tmp)) {
|
if (!NIL_P(tmp)) {
|
||||||
OpenFile *fptr;
|
OpenFile *fptr;
|
||||||
|
|
||||||
|
*file = Qnil;
|
||||||
GetOpenFile(tmp, fptr);
|
GetOpenFile(tmp, fptr);
|
||||||
f = (HANDLE)rb_w32_get_osfhandle(fptr->fd);
|
f = (HANDLE)rb_w32_get_osfhandle(fptr->fd);
|
||||||
|
if (f == (HANDLE)-1) return FALSE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FilePathValue(*file);
|
FilePathValue(*file);
|
||||||
f = CreateFile(StringValueCStr(*file), 0, 0, NULL,
|
f = CreateFile(StringValueCStr(*file), 0, 0, NULL, OPEN_EXISTING,
|
||||||
OPEN_EXISTING, 0, NULL);
|
rb_w32_iswin95() ? 0 : FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||||
if (f == INVALID_HANDLE_VALUE) return f;
|
if (f == INVALID_HANDLE_VALUE) return FALSE;
|
||||||
ret = f;
|
|
||||||
}
|
}
|
||||||
if (GetFileInformationByHandle(f, st)) return ret;
|
if (GetFileType(f) == FILE_TYPE_DISK) {
|
||||||
return INVALID_HANDLE_VALUE;
|
ZeroMemory(st, sizeof(*st));
|
||||||
|
ret = GetFileInformationByHandle(f, st);
|
||||||
|
}
|
||||||
|
if (NIL_P(tmp)) {
|
||||||
|
CloseHandle(f);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1408,23 +1416,18 @@ test_identical(VALUE obj, VALUE fname1, VALUE fname2)
|
||||||
#else
|
#else
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
BY_HANDLE_FILE_INFORMATION st1, st2;
|
BY_HANDLE_FILE_INFORMATION st1, st2;
|
||||||
HANDLE f1 = 0, f2 = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rb_secure(2);
|
rb_secure(2);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
f1 = w32_io_info(&fname1, &st1);
|
if (!w32_io_info(&fname1, &st1)) return Qfalse;
|
||||||
if (f1 == INVALID_HANDLE_VALUE) return Qfalse;
|
if (!w32_io_info(&fname2, &st2)) return Qfalse;
|
||||||
f2 = w32_io_info(&fname2, &st2);
|
|
||||||
if (f1) CloseHandle(f1);
|
|
||||||
if (f2 == INVALID_HANDLE_VALUE) return Qfalse;
|
|
||||||
if (f2) CloseHandle(f2);
|
|
||||||
|
|
||||||
if (st1.dwVolumeSerialNumber == st2.dwVolumeSerialNumber &&
|
if (st1.dwVolumeSerialNumber == st2.dwVolumeSerialNumber &&
|
||||||
st1.nFileIndexHigh == st2.nFileIndexHigh &&
|
st1.nFileIndexHigh == st2.nFileIndexHigh &&
|
||||||
st1.nFileIndexLow == st2.nFileIndexLow)
|
st1.nFileIndexLow == st2.nFileIndexLow)
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
if (!f1 || !f2) return Qfalse;
|
if (NIL_P(fname1) || NIL_P(fname2)) return Qfalse;
|
||||||
if (rb_w32_iswin95()) return Qfalse;
|
if (rb_w32_iswin95()) return Qfalse;
|
||||||
#else
|
#else
|
||||||
FilePathValue(fname1);
|
FilePathValue(fname1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue