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
This commit is contained in:
akr 2018-12-12 05:07:49 +00:00
Родитель 337cabf7df
Коммит 53a5b276b8
1 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -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);
}
/*