[前][次][番号順一覧][スレッド一覧]

ruby-changes:11063

From: nobu <ko1@a...>
Date: Fri, 27 Feb 2009 17:45:42 +0900 (JST)
Subject: [ruby-changes:11063] Ruby:r22658 (trunk, ruby_1_8): * file.c (file_load_ok): checks if regular file, except for the

nobu	2009-02-27 17:45:26 +0900 (Fri, 27 Feb 2009)

  New Revision: 22658

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22658

  Log:
    * file.c (file_load_ok): checks if regular file, except for the
      platform disallows to open directories, e.g. cygwin.
      [ruby-dev:38097], [Bug #1221]

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/file.c
    trunk/ChangeLog
    trunk/file.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 22657)
+++ ChangeLog	(revision 22658)
@@ -1,6 +1,8 @@
-Fri Feb 27 15:49:41 2009  Nobuyoshi Nakada  <nobu@r...>
+Fri Feb 27 17:45:25 2009  Nobuyoshi Nakada  <nobu@r...>
 
-	* file.c (file_load_ok): checks if regular file.  [ruby-dev:38097]
+	* file.c (file_load_ok): checks if regular file, except for the
+	  platform disallows to open directories, e.g. cygwin.
+	  [ruby-dev:38097], [Bug #1221]
 
 Fri Feb 27 14:39:40 2009  NAKAMURA Usaku  <usa@r...>
 
Index: file.c
===================================================================
--- file.c	(revision 22657)
+++ file.c	(revision 22658)
@@ -4521,13 +4521,19 @@
 static int
 file_load_ok(const char *path)
 {
-    struct stat st;
-    int ret, fd = open(path, O_RDONLY);
+    int ret = 1;
+    int fd = open(path, O_RDONLY);
     if (fd == -1) return 0;
-    ret = fstat(fd, &st);
+#if !(defined DOSISH || defined __CYGWIN__)
+    {
+	struct stat st;
+	if (fstat(fd, &st) || !S_ISREG(st.st_mode)) {
+	    ret = 0;
+	}
+    }
+#endif
     (void)close(fd);
-    if (ret) return 0;
-    return S_ISREG(st.st_mode);
+    return ret;
 }
 
 static int
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 22657)
+++ ruby_1_8/ChangeLog	(revision 22658)
@@ -1,6 +1,8 @@
-Fri Feb 27 15:49:41 2009  Nobuyoshi Nakada  <nobu@r...>
+Fri Feb 27 17:45:25 2009  Nobuyoshi Nakada  <nobu@r...>
 
-	* file.c (file_load_ok): checks if regular file.  [ruby-dev:38097]
+	* file.c (file_load_ok): checks if regular file, except for the
+	  platform disallows to open directories, e.g. cygwin.
+	  [ruby-dev:38097], [Bug #1221]
 
 Thu Feb 26 14:31:27 2009  Shugo Maeda  <shugo@r...>
 
Index: ruby_1_8/file.c
===================================================================
--- ruby_1_8/file.c	(revision 22657)
+++ ruby_1_8/file.c	(revision 22658)
@@ -4359,13 +4359,19 @@
 file_load_ok(file)
     const char *file;
 {
-    struct stat st;
-    int ret, fd = open(file, O_RDONLY);
+    int ret = 1;
+    int fd = open(file, O_RDONLY);
     if (fd == -1) return 0;
-    ret = fstat(fd, &st);
+#if !(defined DOSISH || defined __CYGWIN__)
+    {
+	struct stat st;
+	if (fstat(fd, &st) || !S_ISREG(st.st_mode)) {
+	    ret = 0;
+	}
+    }
+#endif
     (void)close(fd);
-    if (ret) return 0;
-    return S_ISREG(st.st_mode);
+    return ret;
 }
 
 static int

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]