summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-09 21:27:20 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-09 21:27:20 +0000
commit8aa17733fa55828db19bb00a9943a1f6ee61782b (patch)
treedde02d0c47597def219866d63567d3178899a79c
parentec5bb26fa031288fd8f935443805f68e5637ee75 (diff)
* ext/pathname/pathname.c (path_readlink): Pathname#readlink translated
from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--ext/pathname/lib/pathname.rb3
-rw-r--r--ext/pathname/pathname.c12
3 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index a93a9a08cc..43ad1ac7a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
+Tue Aug 10 06:26:48 2010 Tanaka Akira <akr@fsij.org>
+
+ * ext/pathname/pathname.c (path_readlink): Pathname#readlink translated
+ from pathname.rb.
+
Mon Aug 9 22:15:19 2010 Tanaka Akira <akr@fsij.org>
- * ext/pathname/pathname.c (path_open): Pathname#open
- translated from pathname.rb.
+ * ext/pathname/pathname.c (path_open): Pathname#open translated from
+ pathname.rb.
Mon Aug 9 22:11:09 2010 Tanaka Akira <akr@fsij.org>
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb
index 197c9e6bf4..9ba002b6ca 100644
--- a/ext/pathname/lib/pathname.rb
+++ b/ext/pathname/lib/pathname.rb
@@ -512,9 +512,6 @@ end
class Pathname # * File *
- # See <tt>File.readlink</tt>. Read symbolic link.
- def readlink() self.class.new(File.readlink(@path)) end
-
# See <tt>File.rename</tt>. Rename the file.
def rename(to) File.rename(@path, to) end
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index f7686717d8..5894451272 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -356,6 +356,17 @@ path_open(int argc, VALUE *argv, VALUE self)
}
/*
+ * See <tt>File.readlink</tt>. Read symbolic link.
+ */
+static VALUE
+path_readlink(VALUE self)
+{
+ VALUE str;
+ str = rb_funcall(rb_cFile, rb_intern("readlink"), 1, get_strpath(self));
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
* == Pathname
*
* Pathname represents a pathname which locates a file in a filesystem.
@@ -567,4 +578,5 @@ Init_pathname()
rb_define_method(rb_cPathname, "ftype", path_ftype, 0);
rb_define_method(rb_cPathname, "make_link", path_make_link, 1);
rb_define_method(rb_cPathname, "open", path_open, -1);
+ rb_define_method(rb_cPathname, "readlink", path_readlink, 0);
}