wishdev-rio 0.4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING +341 -0
- data/README +81 -0
- data/Rakefile +281 -0
- data/build_doc.rb +94 -0
- data/doc/ANNOUNCE +159 -0
- data/doc/RELEASE_NOTES +308 -0
- data/doc/RIOIS +215 -0
- data/doc/generators/template/html/rio.css +428 -0
- data/doc/generators/template/html/rio.rb +523 -0
- data/doc/generators/template/html/ugly.rb +132 -0
- data/doc/pkg_def.rb +60 -0
- data/doc/rfc1738.txt +1403 -0
- data/doc/rfc959.txt +3933 -0
- data/ex/catcsv.rb +64 -0
- data/ex/colx.rb +8 -0
- data/ex/findinruby +15 -0
- data/ex/findruby +14 -0
- data/ex/passwd_report.rb +8 -0
- data/ex/prompt.rb +25 -0
- data/ex/rgb.txt.gz +0 -0
- data/ex/riocat +42 -0
- data/ex/riogunzip +31 -0
- data/ex/riogzip +24 -0
- data/ex/rioprompt.rb +10 -0
- data/ex/targz2zip +17 -0
- data/ex/tonl +10 -0
- data/lib/rio/abstract_method.rb +56 -0
- data/lib/rio/argv.rb +56 -0
- data/lib/rio/arycopy.rb +43 -0
- data/lib/rio/assert.rb +114 -0
- data/lib/rio/base.rb +56 -0
- data/lib/rio/callstr.rb +46 -0
- data/lib/rio/const.rb +51 -0
- data/lib/rio/construct.rb +50 -0
- data/lib/rio/constructor.rb +258 -0
- data/lib/rio/context/autoclose.rb +72 -0
- data/lib/rio/context/copying.rb +55 -0
- data/lib/rio/context/cxx.rb +66 -0
- data/lib/rio/context/dir.rb +120 -0
- data/lib/rio/context/gzip.rb +50 -0
- data/lib/rio/context/methods.rb +182 -0
- data/lib/rio/context/skip.rb +66 -0
- data/lib/rio/context/stream.rb +229 -0
- data/lib/rio/context.rb +117 -0
- data/lib/rio/cp.rb +370 -0
- data/lib/rio/def.rb +53 -0
- data/lib/rio/dir.rb +144 -0
- data/lib/rio/doc/EXAMPLES.rb +299 -0
- data/lib/rio/doc/HOWTO.rb +737 -0
- data/lib/rio/doc/INDEX.rb +311 -0
- data/lib/rio/doc/INTRO.rb +1068 -0
- data/lib/rio/doc/OPTIONAL.rb +130 -0
- data/lib/rio/doc/SYNOPSIS.rb +183 -0
- data/lib/rio/doc.rb +45 -0
- data/lib/rio/entrysel.rb +246 -0
- data/lib/rio/exception/copy.rb +97 -0
- data/lib/rio/exception/notimplemented.rb +57 -0
- data/lib/rio/exception/notsupported.rb +46 -0
- data/lib/rio/exception/open.rb +61 -0
- data/lib/rio/exception/state.rb +73 -0
- data/lib/rio/exception.rb +41 -0
- data/lib/rio/ext/csv.rb +351 -0
- data/lib/rio/ext/if.rb +45 -0
- data/lib/rio/ext/mp3info.rb +80 -0
- data/lib/rio/ext/splitlines.rb +253 -0
- data/lib/rio/ext/yaml/doc.rb +133 -0
- data/lib/rio/ext/yaml/tie.rb +149 -0
- data/lib/rio/ext/yaml.rb +164 -0
- data/lib/rio/ext/zipfile/fs.rb +116 -0
- data/lib/rio/ext/zipfile/rl.rb +251 -0
- data/lib/rio/ext/zipfile/rootdir.rb +117 -0
- data/lib/rio/ext/zipfile/state.rb +161 -0
- data/lib/rio/ext/zipfile/wrap.rb +204 -0
- data/lib/rio/ext/zipfile.rb +110 -0
- data/lib/rio/ext.rb +138 -0
- data/lib/rio/factory.rb +436 -0
- data/lib/rio/file.rb +118 -0
- data/lib/rio/filter/closeoneof.rb +103 -0
- data/lib/rio/filter/gzip.rb +70 -0
- data/lib/rio/filter.rb +94 -0
- data/lib/rio/fs/base.rb +41 -0
- data/lib/rio/fs/impl.rb +122 -0
- data/lib/rio/fs/native.rb +75 -0
- data/lib/rio/fs/stream.rb +61 -0
- data/lib/rio/fs/url.rb +63 -0
- data/lib/rio/ftp/conncache.rb +101 -0
- data/lib/rio/ftp/dir.rb +94 -0
- data/lib/rio/ftp/fs.rb +180 -0
- data/lib/rio/ftp/ftpfile.rb +20 -0
- data/lib/rio/grande.rb +97 -0
- data/lib/rio/handle.rb +100 -0
- data/lib/rio/if/basic.rb +64 -0
- data/lib/rio/if/csv.rb +76 -0
- data/lib/rio/if/dir.rb +157 -0
- data/lib/rio/if/file.rb +89 -0
- data/lib/rio/if/fileordir.rb +268 -0
- data/lib/rio/if/grande.rb +729 -0
- data/lib/rio/if/grande_entry.rb +379 -0
- data/lib/rio/if/grande_stream.rb +693 -0
- data/lib/rio/if/internal.rb +125 -0
- data/lib/rio/if/path.rb +462 -0
- data/lib/rio/if/rubyio.rb +681 -0
- data/lib/rio/if/string.rb +83 -0
- data/lib/rio/if/temp.rb +45 -0
- data/lib/rio/if/test.rb +282 -0
- data/lib/rio/if/yaml.rb +206 -0
- data/lib/rio/if.rb +64 -0
- data/lib/rio/ioh.rb +162 -0
- data/lib/rio/iomode.rb +109 -0
- data/lib/rio/ios/fail.rb +106 -0
- data/lib/rio/ios/generic.rb +119 -0
- data/lib/rio/ios/mode.rb +60 -0
- data/lib/rio/ios/null.rb +119 -0
- data/lib/rio/iowrap.rb +128 -0
- data/lib/rio/kernel.rb +54 -0
- data/lib/rio/local.rb +62 -0
- data/lib/rio/match.rb +53 -0
- data/lib/rio/matchrecord.rb +283 -0
- data/lib/rio/no_warn.rb +49 -0
- data/lib/rio/nullio.rb +159 -0
- data/lib/rio/open3.rb +68 -0
- data/lib/rio/ops/construct.rb +61 -0
- data/lib/rio/ops/create.rb +77 -0
- data/lib/rio/ops/dir.rb +346 -0
- data/lib/rio/ops/either.rb +134 -0
- data/lib/rio/ops/file.rb +102 -0
- data/lib/rio/ops/path.rb +296 -0
- data/lib/rio/ops/stream/input.rb +267 -0
- data/lib/rio/ops/stream/output.rb +100 -0
- data/lib/rio/ops/stream/read.rb +86 -0
- data/lib/rio/ops/stream/write.rb +57 -0
- data/lib/rio/ops/stream.rb +87 -0
- data/lib/rio/ops/symlink.rb +80 -0
- data/lib/rio/path/reset.rb +69 -0
- data/lib/rio/path.rb +129 -0
- data/lib/rio/piper/cp.rb +80 -0
- data/lib/rio/piper.rb +122 -0
- data/lib/rio/prompt.rb +66 -0
- data/lib/rio/rectype.rb +88 -0
- data/lib/rio/rl/base.rb +118 -0
- data/lib/rio/rl/builder.rb +117 -0
- data/lib/rio/rl/chmap.rb +66 -0
- data/lib/rio/rl/fs2url.rb +82 -0
- data/lib/rio/rl/ioi.rb +78 -0
- data/lib/rio/rl/path.rb +110 -0
- data/lib/rio/rl/pathmethods.rb +116 -0
- data/lib/rio/rl/uri.rb +200 -0
- data/lib/rio/rl/withpath.rb +296 -0
- data/lib/rio/scheme/aryio.rb +88 -0
- data/lib/rio/scheme/cmdio.rb +80 -0
- data/lib/rio/scheme/cmdpipe.rb +118 -0
- data/lib/rio/scheme/fd.rb +65 -0
- data/lib/rio/scheme/ftp.rb +141 -0
- data/lib/rio/scheme/http.rb +78 -0
- data/lib/rio/scheme/null.rb +55 -0
- data/lib/rio/scheme/path.rb +98 -0
- data/lib/rio/scheme/stderr.rb +55 -0
- data/lib/rio/scheme/stdio.rb +71 -0
- data/lib/rio/scheme/strio.rb +87 -0
- data/lib/rio/scheme/sysio.rb +63 -0
- data/lib/rio/scheme/tcp.rb +75 -0
- data/lib/rio/scheme/temp.rb +200 -0
- data/lib/rio/state/error.rb +72 -0
- data/lib/rio/state.rb +242 -0
- data/lib/rio/stream/base.rb +54 -0
- data/lib/rio/stream/duplex.rb +79 -0
- data/lib/rio/stream/open.rb +202 -0
- data/lib/rio/stream.rb +181 -0
- data/lib/rio/symantics.rb +45 -0
- data/lib/rio/tempdir.rb +132 -0
- data/lib/rio/to_rio/all.rb +39 -0
- data/lib/rio/to_rio/array.rb +39 -0
- data/lib/rio/to_rio/io.rb +40 -0
- data/lib/rio/to_rio/object.rb +42 -0
- data/lib/rio/to_rio/string.rb +40 -0
- data/lib/rio/to_rio.rb +67 -0
- data/lib/rio/uri/file.rb +198 -0
- data/lib/rio/util.rb +48 -0
- data/lib/rio/version.rb +51 -0
- data/lib/rio.rb +162 -0
- data/setup.rb +1360 -0
- data/test/bin/count_lines.rb +11 -0
- data/test/bin/find_lines.rb +13 -0
- data/test/bin/list_dir.rb +14 -0
- data/test/ftp/all.rb +9 -0
- data/test/ftp/anon_copy_data.rb +36 -0
- data/test/ftp/anon_misc.rb +124 -0
- data/test/ftp/anon_read.rb +105 -0
- data/test/ftp/anon_special.rb +68 -0
- data/test/ftp/anon_write.rb +70 -0
- data/test/ftp/ftp2ftp.rb +51 -0
- data/test/ftp/initftpfiles.rb +14 -0
- data/test/ftp/testdef.rb +55 -0
- data/test/gem_runtests.rb +15 -0
- data/test/http/all.rb +4 -0
- data/test/http/copy-from-http.rb +141 -0
- data/test/http/uri-meta.rb +72 -0
- data/test/lib/temp_server.rb +46 -0
- data/test/runalltests.rb +17 -0
- data/test/runftptests.rb +14 -0
- data/test/runhttp.rb +11 -0
- data/test/runhttptests.rb +14 -0
- data/test/runtests.rb +52 -0
- data/test/tc/abs.rb +355 -0
- data/test/tc/all.rb +80 -0
- data/test/tc/base.rb +31 -0
- data/test/tc/base2.rb +87 -0
- data/test/tc/cd1.rb +113 -0
- data/test/tc/clearsel.rb +68 -0
- data/test/tc/clone.rb +208 -0
- data/test/tc/closeoncopy.rb +102 -0
- data/test/tc/closeoneof.rb +194 -0
- data/test/tc/cmdpipe.rb +149 -0
- data/test/tc/copy-dir-samevar.rb +91 -0
- data/test/tc/copy-from.rb +129 -0
- data/test/tc/copy-to.rb +91 -0
- data/test/tc/copy.rb +74 -0
- data/test/tc/copyarray.rb +188 -0
- data/test/tc/copydest.rb +50 -0
- data/test/tc/copydir.rb +166 -0
- data/test/tc/copydirlines.rb +121 -0
- data/test/tc/copylines.rb +46 -0
- data/test/tc/copynonex.rb +118 -0
- data/test/tc/copysymlink.rb +39 -0
- data/test/tc/create.rb +114 -0
- data/test/tc/csv.rb +226 -0
- data/test/tc/csv2.rb +138 -0
- data/test/tc/csv_columns.rb +37 -0
- data/test/tc/csvutil.rb +56 -0
- data/test/tc/dir.rb +76 -0
- data/test/tc/dir_iter.rb +383 -0
- data/test/tc/dirautoclose.rb +67 -0
- data/test/tc/dirent.rb +178 -0
- data/test/tc/dirss.rb +81 -0
- data/test/tc/each.rb +111 -0
- data/test/tc/each_break.rb +243 -0
- data/test/tc/edf.rb +81 -0
- data/test/tc/empty.rb +51 -0
- data/test/tc/emptyriodir.rb +129 -0
- data/test/tc/entary.rb +227 -0
- data/test/tc/entsel.rb +110 -0
- data/test/tc/eq.rb +101 -0
- data/test/tc/expand_path.rb +69 -0
- data/test/tc/ext.rb +136 -0
- data/test/tc/fileno.rb +94 -0
- data/test/tc/files_select.rb +92 -0
- data/test/tc/get.rb +152 -0
- data/test/tc/getrec.rb +137 -0
- data/test/tc/gzip.rb +109 -0
- data/test/tc/io_each_byte.rb +60 -0
- data/test/tc/io_read.rb +80 -0
- data/test/tc/iometh.rb +149 -0
- data/test/tc/likeio.rb +116 -0
- data/test/tc/line_record_row.rb +51 -0
- data/test/tc/lineno.rb +196 -0
- data/test/tc/lines.rb +66 -0
- data/test/tc/misc.rb +432 -0
- data/test/tc/nolines.rb +204 -0
- data/test/tc/noqae.rb +879 -0
- data/test/tc/null.rb +45 -0
- data/test/tc/once.rb +6 -0
- data/test/tc/overload.rb +140 -0
- data/test/tc/pa.rb +158 -0
- data/test/tc/path_parts.rb +175 -0
- data/test/tc/pathop.rb +60 -0
- data/test/tc/paths.rb +145 -0
- data/test/tc/pid.rb +31 -0
- data/test/tc/piper.rb +143 -0
- data/test/tc/programs_util.rb +24 -0
- data/test/tc/qae.rb +493 -0
- data/test/tc/qae_riovar.rb +499 -0
- data/test/tc/readline.rb +30 -0
- data/test/tc/records.rb +68 -0
- data/test/tc/rename.rb +233 -0
- data/test/tc/rename_assign.rb +45 -0
- data/test/tc/riorl.rb +181 -0
- data/test/tc/route.rb +51 -0
- data/test/tc/selnosel.rb +33 -0
- data/test/tc/skip.rb +89 -0
- data/test/tc/skiplines.rb +71 -0
- data/test/tc/split.rb +28 -0
- data/test/tc/splitlines.rb +65 -0
- data/test/tc/splitpath.rb +83 -0
- data/test/tc/sub.rb +46 -0
- data/test/tc/symlink.rb +176 -0
- data/test/tc/symlink0.rb +348 -0
- data/test/tc/symlink1.rb +114 -0
- data/test/tc/synopsis.rb +75 -0
- data/test/tc/temp.rb +152 -0
- data/test/tc/tempdir.rb +60 -0
- data/test/tc/tempfile.rb +66 -0
- data/test/tc/testcase.rb +170 -0
- data/test/tc/tonl.rb +37 -0
- data/test/tc/truncate.rb +39 -0
- data/test/tc/yaml.rb +275 -0
- metadata +387 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# ===============================================================================
|
|
3
|
+
# Copyright (c) 2005,2006,2007 Christopher Kleckner
|
|
4
|
+
# All rights reserved
|
|
5
|
+
#
|
|
6
|
+
# This file is part of the Rio library for ruby.
|
|
7
|
+
#
|
|
8
|
+
# Rio is free software; you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
11
|
+
# (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# Rio is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with Rio; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
# ===============================================================================
|
|
22
|
+
#++
|
|
23
|
+
#
|
|
24
|
+
# To create the documentation for Rio run the command
|
|
25
|
+
# ruby build_doc.rb
|
|
26
|
+
# from the distribution directory.
|
|
27
|
+
#
|
|
28
|
+
# Suggested Reading
|
|
29
|
+
# * RIO::Doc::SYNOPSIS
|
|
30
|
+
# * RIO::Doc::INTRO
|
|
31
|
+
# * RIO::Doc::HOWTO
|
|
32
|
+
# * RIO::Doc::EXAMPLES
|
|
33
|
+
# * RIO::Rio
|
|
34
|
+
#
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
module RIO
|
|
38
|
+
module IF
|
|
39
|
+
module RubyIO
|
|
40
|
+
# Calls IO#gets
|
|
41
|
+
#
|
|
42
|
+
# Reads the next line from the Rio; lines are separated by sep_string.
|
|
43
|
+
# A separator of nil reads the entire contents, and a zero-length separator reads
|
|
44
|
+
# the input a paragraph at a time (two successive newlines in the input separate paragraphs).
|
|
45
|
+
#
|
|
46
|
+
# Returns nil if called at end of file.
|
|
47
|
+
#
|
|
48
|
+
# astring = rio('afile.txt').gets # read the first line of afile.txt into astring
|
|
49
|
+
#
|
|
50
|
+
def gets(sep_string=$/) target.gets(sep_string) end
|
|
51
|
+
|
|
52
|
+
# IF::Grande#each_record
|
|
53
|
+
#
|
|
54
|
+
#
|
|
55
|
+
#def each_record(&block) target.each_record(&block); self end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# IF::Grande#each_row
|
|
59
|
+
#
|
|
60
|
+
#
|
|
61
|
+
#def each_row(&block) target.each_row(&block); self end
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# Calls IO#lineno
|
|
65
|
+
#
|
|
66
|
+
# Returns the current line number of a Rio.
|
|
67
|
+
#
|
|
68
|
+
# The Rio will be opened for reading if not already.
|
|
69
|
+
# lineno counts the number of times gets is called, rather than the number of newlines encountered --
|
|
70
|
+
# so lineno will only be accurate if the file is read exclusively with line-oriented methods
|
|
71
|
+
# (IF::RubyIO#readline, IF::GrandeStream#each_line, IF::RubyIO#gets etc.)
|
|
72
|
+
#
|
|
73
|
+
# See also the $. variable and IF::RubyIO#recno
|
|
74
|
+
# f = rio("testfile")
|
|
75
|
+
# f.lineno #=> 0
|
|
76
|
+
# f.gets #=> "This is line one\n"
|
|
77
|
+
# f.lineno #=> 1
|
|
78
|
+
# f.gets #=> "This is line two\n"
|
|
79
|
+
# f.lineno #=> 2
|
|
80
|
+
def lineno() target.lineno() end
|
|
81
|
+
|
|
82
|
+
# Calls IO#lineno=
|
|
83
|
+
# ario.lineno = integer => integer
|
|
84
|
+
# Manually sets the current line number to the given value. <tt>$.</tt> is
|
|
85
|
+
# updated only on the next read.
|
|
86
|
+
#
|
|
87
|
+
# f = rio("testfile")
|
|
88
|
+
# f.gets #=> "This is line one\n"
|
|
89
|
+
# $. #=> 1
|
|
90
|
+
# f.lineno = 1000
|
|
91
|
+
# f.lineno #=> 1000
|
|
92
|
+
# $. # lineno of last read #=> 1
|
|
93
|
+
# f.gets #=> "This is line two\n"
|
|
94
|
+
# $. # lineno of last read #=> 1001
|
|
95
|
+
#
|
|
96
|
+
#
|
|
97
|
+
def lineno=(integer) target.lineno = integer end
|
|
98
|
+
|
|
99
|
+
# Returns the current record number of a Rio. The +recno+ is the index
|
|
100
|
+
# used by the grande selection methods. It represents the zero-based index of the
|
|
101
|
+
# last record read. Returns nil until a record has been read.
|
|
102
|
+
#
|
|
103
|
+
# see IF::GrandeStream#lines IF::GrandeStream#bytes and IF::GrandeStream#records
|
|
104
|
+
#
|
|
105
|
+
# To illustrate: Given a file containing three lines "L0\n","L1\n","L2\n"
|
|
106
|
+
# and a Range (0..1)
|
|
107
|
+
# Each of the following would fill anarray with ["L0\n", "L1\n"]
|
|
108
|
+
#
|
|
109
|
+
# Given:
|
|
110
|
+
# anarray = []
|
|
111
|
+
# range = (0..1)
|
|
112
|
+
#
|
|
113
|
+
# all_lines = rio('afile').readlines
|
|
114
|
+
# all_lines.each_with_index do |line,i|
|
|
115
|
+
# anarray << line if range === i
|
|
116
|
+
# end
|
|
117
|
+
# # anarray == ["L0\n", "L1\n"]
|
|
118
|
+
#
|
|
119
|
+
# anarray = rio('afile').lines[0..1] # anarray == ["L0\n", "L1\n"]
|
|
120
|
+
#
|
|
121
|
+
# +recno+ counts the number of times IF::GrandeStream#getrec or IF::Grande#each is used to get a record.
|
|
122
|
+
# so +recno+ will only concern parts of the file read with grande methods
|
|
123
|
+
# IF::Grande#each, IF::Grande#[], IF::GrandeStream#getrec
|
|
124
|
+
#
|
|
125
|
+
# See also IF::RubyIO#lineno
|
|
126
|
+
def recno() target.recno() end
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
# Calls IO#binmode
|
|
130
|
+
#
|
|
131
|
+
# Puts rio into binary mode. This is useful only in MS-DOS/Windows environments.
|
|
132
|
+
# Once a stream is in binary mode, it cannot be reset to nonbinary mode.
|
|
133
|
+
#
|
|
134
|
+
# Returns the Rio.
|
|
135
|
+
#
|
|
136
|
+
# rio('afile.exe').binmode.bytes(512).to_a # read a file in 512 byte blocks
|
|
137
|
+
#
|
|
138
|
+
def binmode() target.binmode(); self end
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
# Calls IO#flush
|
|
142
|
+
# ario.flush => ario
|
|
143
|
+
# Flushes any buffered data within _ario_ to the underlying operating
|
|
144
|
+
# system (note that this is Ruby internal buffering only; the OS may
|
|
145
|
+
# buffer the data as well).
|
|
146
|
+
#
|
|
147
|
+
def flush() target.flush(); self end
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
# Calls IO#each_byte
|
|
151
|
+
# ario.each_byte {|byte| block } => ario
|
|
152
|
+
# Calls the given block once for each byte (0..255) in _ario_, passing
|
|
153
|
+
# the byte as an argument.
|
|
154
|
+
#
|
|
155
|
+
def each_byte(*args,&block) target.each_byte(*args,&block); self end
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
# IF::RubyIO#each_bytes
|
|
159
|
+
#
|
|
160
|
+
#
|
|
161
|
+
#def each_bytes(nb,*args,&block) target.each_bytes(nb,*args,&block); self end
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# Calls IO#each_line
|
|
165
|
+
# ario.each_line(sep_string=$/) {|line| block } => ario
|
|
166
|
+
# Executes the block for every line in _ario_, where lines are
|
|
167
|
+
# separated by _sep_string_.
|
|
168
|
+
#
|
|
169
|
+
def each_line(*args,&block) target.each_line(*args,&block); self end
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
# Calls IO#readlines
|
|
173
|
+
#
|
|
174
|
+
# Reads all of the lines in a Rio, and returns them in anArray.
|
|
175
|
+
# Lines are separated by the optional aSepString.
|
|
176
|
+
# The stream must be opened for reading or an IOerror will be raised.
|
|
177
|
+
#
|
|
178
|
+
# an_array = rio('afile.txt').readlines # read afile.txt into an array
|
|
179
|
+
# an_array = rio('afile.txt').chomp.readlines # read afile.txt into an array with each line chomped
|
|
180
|
+
#
|
|
181
|
+
def readlines(*args,&block) target.readlines(*args,&block) end
|
|
182
|
+
|
|
183
|
+
# Calls IO#readline
|
|
184
|
+
# ario.readline(sep_string=$/) => string
|
|
185
|
+
# Reads a line as with +IO#gets+, but raises an +EOFError+ on end of
|
|
186
|
+
# file.
|
|
187
|
+
#
|
|
188
|
+
def readline(*args) target.readline(*args) end
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
# Calls IO#readpartial
|
|
192
|
+
#
|
|
193
|
+
# Reads at most maxlen bytes from the I/O stream but it blocks
|
|
194
|
+
# only if ios has no data immediately available. If the optional
|
|
195
|
+
# outbuf argument is present, it must reference a String, which
|
|
196
|
+
# will receive the data. It raises EOFError on end of file.
|
|
197
|
+
#
|
|
198
|
+
# readpartial is designed for streams such as pipe, socket, tty, etc. It
|
|
199
|
+
# blocks only when no data immediately available. This means that it
|
|
200
|
+
# blocks only when following all conditions hold.
|
|
201
|
+
#
|
|
202
|
+
# * the buffer in the IO object is empty.
|
|
203
|
+
# * the content of the stream is empty.
|
|
204
|
+
# * the stream is not reached to EOF.
|
|
205
|
+
#
|
|
206
|
+
# When readpartial blocks, it waits data or EOF on the stream. If some
|
|
207
|
+
# data is reached, readpartial returns with the data. If EOF is reached,
|
|
208
|
+
# readpartial raises EOFError.
|
|
209
|
+
#
|
|
210
|
+
# When readpartial doesn�t blocks, it returns or raises immediately. If
|
|
211
|
+
# the buffer is not empty, it returns the data in the buffer. Otherwise
|
|
212
|
+
# if the stream has some content, it returns the data in the
|
|
213
|
+
# stream. Otherwise if the stream is reached to EOF, it raises EOFError.
|
|
214
|
+
#
|
|
215
|
+
# r, w = IO.pipe # buffer pipe content
|
|
216
|
+
# w << "abc" # "" "abc".
|
|
217
|
+
# r.readpartial(4096) #=> "abc" "" ""
|
|
218
|
+
# r.readpartial(4096) # blocks because buffer and pipe is empty.
|
|
219
|
+
#
|
|
220
|
+
# r, w = IO.pipe # buffer pipe content
|
|
221
|
+
# w << "abc" # "" "abc"
|
|
222
|
+
# w.close # "" "abc" EOF
|
|
223
|
+
# r.readpartial(4096) #=> "abc" "" EOF
|
|
224
|
+
# r.readpartial(4096) # raises EOFError
|
|
225
|
+
#
|
|
226
|
+
# r, w = IO.pipe # buffer pipe content
|
|
227
|
+
# w << "abc\ndef\n" # "" "abc\ndef\n"
|
|
228
|
+
# r.gets #=> "abc\n" "def\n" ""
|
|
229
|
+
# w << "ghi\n" # "def\n" "ghi\n"
|
|
230
|
+
# r.readpartial(4096) #=> "def\n" "" "ghi\n"
|
|
231
|
+
# r.readpartial(4096) #=> "ghi\n" "" ""
|
|
232
|
+
#
|
|
233
|
+
# Note that readpartial is nonblocking-flag insensitive. It blocks even
|
|
234
|
+
# if the nonblocking-flag is set.
|
|
235
|
+
#
|
|
236
|
+
# Also note that readpartial behaves similar to sysread in blocking
|
|
237
|
+
# mode. The behavior is identical when the buffer is empty.
|
|
238
|
+
# ios.reopen(other_IO) => ios ios.reopen(path, mode_str) => ios
|
|
239
|
+
#
|
|
240
|
+
# Reassociates ios with the I/O stream given in other_IO or to a new
|
|
241
|
+
# stream opened on path. This may dynamically change the actual class of
|
|
242
|
+
# this stream.
|
|
243
|
+
#
|
|
244
|
+
# f1 = File.new("testfile")
|
|
245
|
+
# f2 = File.new("testfile")
|
|
246
|
+
# f2.readlines[0] #=> "This is line one\n"
|
|
247
|
+
# f2.reopen(f1) #=> #<File:testfile>
|
|
248
|
+
# f2.readlines[0] #=> "This is line one\n"
|
|
249
|
+
#
|
|
250
|
+
def readpartial(*args) target.readpartial(*args) end
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
# Calls IO::print
|
|
254
|
+
#
|
|
255
|
+
# Writes the given object(s) to the Rio. If the output record separator ($\) is not nil,
|
|
256
|
+
# it will be appended to the output. If no arguments are given, prints $_.
|
|
257
|
+
# Objects that aren't strings will be converted by calling their to_s method.
|
|
258
|
+
# Returns the Rio.
|
|
259
|
+
#
|
|
260
|
+
# rio('f.txt').print("Hello Rio\n") # print the string to f.txt
|
|
261
|
+
# rio(?-).print("Hello Rio\n") # print the string to stdout
|
|
262
|
+
#
|
|
263
|
+
def print(*args,&block) target.print(*args,&block); self end
|
|
264
|
+
|
|
265
|
+
# Writes the given objects to the rio as with IF::RubyIO#print and then closes the Rio.
|
|
266
|
+
# Returns the Rio.
|
|
267
|
+
#
|
|
268
|
+
# Equivalent to rio.print(*args).close
|
|
269
|
+
#
|
|
270
|
+
# rio('f.txt').print!("Hello Rio\n") # print the string to f.txt then close it
|
|
271
|
+
#
|
|
272
|
+
def print!(*args,&block) target.print!(*args,&block); self end
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
# Writes the given objects to the rio as with IF::RubyIO#printf and then closes the rio.
|
|
276
|
+
# Returns the rio.
|
|
277
|
+
#
|
|
278
|
+
# Equivalent to rio.printf(*args).close
|
|
279
|
+
#
|
|
280
|
+
def printf!(*argv) target.printf!(*argv); self end
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
# Calls IO#printf
|
|
284
|
+
# ario.printf(format_string [, obj, ...] ) => ario
|
|
285
|
+
# Formats and writes to _ario_, converting parameters under control of
|
|
286
|
+
# the format string. See +Kernel#sprintf+ for details.
|
|
287
|
+
#
|
|
288
|
+
def printf(*argv) target.printf(*argv); self end
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
# Writes the given objects to the rio as with IF::RubyIO#putc and then closes the rio.
|
|
292
|
+
# Returns the rio.
|
|
293
|
+
#
|
|
294
|
+
# Equivalent to rio.putc(*args).close
|
|
295
|
+
#
|
|
296
|
+
def putc!(*argv) target.putc!(*argv); self end
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
# Calls IO#putc
|
|
300
|
+
# ario.putc(obj) => ario
|
|
301
|
+
# If _obj_ is +Numeric+, write the character whose code is _obj_,
|
|
302
|
+
# otherwise write the first character of the string representation of
|
|
303
|
+
# _obj_ to _ario_.
|
|
304
|
+
#
|
|
305
|
+
# stdout = rio(?-)
|
|
306
|
+
# stdout.putc "A"
|
|
307
|
+
# stdout.putc 65
|
|
308
|
+
#
|
|
309
|
+
# _produces:_
|
|
310
|
+
#
|
|
311
|
+
# AA
|
|
312
|
+
#
|
|
313
|
+
def putc(*argv) target.putc(*argv); self end
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
# Calls IO#puts
|
|
317
|
+
#
|
|
318
|
+
# Writes the given objects to the rio as with IF::RubyIO#print.
|
|
319
|
+
# Writes a record separator (typically a newline) after any that do not already end with a newline sequence.
|
|
320
|
+
# If called with an array argument, writes each element on a new line.
|
|
321
|
+
# If called without arguments, outputs a single record separator.
|
|
322
|
+
# Returns the rio.
|
|
323
|
+
def puts(*args) target.puts(*args); self end
|
|
324
|
+
|
|
325
|
+
# Writes the given objects to the rio as with IF::RubyIO#puts and then closes the rio.
|
|
326
|
+
# Returns the rio.
|
|
327
|
+
#
|
|
328
|
+
# Equivalent to rio.puts(*args).close
|
|
329
|
+
#
|
|
330
|
+
# rio('f.txt').puts!('Hello Rio') # print the string to f.txt then close it
|
|
331
|
+
#
|
|
332
|
+
def puts!(*args) target.puts!(*args); self end
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
# Writes the given objects to the rio as with IF::RubyIO#write and then closes the rio.
|
|
336
|
+
#
|
|
337
|
+
# Equivalent to
|
|
338
|
+
# ario.write(*args)
|
|
339
|
+
# ario.close
|
|
340
|
+
#
|
|
341
|
+
def write!(*argv) target.write!(*argv) end
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
# Calls IO#write
|
|
345
|
+
# ario.write(string) => integer
|
|
346
|
+
# Writes the given string to _ario_. If the argument is not a string,
|
|
347
|
+
# it will be converted to a
|
|
348
|
+
# string using +to_s+. Returns the number of bytes written.
|
|
349
|
+
#
|
|
350
|
+
def write(*argv) target.write(*argv) end
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
# Calls IO#eof?
|
|
354
|
+
# ario.eof => true or false
|
|
355
|
+
# Returns true if _ario_ is at end of file. The stream must be opened
|
|
356
|
+
# for reading or an +IOError+ will be raised.
|
|
357
|
+
#
|
|
358
|
+
def eof?() target.eof? end
|
|
359
|
+
|
|
360
|
+
# Provides direct access to the IO handle (as would be returned by ::IO#new) *with* filtering.
|
|
361
|
+
# Reading from and writing to this handle will be affected
|
|
362
|
+
# by such things as IF::GrandeStream#gzip and IF::GrandeStream#chomp if they were specified for the Rio.
|
|
363
|
+
#
|
|
364
|
+
# Compare this with IF::RubyIO#ios
|
|
365
|
+
#
|
|
366
|
+
def ioh(*args) target.ioh() end
|
|
367
|
+
|
|
368
|
+
# Provides direct access to the IO handle (as would be returned by ::IO#new)
|
|
369
|
+
# Reading from and writing to this handle
|
|
370
|
+
# is *not* affected by such things as IF::GrandeStream#gzip and IF::GrandeStream#chomp.
|
|
371
|
+
#
|
|
372
|
+
# Compare this with IF::RubyIO#ioh
|
|
373
|
+
#
|
|
374
|
+
def ios(*args) target.ios() end
|
|
375
|
+
|
|
376
|
+
#def open(m,*args) target.open(m,*args); self end
|
|
377
|
+
|
|
378
|
+
# Explicitly set the mode with which a Rio will be opened.
|
|
379
|
+
# ario.mode('r+') => ario
|
|
380
|
+
# Normally one needs never open a Rio or specify its mode -- the mode is determined by the
|
|
381
|
+
# operation the Rio is asked to perform. (i.e. IF::RubyIO#print requires write access, IF::RubyIO#readlines requires
|
|
382
|
+
# read access). However there are times when one wishes to be specific about the mode with which a Rio
|
|
383
|
+
# will be opened. Note that explicitly setting the mode overrides all of Rio's internal mode
|
|
384
|
+
# logic. If a mode is specified via IF::RubyIO#mode or IF::FileOrDir#open that mode will be used. Period.
|
|
385
|
+
#
|
|
386
|
+
# Returns the Rio.
|
|
387
|
+
#
|
|
388
|
+
# See also IF::RubyIO#mode?
|
|
389
|
+
#
|
|
390
|
+
# If the mode is given as a String, it must be one of the values listed in the following table.
|
|
391
|
+
#
|
|
392
|
+
# Mode | Meaning
|
|
393
|
+
# -----+--------------------------------------------------------
|
|
394
|
+
# "r" | Read-only, starts at beginning of file (default mode).
|
|
395
|
+
# -----+--------------------------------------------------------
|
|
396
|
+
# "r+" | Read-write, starts at beginning of file.
|
|
397
|
+
# -----+--------------------------------------------------------
|
|
398
|
+
# "w" | Write-only, truncates existing file
|
|
399
|
+
# | to zero length or creates a new file for writing.
|
|
400
|
+
# -----+--------------------------------------------------------
|
|
401
|
+
# "w+" | Read-write, truncates existing file to zero length
|
|
402
|
+
# | or creates a new file for reading and writing.
|
|
403
|
+
# -----+--------------------------------------------------------
|
|
404
|
+
# "a" | Write-only, starts at end of file if file exists,
|
|
405
|
+
# | otherwise creates a new file for writing.
|
|
406
|
+
# -----+--------------------------------------------------------
|
|
407
|
+
# "a+" | Read-write, starts at end of file if file exists,
|
|
408
|
+
# | otherwise creates a new file for reading and
|
|
409
|
+
# | writing.
|
|
410
|
+
# -----+--------------------------------------------------------
|
|
411
|
+
# "b" | (DOS/Windows only) Binary file mode (may appear with
|
|
412
|
+
# | any of the key letters listed above).
|
|
413
|
+
#
|
|
414
|
+
# ario = rio('afile').mode('r+').nocloseoneof # file will be opened in r+ mode
|
|
415
|
+
# # don't want the file closed at eof
|
|
416
|
+
# ario.seek(apos).gets # read the string at apos in afile
|
|
417
|
+
# ario.rewind.gets # read the string at the beginning of the file
|
|
418
|
+
# ario.close
|
|
419
|
+
#
|
|
420
|
+
# TODO:
|
|
421
|
+
# * Add support for integer modes
|
|
422
|
+
#
|
|
423
|
+
def mode(m,*args) target.mode(m,*args); self end
|
|
424
|
+
|
|
425
|
+
# Query a Rio's mode
|
|
426
|
+
# ario.mode? #=> a mode string
|
|
427
|
+
#
|
|
428
|
+
# See IF::RubyIO#mode
|
|
429
|
+
#
|
|
430
|
+
# ario = rio('afile')
|
|
431
|
+
# ario.puts("Hello World")
|
|
432
|
+
# ario.mode? #=> 'w' IF::RubyIO#puts requires write access
|
|
433
|
+
#
|
|
434
|
+
# ario = rio('afile')
|
|
435
|
+
# ario.gets
|
|
436
|
+
# ario.mode? #=> 'r' IF::RubyIO#gets requires read access
|
|
437
|
+
#
|
|
438
|
+
# ario = rio('afile').mode('w+').nocloseoneof
|
|
439
|
+
# ario.gets
|
|
440
|
+
# ario.mode? #=> 'w+' Set explictly
|
|
441
|
+
#
|
|
442
|
+
def mode?() target.mode?() end
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
# Calls IO#close
|
|
447
|
+
# ario.close => nil
|
|
448
|
+
# Closes _ario_ and flushes any pending writes to the operating
|
|
449
|
+
# system. The stream is unavailable for any further data operations;
|
|
450
|
+
# an +IOError+ is raised if such an attempt is made. I/O streams are
|
|
451
|
+
# automatically closed when they are claimed by the garbage
|
|
452
|
+
# collector.
|
|
453
|
+
#
|
|
454
|
+
def close() target.close(); self end
|
|
455
|
+
def close_write() target.close_write(); self end
|
|
456
|
+
|
|
457
|
+
# Calls IO#fcntl
|
|
458
|
+
# ario.fcntl(integer_cmd, arg) => integer
|
|
459
|
+
# Provides a mechanism for issuing low-level commands to control or
|
|
460
|
+
# query file-oriented I/O streams. Arguments and results are platform
|
|
461
|
+
# dependent. If _arg_ is a number, its value is passed directly. If
|
|
462
|
+
# it is a string, it is interpreted as a binary sequence of bytes
|
|
463
|
+
# (<tt>Array#pack</tt> might be a useful way to build this string). On Unix
|
|
464
|
+
# platforms, see <tt>fcntl(2)</tt> for details. Not implemented on all
|
|
465
|
+
# platforms.
|
|
466
|
+
#
|
|
467
|
+
#
|
|
468
|
+
def fcntl(integer_cmd,arg) target.fcntl(integer_cmd,arg) end
|
|
469
|
+
|
|
470
|
+
# Calls IO#ioctl
|
|
471
|
+
# ario.ioctl(integer_cmd, arg) => integer
|
|
472
|
+
# Provides a mechanism for issuing low-level commands to control or
|
|
473
|
+
# query I/O devices. Arguments and results are platform dependent. If
|
|
474
|
+
# _arg_ is a number, its value is passed directly. If it is a string,
|
|
475
|
+
# it is interpreted as a binary sequence of bytes. On Unix platforms,
|
|
476
|
+
# see +ioctl(2)+ for details. Not implemented on all platforms.
|
|
477
|
+
#
|
|
478
|
+
#
|
|
479
|
+
def ioctl(integer_cmd,arg) target.ioctl(integer_cmd,arg) end
|
|
480
|
+
|
|
481
|
+
# Calls IO#fileno
|
|
482
|
+
# ario.fileno => fixnum
|
|
483
|
+
# ario.to_i => fixnum
|
|
484
|
+
# Returns an integer representing the numeric file descriptor for
|
|
485
|
+
# _ario_.
|
|
486
|
+
#
|
|
487
|
+
def fileno() target.fileno() end
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
# Calls IO#fsync
|
|
491
|
+
# ario.fsync => ario
|
|
492
|
+
# Immediately writes all buffered data in _ario_ to disk and
|
|
493
|
+
# return _ario_.
|
|
494
|
+
# Does nothing if the underlying operating system does not support
|
|
495
|
+
# _fsync(2)_. Note that +fsync+ differs from using IF::RubyIO#sync. The
|
|
496
|
+
# latter ensures that data is flushed from Ruby's buffers, but
|
|
497
|
+
# doesn't not guarantee that the underlying operating system actually
|
|
498
|
+
# writes it to disk.
|
|
499
|
+
#
|
|
500
|
+
def fsync() target.fsync end
|
|
501
|
+
|
|
502
|
+
# Calls IO#pid
|
|
503
|
+
# ario.pid => fixnum
|
|
504
|
+
# Returns the process ID of a child process associated with _ario_.
|
|
505
|
+
# This will be set by <tt>IO::popen</tt>.
|
|
506
|
+
#
|
|
507
|
+
# pipe = IO.popen("-")
|
|
508
|
+
# if pipe
|
|
509
|
+
# $stderr.puts "In parent, child pid is #{pipe.pid}"
|
|
510
|
+
# else
|
|
511
|
+
# $stderr.puts "In child, pid is #{$$}"
|
|
512
|
+
# end
|
|
513
|
+
#
|
|
514
|
+
# produces:
|
|
515
|
+
#
|
|
516
|
+
# In child, pid is 26209
|
|
517
|
+
# In parent, child pid is 26209
|
|
518
|
+
#
|
|
519
|
+
#
|
|
520
|
+
def pid() target.pid end
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
# Calls IO#putc
|
|
524
|
+
# ario.putc(obj) => obj
|
|
525
|
+
# If _obj_ is +Numeric+, write the character whose code is _obj_,
|
|
526
|
+
# otherwise write the first character of the string representation of
|
|
527
|
+
# _obj_ to _ario_.
|
|
528
|
+
#
|
|
529
|
+
# $stdout.putc "A"
|
|
530
|
+
# $stdout.putc 65
|
|
531
|
+
#
|
|
532
|
+
# _produces:_
|
|
533
|
+
#
|
|
534
|
+
# AA
|
|
535
|
+
#
|
|
536
|
+
#
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
# Calls IO#getc
|
|
540
|
+
# ario.getc => fixnum or nil
|
|
541
|
+
# Gets the next 8-bit byte (0..255) from _ario_. Returns +nil+ if
|
|
542
|
+
# called at end of file.
|
|
543
|
+
#
|
|
544
|
+
# f = File.new("testfile")
|
|
545
|
+
# f.getc #=> 84
|
|
546
|
+
# f.getc #=> 104
|
|
547
|
+
#
|
|
548
|
+
#
|
|
549
|
+
def getc() target.getc() end
|
|
550
|
+
|
|
551
|
+
# Calls IO#readchar
|
|
552
|
+
# ario.readchar => fixnum
|
|
553
|
+
# Reads a character as with +IO#getc+, but raises an +EOFError+ on
|
|
554
|
+
# end of file.
|
|
555
|
+
#
|
|
556
|
+
#
|
|
557
|
+
|
|
558
|
+
# Calls IO#reopen
|
|
559
|
+
# ario.reopen(other_IO) => ios
|
|
560
|
+
# ario.reopen(path, mode_str) => ios
|
|
561
|
+
# Reassociates _ario_ with the I/O stream given in _other_IO_ or to a
|
|
562
|
+
# new stream opened on _path_. This may dynamically change the actual
|
|
563
|
+
# class of this stream.
|
|
564
|
+
#
|
|
565
|
+
# f1 = File.new("testfile")
|
|
566
|
+
# f2 = File.new("testfile")
|
|
567
|
+
# f2.readlines[0] #=> "This is line one\n"
|
|
568
|
+
# f2.reopen(f1) #=> #<File:testfile>
|
|
569
|
+
# f2.readlines[0] #=> "This is line one\n"
|
|
570
|
+
#
|
|
571
|
+
#
|
|
572
|
+
#def reopen(m) target.reopen(m) end
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
# Calls IO#stat
|
|
576
|
+
# ario.stat => stat
|
|
577
|
+
# Returns status information for _ario_ as an object of type
|
|
578
|
+
# +File::Stat+.
|
|
579
|
+
#
|
|
580
|
+
# f = File.new("testfile")
|
|
581
|
+
# s = f.stat
|
|
582
|
+
# "%o" % s.mode #=> "100644"
|
|
583
|
+
# s.blksize #=> 4096
|
|
584
|
+
# s.atime #=> Wed Apr 09 08:53:54 CDT 2003
|
|
585
|
+
#
|
|
586
|
+
#
|
|
587
|
+
|
|
588
|
+
# Calls IO#to_i
|
|
589
|
+
# to_i()
|
|
590
|
+
# Alias for #fileno
|
|
591
|
+
#
|
|
592
|
+
#
|
|
593
|
+
def to_i() target.to_i() end
|
|
594
|
+
|
|
595
|
+
# Calls IO#to_io
|
|
596
|
+
# ario.to_io -> ios
|
|
597
|
+
# Returns _ario_.
|
|
598
|
+
#
|
|
599
|
+
#
|
|
600
|
+
def to_io() target.to_io() end
|
|
601
|
+
|
|
602
|
+
# Calls IO#tty?
|
|
603
|
+
# ario.tty? => true or false
|
|
604
|
+
# Returns +true+ if _ario_ is associated with a terminal device (tty),
|
|
605
|
+
# +false+ otherwise.
|
|
606
|
+
#
|
|
607
|
+
# rio("testfile").tty? #=> false
|
|
608
|
+
# rio("/dev/tty").tty? #=> true
|
|
609
|
+
#
|
|
610
|
+
#
|
|
611
|
+
def tty?() target.tty?() end
|
|
612
|
+
|
|
613
|
+
# Calls IO#ungetc
|
|
614
|
+
# ario.ungetc(integer) => ario
|
|
615
|
+
# Pushes back one character (passed as a parameter) onto _ario_, such
|
|
616
|
+
# that a subsequent buffered read will return it. Only one character
|
|
617
|
+
# may be pushed back before a subsequent read operation (that is, you
|
|
618
|
+
# will be able to read only the last of several characters that have
|
|
619
|
+
# been pushed back).
|
|
620
|
+
#
|
|
621
|
+
# f = rio("testfile") #=> #<Rio:testfile>
|
|
622
|
+
# c = f.getc #=> 84
|
|
623
|
+
# f.ungetc(c).getc #=> 84
|
|
624
|
+
#
|
|
625
|
+
def ungetc(*args) target.ungetc(*args); self end
|
|
626
|
+
|
|
627
|
+
# Sets the 'sync-mode' of the underlying IO using IO#sync=
|
|
628
|
+
# ario.sync(boolean=true,&block) => ario
|
|
629
|
+
# Sets the Rio so that its 'sync mode' will be set to +true+ or +false+ when opened, or set
|
|
630
|
+
# it immediately if already open. When sync mode is
|
|
631
|
+
# true, all output is immediately flushed to the underlying operating
|
|
632
|
+
# system and is not buffered internally. Returns the rio. See
|
|
633
|
+
# also IF::RubyIO#fsync, IF::RubyIO#nosync, IF::RubyIO#sync?.
|
|
634
|
+
#
|
|
635
|
+
# If a block is given behaves like <tt>ario.sync(arg).each(&block)</tt>
|
|
636
|
+
#
|
|
637
|
+
# f = rio("testfile").sync.puts("Hello World")
|
|
638
|
+
# f.sync? # => true
|
|
639
|
+
#
|
|
640
|
+
def sync(arg=true,&block) target.sync(arg,&block); self end
|
|
641
|
+
|
|
642
|
+
# Similar to IO#sync= false
|
|
643
|
+
# ario.nosync(&block) => ario
|
|
644
|
+
# Sets the Rio so that its 'sync mode' will be set to +false+ when opened, or set
|
|
645
|
+
# it immediately if already open. When sync mode is
|
|
646
|
+
# true, all output is immediately flushed to the underlying operating
|
|
647
|
+
# system and is not buffered internally. Returns the rio. See
|
|
648
|
+
# also IF::RubyIO#fsync, IF::RubyIO#sync, IF::RubyIO#sync?.
|
|
649
|
+
#
|
|
650
|
+
# If a block is given behaves like <tt>ario.nosync.each(&block)</tt>
|
|
651
|
+
#
|
|
652
|
+
# f = rio("testfile").sync.puts("Hello World")
|
|
653
|
+
# f.sync? # => true
|
|
654
|
+
# f.nosync
|
|
655
|
+
# f.sync? # => false
|
|
656
|
+
#
|
|
657
|
+
def nosync(arg=false,&block) target.nosync(arg,&block); self end
|
|
658
|
+
|
|
659
|
+
# Query the current "sync mode" with IO#sync
|
|
660
|
+
# ario.sync? => true or false
|
|
661
|
+
# Returns the current "sync mode" of _ario_. When sync mode is true,
|
|
662
|
+
# all output is immediately flushed to the underlying operating
|
|
663
|
+
# system and is not buffered by Ruby internally. See also IF::RubyIO#fsync,
|
|
664
|
+
# IF::RubyIO#sync, IF::RubyIO#nosync
|
|
665
|
+
#
|
|
666
|
+
# f = rio("testfile")
|
|
667
|
+
# f.sync? #=> false
|
|
668
|
+
#
|
|
669
|
+
def sync?() target.sync?() end
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
end
|
|
674
|
+
end
|
|
675
|
+
end
|
|
676
|
+
|
|
677
|
+
module RIO
|
|
678
|
+
class Rio
|
|
679
|
+
include RIO::IF::RubyIO
|
|
680
|
+
end
|
|
681
|
+
end
|