aboutsummaryrefslogtreecommitdiffstats
path: root/ext/pathname/pathname.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-13 13:49:24 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-13 13:49:24 +0000
commit87da8f0a292798126a40dfc3f06a4a8f98aa9073 (patch)
tree81ed5c7d95b740c44f65a6074c3f79b35a480646 /ext/pathname/pathname.c
parentd7d361a316ab554aaa2e773d2dee9644c81b2ff5 (diff)
downloadruby-87da8f0a292798126a40dfc3f06a4a8f98aa9073.tar.gz
* 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
Diffstat (limited to 'ext/pathname/pathname.c')
-rw-r--r--ext/pathname/pathname.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index f98093ff87..a1d260f3ad 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -406,6 +406,15 @@ path_make_symlink(VALUE self, VALUE old)
}
/*
+ * 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 @@ 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);
}