Feature #3526
closedIO::NULL; null device path name
Description
なかだです。
IO::NULL
を追加するのはどうでしょうか。
diff --git a/io.c b/io.c
index 05b2d45..3793ae5 100644
--- a/io.c
+++ b/io.c
@@ -9623,6 +9623,18 @@ rb_get_argv(void)
return ARGF.argv;
}
+static const char null_device[] =
+#if defined DOSISH
+ "NUL"
+#elif defined AMIGA || defined __amigaos__
+ "NIL"
+#elif defined __VMS
+ "NL:"
+#else
+ "/dev/null"
+#endif
+ ;
+
/*
* Document-class: IOError
*
@@ -9956,6 +9968,8 @@ Init_IO(void)
rb_define_method(rb_cIO, "autoclose?", rb_io_autoclose_p, 0);
rb_define_method(rb_cIO, "autoclose=", rb_io_set_autoclose, 1);
+ rb_define_const(rb_cIO, "NULL", rb_obj_freeze(rb_usascii_str_new2(null_device)));
+
rb_define_variable("$stdin", &rb_stdin);
rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO, "<STDIN>");
rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter);
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦
Updated by runpaint (Run Paint Run Run) over 14 years ago
No objection, FWIW. Looks to mirror Python's os.devnull
. AFAICT, NUL
does not necessarily exist on a Windows system, but that can't be helped. http://bugs.python.org/issue1311 suggests there may be problems stat'ing NUL
on Windows--affecting #exists? and #stat, possibly--but I'm not in a position to verify.
Updated by usa (Usaku NAKAMURA) over 14 years ago
こんにちは、なかむら(う)です。
In message "[ruby-dev:41791] [Feature:trunk] IO::NULL; null device path name"
on Jul.03,2010 11:08:26, nobu@ruby-lang.org wrote:
IO::NULL を追加するのはどうでしょうか。
IOだと、なんとなく、IOオブジェクトが返ってくることを期待してしまう気がします。
で、NULLデバイスが欲しい人にはファイル名が欲しい人もいればIOオブジェクトが欲しい人もいるでしょうから、用意するとしたら前者であろうという点は同意できます。
というわけで、File::NULLでどうでしょうか?
それでは。¶
U.Nakamura usa@garbagecollect.jp
Updated by nobu (Nobuyoshi Nakada) over 14 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r29110.
Nobuyoshi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
- Description updated (diff)