mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/pathname/pathname.c (path_write): New method.
(path_binwrite): Ditto. [ruby-core:49468] [Feature #7378] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
12bf1de1dd
commit
c3d1fde2b5
4 changed files with 71 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Thu Apr 4 20:07:19 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/pathname/pathname.c (path_write): New method.
|
||||||
|
(path_binwrite): Ditto.
|
||||||
|
[ruby-core:49468] [Feature #7378]
|
||||||
|
|
||||||
Thu Apr 4 16:51:29 2013 Yuki Yugui Sonoda <yugui@google.com>
|
Thu Apr 4 16:51:29 2013 Yuki Yugui Sonoda <yugui@google.com>
|
||||||
|
|
||||||
* thread_pthread.c: Fixes wrong scopes of #if USE_SLEEPY_TIMER_THREAD
|
* thread_pthread.c: Fixes wrong scopes of #if USE_SLEEPY_TIMER_THREAD
|
||||||
|
|
5
NEWS
5
NEWS
|
@ -41,6 +41,11 @@ with all sufficient information, see the ChangeLog file.
|
||||||
* Net::SMTP
|
* Net::SMTP
|
||||||
* Added Net::SMTP#rset to implement the RSET command
|
* Added Net::SMTP#rset to implement the RSET command
|
||||||
|
|
||||||
|
* Pathname
|
||||||
|
* New methods:
|
||||||
|
* Pathname#write
|
||||||
|
* Pathname#binwrite
|
||||||
|
|
||||||
* Rinda::RingServer, Rinda::RingFinger
|
* Rinda::RingServer, Rinda::RingFinger
|
||||||
* Rinda now supports multicast sockets. See Rinda::RingServer and
|
* Rinda now supports multicast sockets. See Rinda::RingServer and
|
||||||
Rinda::RingFinger for details.
|
Rinda::RingFinger for details.
|
||||||
|
|
|
@ -344,6 +344,48 @@ path_binread(int argc, VALUE *argv, VALUE self)
|
||||||
return rb_funcall2(rb_cIO, rb_intern("binread"), 1+n, args);
|
return rb_funcall2(rb_cIO, rb_intern("binread"), 1+n, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* call-seq:
|
||||||
|
* pathname.write(string, [offset] ) => fixnum
|
||||||
|
* pathname.write(string, [offset], open_args ) => fixnum
|
||||||
|
*
|
||||||
|
* Writes +contents+ to the file.
|
||||||
|
*
|
||||||
|
* See IO.write.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static VALUE
|
||||||
|
path_write(int argc, VALUE *argv, VALUE self)
|
||||||
|
{
|
||||||
|
VALUE args[4];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
args[0] = get_strpath(self);
|
||||||
|
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
|
||||||
|
return rb_funcall2(rb_cIO, rb_intern("write"), 1+n, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* call-seq:
|
||||||
|
* pathname.binwrite(string, [offset] ) => fixnum
|
||||||
|
* pathname.binwrite(string, [offset], open_args ) => fixnum
|
||||||
|
*
|
||||||
|
* Writes +contents+ to the file, opening it in binary mode.
|
||||||
|
*
|
||||||
|
* See IO.binwrite.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static VALUE
|
||||||
|
path_binwrite(int argc, VALUE *argv, VALUE self)
|
||||||
|
{
|
||||||
|
VALUE args[4];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
args[0] = get_strpath(self);
|
||||||
|
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
|
||||||
|
return rb_funcall2(rb_cIO, rb_intern("binwrite"), 1+n, args);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* pathname.readlines(sep=$/ [, open_args]) -> array
|
* pathname.readlines(sep=$/ [, open_args]) -> array
|
||||||
|
@ -1334,6 +1376,8 @@ Init_pathname()
|
||||||
rb_define_method(rb_cPathname, "read", path_read, -1);
|
rb_define_method(rb_cPathname, "read", path_read, -1);
|
||||||
rb_define_method(rb_cPathname, "binread", path_binread, -1);
|
rb_define_method(rb_cPathname, "binread", path_binread, -1);
|
||||||
rb_define_method(rb_cPathname, "readlines", path_readlines, -1);
|
rb_define_method(rb_cPathname, "readlines", path_readlines, -1);
|
||||||
|
rb_define_method(rb_cPathname, "write", path_write, -1);
|
||||||
|
rb_define_method(rb_cPathname, "binwrite", path_binwrite, -1);
|
||||||
rb_define_method(rb_cPathname, "sysopen", path_sysopen, -1);
|
rb_define_method(rb_cPathname, "sysopen", path_sysopen, -1);
|
||||||
rb_define_method(rb_cPathname, "atime", path_atime, 0);
|
rb_define_method(rb_cPathname, "atime", path_atime, 0);
|
||||||
rb_define_method(rb_cPathname, "ctime", path_ctime, 0);
|
rb_define_method(rb_cPathname, "ctime", path_ctime, 0);
|
||||||
|
|
|
@ -716,6 +716,22 @@ class TestPathname < Test::Unit::TestCase
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_write
|
||||||
|
with_tmpchdir('rubytest-pathname') {|dir|
|
||||||
|
path = Pathname("a")
|
||||||
|
path.write "abc"
|
||||||
|
assert_equal("abc", path.read)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_binwrite
|
||||||
|
with_tmpchdir('rubytest-pathname') {|dir|
|
||||||
|
path = Pathname("a")
|
||||||
|
path.binwrite "abc\x80"
|
||||||
|
assert_equal("abc\x80".b, path.binread)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def test_sysopen
|
def test_sysopen
|
||||||
with_tmpchdir('rubytest-pathname') {|dir|
|
with_tmpchdir('rubytest-pathname') {|dir|
|
||||||
open("a", "w") {|f| f.write "abc" }
|
open("a", "w") {|f| f.write "abc" }
|
||||||
|
|
Loading…
Reference in a new issue