Project

General

Profile

Actions

Feature #1081

closed

add File::write() convenience method

Added by sunaku (Suraj Kurapati) almost 16 years ago. Updated about 13 years ago.

Status:
Closed
Target version:
[ruby-core:21701]

Description

=begin
Please add a File::write() convenience method to the core Ruby API.

Currently, it is easier to read whole files than to write them:

reading a whole file --- less effort

text = File::read('foo.txt')

writing a whole file --- more effort

File::open('foo.txt', 'wb') {|f| f.write 'ruby!' }

This imbalance can be corrected by adding a File::write method,
such as the following, to the core Ruby API:

class File
def self.write path, data, mode = 'wb'
open(path, mode) {|f| f.write data }
end
end

Thanks for your consideration.
=end


Files

0001-io.c-io_s_write-io_s_binwrite-Re-add-IO.write-binwri.patch (2.86 KB) 0001-io.c-io_s_write-io_s_binwrite-Re-add-IO.write-binwri.patch runpaint (Run Paint Run Run), 03/07/2010 02:32 AM
new.diff (9.02 KB) new.diff rogerdpack (Roger Pack), 04/29/2010 03:42 AM
latest.diff (7.49 KB) latest.diff rogerdpack (Roger Pack), 04/30/2010 02:32 AM
add_file_write_prelude.diff (4.66 KB) add_file_write_prelude.diff rogerdpack (Roger Pack), 03/19/2011 04:41 AM
latest_also_accomodate_lack_of_mode_param.diff (5.59 KB) latest_also_accomodate_lack_of_mode_param.diff rogerdpack (Roger Pack), 05/18/2011 03:37 AM
sorah_implementation.diff (7.46 KB) sorah_implementation.diff sorah (Sorah Fukumori), 05/30/2011 10:57 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #4846: Permission denied - /tmp/nonexistingClosedznz (Kazuhiro NISHIYAMA)06/07/2011Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0