ruby-changes:7301
From: akr <ko1@a...>
Date: Sun, 24 Aug 2008 19:18:45 +0900 (JST)
Subject: [ruby-changes:7301] Ruby:r18820 (trunk): * io.c (rb_io_open): add an argument: vperm.
akr 2008-08-24 19:18:32 +0900 (Sun, 24 Aug 2008) New Revision: 18820 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18820 Log: * io.c (rb_io_open): add an argument: vperm. (open_key_args): call rb_io_open with perm. Modified files: trunk/ChangeLog trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 18819) +++ ChangeLog (revision 18820) @@ -1,3 +1,8 @@ +Sun Aug 24 19:17:31 2008 Tanaka Akira <akr@f...> + + * io.c (rb_io_open): add an argument: vperm. + (open_key_args): call rb_io_open with perm. + Sun Aug 24 19:11:07 2008 Tanaka Akira <akr@f...> * io.c (sym_invalid): removed. Index: io.c =================================================================== --- io.c (revision 18819) +++ io.c (revision 18820) @@ -4860,19 +4860,22 @@ } static VALUE -rb_io_open(VALUE filename, VALUE mode, VALUE opt) +rb_io_open(VALUE filename, VALUE mode, VALUE vperm, VALUE opt) { VALUE cmd; int modenum, flags; convconfig_t convconfig; + mode_t perm; + rb_io_extract_modeenc(&mode, opt, &modenum, &flags, &convconfig); + perm = NIL_P(vperm) ? 0666 : NUM2UINT(vperm); if (!NIL_P(cmd = check_pipe_command(filename))) { return pipe_open_s(cmd, rb_io_modenum_mode(modenum), flags, &convconfig); } else { return rb_file_open_generic(io_alloc(rb_cFile), filename, - modenum, flags, &convconfig, 0666); + modenum, flags, &convconfig, perm); } } @@ -6760,6 +6763,7 @@ open_key_args(int argc, VALUE *argv, struct foreach_arg *arg) { VALUE opt, v; + VALUE mode, perm; FilePathValue(argv[0]); arg->io = 0; @@ -6767,7 +6771,7 @@ arg->argv = argv + 1; if (argc == 1) { no_key: - arg->io = rb_io_open(argv[0], INT2NUM(O_RDONLY), Qnil); + arg->io = rb_io_open(argv[0], INT2NUM(O_RDONLY), INT2FIX(0666), Qnil); return; } opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash"); @@ -6786,10 +6790,15 @@ arg->io = rb_io_open_with_args(RARRAY_LEN(args), RARRAY_PTR(args)); return; } + mode = Qnil; + perm = INT2NUM(O_RDONLY); v = rb_hash_aref(opt, sym_mode); - if (NIL_P(v)) - v = INT2NUM(O_RDONLY); - arg->io = rb_io_open(argv[0], v, opt); + if (!NIL_P(v)) + mode = v; + v = rb_hash_aref(opt, sym_perm); + if (!NIL_P(v)) + perm = v; + arg->io = rb_io_open(argv[0], mode, perm, opt); } static VALUE -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/