ruby-changes:16977
From: akr <ko1@a...>
Date: Fri, 13 Aug 2010 22:49:54 +0900 (JST)
Subject: [ruby-changes:16977] Ruby:r28974 (trunk): * ext/pathname/pathname.c (path_truncate): Pathname#truncate translated
akr 2010-08-13 22:49:24 +0900 (Fri, 13 Aug 2010) New Revision: 28974 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28974 Log: * ext/pathname/pathname.c (path_truncate): Pathname#truncate translated from pathname.rb. Modified files: trunk/ChangeLog trunk/ext/pathname/lib/pathname.rb trunk/ext/pathname/pathname.c Index: ChangeLog =================================================================== --- ChangeLog (revision 28973) +++ ChangeLog (revision 28974) @@ -1,3 +1,8 @@ +Fri Aug 13 22:48:39 2010 Tanaka Akira <akr@f...> + + * ext/pathname/pathname.c (path_truncate): Pathname#truncate translated + from pathname.rb. + Fri Aug 13 16:11:36 2010 Nobuyoshi Nakada <nobu@r...> * lib/test/unit.rb (MiniTest::Unit.new): extend before initialize. Index: ext/pathname/lib/pathname.rb =================================================================== --- ext/pathname/lib/pathname.rb (revision 28973) +++ ext/pathname/lib/pathname.rb (revision 28974) @@ -512,9 +512,6 @@ class Pathname # * File * - # See <tt>File.truncate</tt>. Truncate the file to +length+ bytes. - def truncate(length) File.truncate(@path, length) end - # See <tt>File.utime</tt>. Update the access and modification times. def utime(atime, mtime) File.utime(atime, mtime, @path) end Index: ext/pathname/pathname.c =================================================================== --- ext/pathname/pathname.c (revision 28973) +++ ext/pathname/pathname.c (revision 28974) @@ -406,6 +406,15 @@ } /* + * See <tt>File.truncate</tt>. Truncate the file to +length+ bytes. + */ +static VALUE +path_truncate(VALUE self, VALUE length) +{ + return rb_funcall(rb_cFile, rb_intern("truncate"), 2, get_strpath(self), length); +} + +/* * == Pathname * * Pathname represents a pathname which locates a file in a filesystem. @@ -622,4 +631,5 @@ rb_define_method(rb_cPathname, "stat", path_stat, 0); rb_define_method(rb_cPathname, "lstat", path_lstat, 0); rb_define_method(rb_cPathname, "make_symlink", path_make_symlink, 1); + rb_define_method(rb_cPathname, "truncate", path_truncate, 1); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/