summaryrefslogtreecommitdiff
path: root/ext/pathname
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-12 05:07:49 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-12 05:07:49 +0000
commit53a5b276b8bc6e22a9fecc23dd99259e2d0e7fa4 (patch)
treeafce6bb2f60d41b2b0957b4a3eecfb16b30c316a /ext/pathname
parent337cabf7dfd73bf917744fad7c09212564dc3f2f (diff)
Use File class methods to avoid pipe execution
Following methods use corresponding File class methods instead of IO class methods. - Pathname#each_line - Pathname#read - Pathname#binread - Pathname#write - Pathname#binwrite - Pathname#readlines Reported by ooooooo_q. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pathname')
-rw-r--r--ext/pathname/pathname.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 2d74e9cf80..d5e58c52d8 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -368,10 +368,10 @@ path_each_line(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
if (rb_block_given_p()) {
- return rb_block_call(rb_cIO, id_foreach, 1+n, args, 0, 0);
+ return rb_block_call(rb_cFile, id_foreach, 1+n, args, 0, 0);
}
else {
- return rb_funcallv(rb_cIO, id_foreach, 1+n, args);
+ return rb_funcallv(rb_cFile, id_foreach, 1+n, args);
}
}
@@ -382,7 +382,7 @@ path_each_line(int argc, VALUE *argv, VALUE self)
*
* Returns all data from the file, or the first +N+ bytes if specified.
*
- * See IO.read.
+ * See File.read.
*
*/
static VALUE
@@ -393,7 +393,7 @@ path_read(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv(rb_cIO, id_read, 1+n, args);
+ return rb_funcallv(rb_cFile, id_read, 1+n, args);
}
/*
@@ -402,7 +402,7 @@ path_read(int argc, VALUE *argv, VALUE self)
*
* Returns all the bytes from the file, or the first +N+ if specified.
*
- * See IO.binread.
+ * See File.binread.
*
*/
static VALUE
@@ -413,7 +413,7 @@ path_binread(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "02", &args[1], &args[2]);
- return rb_funcallv(rb_cIO, id_binread, 1+n, args);
+ return rb_funcallv(rb_cFile, id_binread, 1+n, args);
}
/*
@@ -423,7 +423,7 @@ path_binread(int argc, VALUE *argv, VALUE self)
*
* Writes +contents+ to the file.
*
- * See IO.write.
+ * See File.write.
*
*/
static VALUE
@@ -434,7 +434,7 @@ path_write(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv(rb_cIO, id_write, 1+n, args);
+ return rb_funcallv(rb_cFile, id_write, 1+n, args);
}
/*
@@ -444,7 +444,7 @@ path_write(int argc, VALUE *argv, VALUE self)
*
* Writes +contents+ to the file, opening it in binary mode.
*
- * See IO.binwrite.
+ * See File.binwrite.
*
*/
static VALUE
@@ -455,7 +455,7 @@ path_binwrite(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv(rb_cIO, id_binwrite, 1+n, args);
+ return rb_funcallv(rb_cFile, id_binwrite, 1+n, args);
}
/*
@@ -466,7 +466,7 @@ path_binwrite(int argc, VALUE *argv, VALUE self)
*
* Returns all the lines from the file.
*
- * See IO.readlines.
+ * See File.readlines.
*
*/
static VALUE
@@ -477,7 +477,7 @@ path_readlines(int argc, VALUE *argv, VALUE self)
args[0] = get_strpath(self);
n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
- return rb_funcallv(rb_cIO, id_readlines, 1+n, args);
+ return rb_funcallv(rb_cFile, id_readlines, 1+n, args);
}
/*