summaryrefslogtreecommitdiff
path: root/ext/pathname/pathname.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-19 01:06:49 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-19 01:06:49 +0000
commit078d19b29f689e4a17e86b134d563978eb7a5fd8 (patch)
tree0062346bbcfaa6fffe28482ee232d25b50279030 /ext/pathname/pathname.c
parentbacb45c8775c94e19cc5c7f84b3abaa9aa3b3311 (diff)
* ext/pathname/pathname.c (path_extname): Pathname#extname translated
from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pathname/pathname.c')
-rw-r--r--ext/pathname/pathname.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index e548ac56f5..834fa446da 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -450,6 +450,16 @@ path_dirname(VALUE self)
}
/*
+ * See <tt>File.extname</tt>. Returns the file's extension.
+ */
+static VALUE
+path_extname(VALUE self)
+{
+ VALUE str = get_strpath(self);
+ return rb_funcall(rb_cFile, rb_intern("extname"), 1, str);
+}
+
+/*
* == Pathname
*
* Pathname represents a pathname which locates a file in a filesystem.
@@ -670,4 +680,5 @@ Init_pathname()
rb_define_method(rb_cPathname, "utime", path_utime, 2);
rb_define_method(rb_cPathname, "basename", path_basename, -1);
rb_define_method(rb_cPathname, "dirname", path_dirname, 0);
+ rb_define_method(rb_cPathname, "extname", path_extname, 0);
}