1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/pathname/pathname.c (path_truncate): Pathname#truncate translated

from pathname.rb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-08-13 13:49:24 +00:00
parent d7d361a316
commit 87da8f0a29
3 changed files with 15 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Fri Aug 13 22:48:39 2010 Tanaka Akira <akr@fsij.org>
* ext/pathname/pathname.c (path_truncate): Pathname#truncate translated
from pathname.rb.
Fri Aug 13 16:11:36 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit.rb (MiniTest::Unit.new): extend before initialize.

View file

@ -512,9 +512,6 @@ end
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

View file

@ -405,6 +405,15 @@ path_make_symlink(VALUE self, VALUE old)
return rb_funcall(rb_cFile, rb_intern("symlink"), 2, old, get_strpath(self));
}
/*
* 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
*
@ -622,4 +631,5 @@ Init_pathname()
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);
}