summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-23 09:56:23 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-11-23 09:56:23 +0000
commitce4cda9de58a01dd1202222a5349064641f311f3 (patch)
tree6df3167317e0bf8aea43f96109969a6b3446d882
parent8847a49f21f9b2d19f6d3b579fcd1649e9ebd533 (diff)
* 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/branches/ruby_1_8@9600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--file.c35
2 files changed, 28 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index edd30289139..e78345a03f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed Nov 23 18:55:31 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 03:40:49 2005 Guy Decoux <ts@moulon.inra.fr>
* re.c (KR_REHASH): should cast to unsigned for 64bit CPU.
@@ -79,7 +88,6 @@ Sun Nov 20 22:34:06 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (rb_symname_p): [ not followed by ] is not valid symbol.
fixed: [ruby-talk:166520]
->>>>>>> 1.2673.2.1407
Sat Nov 19 19:57:54 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/fileutils.rb (FileUtils::ln): ln documentation fix.
diff --git a/file.c b/file.c
index ef73ffba25f..8aa42641618 100644
--- a/file.c
+++ b/file.c
@@ -663,30 +663,38 @@ rb_stat(file, st)
}
#ifdef _WIN32
-static HANDLE
+static BOOL
w32_io_info(file, st)
VALUE *file;
BY_HANDLE_FILE_INFORMATION *st;
{
VALUE tmp;
- HANDLE f, ret = 0;
+ HANDLE f;
+ BOOL ret = FALSE;
tmp = rb_check_convert_type(*file, T_FILE, "IO", "to_io");
if (!NIL_P(tmp)) {
OpenFile *fptr;
+ *file = Qnil;
GetOpenFile(tmp, fptr);
f = (HANDLE)rb_w32_get_osfhandle(fileno(fptr->f));
+ if (f == (HANDLE)-1) return FALSE;
}
else {
SafeStringValue(*file);
- f = CreateFile(StringValueCStr(*file), 0, 0, NULL,
- OPEN_EXISTING, 0, NULL);
- if (f == INVALID_HANDLE_VALUE) return f;
- ret = f;
+ f = CreateFile(StringValueCStr(*file), 0, 0, NULL, OPEN_EXISTING,
+ rb_w32_iswin95() ? 0 : FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (f == INVALID_HANDLE_VALUE) return FALSE;
}
- if (GetFileInformationByHandle(f, st)) return ret;
- return INVALID_HANDLE_VALUE;
+ if (GetFileType(f) == FILE_TYPE_DISK) {
+ ZeroMemory(st, sizeof(*st));
+ ret = GetFileInformationByHandle(f, st);
+ }
+ if (NIL_P(tmp)) {
+ CloseHandle(f);
+ }
+ return ret;
}
#endif
@@ -1408,23 +1416,18 @@ test_identical(obj, fname1, fname2)
#else
#ifdef _WIN32
BY_HANDLE_FILE_INFORMATION st1, st2;
- HANDLE f1 = 0, f2 = 0;
#endif
rb_secure(2);
#ifdef _WIN32
- f1 = w32_io_info(&fname1, &st1);
- if (f1 == INVALID_HANDLE_VALUE) return Qfalse;
- f2 = w32_io_info(&fname2, &st2);
- if (f1) CloseHandle(f1);
- if (f2 == INVALID_HANDLE_VALUE) return Qfalse;
- if (f2) CloseHandle(f2);
+ if (!w32_io_info(&fname1, &st1)) return Qfalse;
+ if (!w32_io_info(&fname2, &st2)) return Qfalse;
if (st1.dwVolumeSerialNumber == st2.dwVolumeSerialNumber &&
st1.nFileIndexHigh == st2.nFileIndexHigh &&
st1.nFileIndexLow == st2.nFileIndexLow)
return Qtrue;
- if (!f1 || !f2) return Qfalse;
+ if (NIL_P(fname1) || NIL_P(fname2)) return Qfalse;
if (rb_w32_iswin95()) return Qfalse;
#else
SafeStringValue(fname1);