ÿØÿà JFIF ÿÛ „ ( %!1!%)+//.383,7(-.+
-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ ¥2" ÿÄ ÿÄ J ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ ÿÄ * !1AQa‘"2q3±ð#b¡ÿÚ ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁTÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßwpŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
?>
.........................................
.............................................................................
ÿØÿà JFIF ÿÛ „
(
%!1!%)+//.383,7(-.+
-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ ¥2" ÿÄ
ÿÄ J ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ
ÿÄ * !1AQa‘"2q3±ð#b¡ÿÚ
? ¼QxJQaÍuò¸Zö
Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁTÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßwpŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
?>
.........................................
.............................................................................
????????????????????????????????????
????????????????????????????????????
ÿØÿà JFIF ÿÛ „ ( %!1!%)+//.383,7(-.+
-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ ¥2" ÿÄ ÿÄ J ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ ÿÄ * !1AQa‘"2q3±ð#b¡ÿÚ ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁTÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßwpŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
?>
.........................................
.............................................................................
ÿØÿà JFIF ÿÛ „
(
%!1!%)+//.383,7(-.+
-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ ¥2" ÿÄ
ÿÄ J ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ
ÿÄ * !1AQa‘"2q3±ð#b¡ÿÚ
? ¼QxJQaÍuò¸Zö
Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁTÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßwpŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
?>
.........................................
.............................................................................
????????????????????????????????????
????????????????????????????????????
U:RDoc::NormalClass[iI" File:ET@I"IO;To:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[I"MA \File object is a representation of a file in the underlying platform.;To:RDoc::Markup::BlankLine o; ;[I"M\Class \File extends module FileTest, supporting such singleton methods ;TI"as File.exist?.;T@S:RDoc::Markup::Heading:
leveli: textI"About the Examples;T@o; ;[I",Many examples here use these variables:;T@o:RDoc::Markup::Verbatim;[I"## English text with newlines.
;TI"text = <<~EOT
;TI" First line
;TI" Second line
;TI"
;TI" Fourth line
;TI" Fifth line
;TI" EOT
;TI"
;TI"# Russian text.
;TI"5russian = "\u{442 435 441 442}" # => "тест"
;TI"
;TI"# Binary data.
;TI"-data = "\u9990\u9991\u9992\u9993\u9994"
;TI"
;TI"# Text file.
;TI"File.write('t.txt', text)
;TI"
;TI"# File with Russian text.
;TI""File.write('t.rus', russian)
;TI"
;TI"# File with binary data.
;TI"(f = File.new('t.dat', 'wb:UTF-16')
;TI"f.write(data)
;TI"
f.close
;T:@format0S;;i;
I"Access Modes;T@o; ;[I"UMethods File.new and File.open each create a \File object for a given file path.;T@S;;i;
I"\String Access Modes;T@o; ;[I"PMethods File.new and File.open each may take string argument +mode+, which:;T@o:RDoc::Markup::List:
@type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"%Begins with a 1- or 2-character ;TI"8{read/write mode}[rdoc-ref:File@Read-2FWrite+Mode].;To;;0;[o; ;[I"IMay also contain a 1-character {data mode}[rdoc-ref:File@Data+Mode].;To;;0;[o; ;[I"$May also contain a 1-character ;TI"8{file-create mode}[rdoc-ref:File@File-Create+Mode].;T@S;;i ;
I"Read/Write Mode;T@o; ;[I"&The read/write +mode+ determines:;T@o;;;;[o;;0;[o; ;[I"3Whether the file is to be initially truncated.;T@o;;0;[o; ;[I"+Whether reading is allowed, and if so:;T@o;;;;[o;;0;[o; ;[I"+The initial read position in the file.;To;;0;[o; ;[I")Where in the file reading can occur.;T@o;;0;[o; ;[I"+Whether writing is allowed, and if so:;T@o;;;;[o;;0;[o; ;[I",The initial write position in the file.;To;;0;[o; ;[I")Where in the file writing can occur.;T@o; ;[I"These tables summarize:;T@o;;[I"(Read/Write Modes for Existing File
;TI"
;TI"G|------|-----------|----------|----------|----------|-----------|
;TI"G| R/W | Initial | | Initial | | Initial |
;TI"G| Mode | Truncate? | Read | Read Pos | Write | Write Pos |
;TI"G|------|-----------|----------|----------|----------|-----------|
;TI"G| 'r' | No | Anywhere | 0 | Error | - |
;TI"G| 'w' | Yes | Error | - | Anywhere | 0 |
;TI"G| 'a' | No | Error | - | End only | End |
;TI"G| 'r+' | No | Anywhere | 0 | Anywhere | 0 |
;TI"G| 'w+' | Yes | Anywhere | 0 | Anywhere | 0 |
;TI"G| 'a+' | No | Anywhere | End | End only | End |
;TI"G|------|-----------|----------|----------|----------|-----------|
;TI"
;TI".Read/Write Modes for \File To Be Created
;TI"
;TI";|------|----------|----------|----------|-----------|
;TI";| R/W | | Initial | | Initial |
;TI";| Mode | Read | Read Pos | Write | Write Pos |
;TI";|------|----------|----------|----------|-----------|
;TI";| 'w' | Error | - | Anywhere | 0 |
;TI";| 'a' | Error | - | End only | 0 |
;TI";| 'w+' | Anywhere | 0 | Anywhere | 0 |
;TI";| 'a+' | Anywhere | 0 | End only | End |
;TI";|------|----------|----------|----------|-----------|
;T;0o; ;[I"DNote that modes 'r' and 'r+' are not allowed ;TI"0for a non-existent file (exception raised).;T@o; ;[I"In the tables:;T@o;;;;[o;;0;[o; ;[I"C+Anywhere+ means that methods IO#rewind, IO#pos=, and IO#seek ;TI"0may be used to change the file's position, ;TI"Gso that allowed reading or writing may occur anywhere in the file.;To;;0;[o; ;[I"IEnd only means that writing can occur only at end-of-file, ;TI"Land that methods IO#rewind, IO#pos=, and IO#seek do not affect writing.;To;;0;[o; ;[I"P+Error+ means that an exception is raised if disallowed reading or writing ;TI"is attempted.;T@S;;i
;
I"(Read/Write Modes for Existing \File;T@o;;;;[
o;;0;[o; ;[I"'r':;T@o;;;;[ o;;0;[o; ;[I"&\File is not initially truncated:;T@o;;[I".f = File.new('t.txt') # => #
;TI"&f.size == 0 # => false
;T;0o;;0;[o; ;[I"'File's initial read position is 0:;T@o;;[I"f.pos # => 0
;T;0o;;0;[o; ;[I"A\File may be read anywhere; see IO#rewind, IO#pos=, IO#seek:;T@o;;[I"$f.readline # => "First line\n"
;TI"%f.readline # => "Second line\n"
;TI"
;TI"f.rewind
;TI"$f.readline # => "First line\n"
;TI"
;TI"f.pos = 1
;TI"#f.readline # => "irst line\n"
;TI"
;TI"f.seek(1, :CUR)
;TI"$f.readline # => "econd line\n"
;T;0o;;0;[o; ;[I"Writing is not allowed:;T@o;;[I"&f.write('foo') # Raises IOError.
;T;0o;;0;[o; ;[I"'w':;T@o;;;;[ o;;0;[o; ;[I""\File is initially truncated:;T@o;;[ I"path = 't.tmp'
;TI"File.write(path, text)
;TI"f = File.new(path, 'w')
;TI"f.size == 0 # => true
;T;0o;;0;[o; ;[I"(File's initial write position is 0:;T@o;;[I"f.pos # => 0
;T;0o;;0;[o; ;[I"<\File may be written anywhere (even past end-of-file); ;TI"%see IO#rewind, IO#pos=, IO#seek:;T@o;;[&I"f.write('foo')
;TI"
f.flush
;TI" File.read(path) # => "foo"
;TI"f.pos # => 3
;TI"
;TI"f.write('bar')
;TI"
f.flush
;TI"#File.read(path) # => "foobar"
;TI"f.pos # => 6
;TI"
;TI"f.rewind
;TI"f.write('baz')
;TI"
f.flush
;TI"#File.read(path) # => "bazbar"
;TI"f.pos # => 3
;TI"
;TI"f.pos = 3
;TI"f.write('foo')
;TI"
f.flush
;TI"#File.read(path) # => "bazfoo"
;TI"f.pos # => 6
;TI"
;TI"f.seek(-3, :END)
;TI"f.write('bam')
;TI"
f.flush
;TI"#File.read(path) # => "bazbam"
;TI"f.pos # => 6
;TI"
;TI"f.pos = 8
;TI"/f.write('bah') # Zero padding as needed.
;TI"
f.flush
;TI"2File.read(path) # => "bazbam\u0000\u0000bah"
;TI"f.pos # => 11
;T;0o;;0;[o; ;[I"Reading is not allowed:;T@o;;[I"f.read # Raises IOError.
;T;0o;;0;[o; ;[I"'a':;T@o;;;;[ o;;0;[o; ;[I"&\File is not initially truncated:;T@o;;[ I"path = 't.tmp'
;TI"File.write(path, 'foo')
;TI"f = File.new(path, 'a')
;TI"f.size == 0 # => false
;T;0o;;0;[o; ;[I"3File's initial position is 0 (but is ignored):;T@o;;[I"f.pos # => 0
;T;0o;;0;[o; ;[I"/\File may be written only at end-of-file; ;TI"7IO#rewind, IO#pos=, IO#seek do not affect writing:;T@o;;[I"f.write('bar')
;TI"
f.flush
;TI"#File.read(path) # => "foobar"
;TI"f.write('baz')
;TI"
f.flush
;TI"&File.read(path) # => "foobarbaz"
;TI"
;TI"f.rewind
;TI"f.write('bat')
;TI"
f.flush
;TI")File.read(path) # => "foobarbazbat"
;T;0o;;0;[o; ;[I"Reading is not allowed:;T@o;;[I"f.read # Raises IOError.
;T;0o;;0;[o; ;[I"'r+':;T@o;;;;[o;;0;[o; ;[I"&\File is not initially truncated:;T@o;;[ I"path = 't.tmp'
;TI"File.write(path, text)
;TI"f = File.new(path, 'r+')
;TI"f.size == 0 # => false
;T;0o;;0;[o; ;[I"'File's initial read position is 0:;T@o;;[I"f.pos # => 0
;T;0o;;0;[o; ;[I"D\File may be read or written anywhere (even past end-of-file); ;TI"%see IO#rewind, IO#pos=, IO#seek:;T@o;;[+I"$f.readline # => "First line\n"
;TI"%f.readline # => "Second line\n"
;TI"
;TI"f.rewind
;TI"$f.readline # => "First line\n"
;TI"
;TI"f.pos = 1
;TI"#f.readline # => "irst line\n"
;TI"
;TI"f.seek(1, :CUR)
;TI"$f.readline # => "econd line\n"
;TI"
;TI"f.rewind
;TI"f.write('WWW')
;TI"
f.flush
;TI"File.read(path)
;TI"?# => "WWWst line\nSecond line\nFourth line\nFifth line\n"
;TI"
;TI"f.pos = 10
;TI"f.write('XXX')
;TI"
f.flush
;TI"File.read(path)
;TI"?# => "WWWst lineXXXecond line\nFourth line\nFifth line\n"
;TI"
;TI"f.seek(-6, :END)
;TI"# => 0
;TI"f.write('YYY')
;TI"# => 3
;TI"
f.flush
;TI"# => #
;TI"File.read(path)
;TI"?# => "WWWst lineXXXecond line\nFourth line\nFifth YYYe\n"
;TI"
;TI"f.seek(2, :END)
;TI".f.write('ZZZ') # Zero padding as needed.
;TI"
f.flush
;TI"File.read(path)
;TI"N# => "WWWst lineXXXecond line\nFourth line\nFifth YYYe\n\u0000\u0000ZZZ"
;T;0o;;0;[o; ;[I"'a+':;T@o;;;;[ o;;0;[o; ;[I"&\File is not initially truncated:;T@o;;[ I"path = 't.tmp'
;TI"File.write(path, 'foo')
;TI"f = File.new(path, 'a+')
;TI"f.size == 0 # => false
;T;0o;;0;[o; ;[I"'File's initial read position is 0:;T@o;;[I"f.pos # => 0
;T;0o;;0;[o; ;[I"/\File may be written only at end-of-file; ;TI"7IO#rewind, IO#pos=, IO#seek do not affect writing:;T@o;;[I"f.write('bar')
;TI"
f.flush
;TI"(File.read(path) # => "foobar"
;TI"f.write('baz')
;TI"
f.flush
;TI"+File.read(path) # => "foobarbaz"
;TI"
;TI"f.rewind
;TI"f.write('bat')
;TI"
f.flush
;TI")File.read(path) # => "foobarbazbat"
;T;0o;;0;[o; ;[I"A\File may be read anywhere; see IO#rewind, IO#pos=, IO#seek:;T@o;;[
I"f.rewind
;TI" f.read # => "foobarbazbat"
;TI"
;TI"f.pos = 3
;TI"f.read # => "barbazbat"
;TI"
;TI"f.seek(-3, :END)
;TI"f.read # => "bat"
;T;0S;;i
;
I"-Read/Write Modes for \File To Be Created;T@o; ;[I"DNote that modes 'r' and 'r+' are not allowed ;TI"0for a non-existent file (exception raised).;T@o;;;;[ o;;0;[o; ;[I"'w':;T@o;;;;[o;;0;[o; ;[I"(File's initial write position is 0:;T@o;;[ I"path = 't.tmp'
;TI"FileUtils.rm_f(path)
;TI"f = File.new(path, 'w')
;TI"f.pos # => 0
;T;0o;;0;[o; ;[I"<\File may be written anywhere (even past end-of-file); ;TI"%see IO#rewind, IO#pos=, IO#seek:;T@o;;[&I"f.write('foo')
;TI"
f.flush
;TI" File.read(path) # => "foo"
;TI"f.pos # => 3
;TI"
;TI"f.write('bar')
;TI"
f.flush
;TI"#File.read(path) # => "foobar"
;TI"f.pos # => 6
;TI"
;TI"f.rewind
;TI"f.write('baz')
;TI"
f.flush
;TI"#File.read(path) # => "bazbar"
;TI"f.pos # => 3
;TI"
;TI"f.pos = 3
;TI"f.write('foo')
;TI"
f.flush
;TI"#File.read(path) # => "bazfoo"
;TI"f.pos # => 6
;TI"
;TI"f.seek(-3, :END)
;TI"f.write('bam')
;TI"
f.flush
;TI"#File.read(path) # => "bazbam"
;TI"f.pos # => 6
;TI"
;TI"f.pos = 8
;TI"/f.write('bah') # Zero padding as needed.
;TI"
f.flush
;TI"2File.read(path) # => "bazbam\u0000\u0000bah"
;TI"f.pos # => 11
;T;0o;;0;[o; ;[I"Reading is not allowed:;T@o;;[I"f.read # Raises IOError.
;T;0o;;0;[o; ;[I"'a':;T@o;;;;[o;;0;[o; ;[I"(File's initial write position is 0:;T@o;;[ I"path = 't.tmp'
;TI"FileUtils.rm_f(path)
;TI"f = File.new(path, 'a')
;TI"f.pos # => 0
;T;0o;;0;[o; ;[I"(Writing occurs only at end-of-file:;T@o;;[I"f.write('foo')
;TI"f.pos # => 3
;TI"f.write('bar')
;TI"f.pos # => 6
;TI"
f.flush
;TI"#File.read(path) # => "foobar"
;TI"
;TI"f.rewind
;TI"f.write('baz')
;TI"
f.flush
;TI"&File.read(path) # => "foobarbaz"
;T;0o;;0;[o; ;[I"Reading is not allowed:;T@o;;[I"f.read # Raises IOError.
;T;0o;;0;[o; ;[I"'w+':;T@o;;;;[o;;0;[o; ;[I""File's initial position is 0:;T@o;;[ I"path = 't.tmp'
;TI"FileUtils.rm_f(path)
;TI"f = File.new(path, 'w+')
;TI"f.pos # => 0
;T;0o;;0;[o; ;[I"<\File may be written anywhere (even past end-of-file); ;TI"%see IO#rewind, IO#pos=, IO#seek:;T@o;;[&I"f.write('foo')
;TI"
f.flush
;TI" File.read(path) # => "foo"
;TI"f.pos # => 3
;TI"
;TI"f.write('bar')
;TI"
f.flush
;TI"#File.read(path) # => "foobar"
;TI"f.pos # => 6
;TI"
;TI"f.rewind
;TI"f.write('baz')
;TI"
f.flush
;TI"#File.read(path) # => "bazbar"
;TI"f.pos # => 3
;TI"
;TI"f.pos = 3
;TI"f.write('foo')
;TI"
f.flush
;TI"#File.read(path) # => "bazfoo"
;TI"f.pos # => 6
;TI"
;TI"f.seek(-3, :END)
;TI"f.write('bam')
;TI"
f.flush
;TI"#File.read(path) # => "bazbam"
;TI"f.pos # => 6
;TI"
;TI"f.pos = 8
;TI"/f.write('bah') # Zero padding as needed.
;TI"
f.flush
;TI"2File.read(path) # => "bazbam\u0000\u0000bah"
;TI"f.pos # => 11
;T;0o;;0;[o; ;[I"9\File may be read anywhere (even past end-of-file); ;TI"%see IO#rewind, IO#pos=, IO#seek:;T@o;;[I"f.rewind
;TI"# => 0
;TI"f.read
;TI""# => "bazbam\u0000\u0000bah"
;TI"
;TI"f.pos = 3
;TI"# => 3
;TI"f.read
;TI"# => "bam\u0000\u0000bah"
;TI"
;TI"f.seek(-3, :END)
;TI"# => 0
;TI"f.read
;TI"# => "bah"
;T;0o;;0;[o; ;[I"'a+':;T@o;;;;[o;;0;[o; ;[I"(File's initial write position is 0:;T@o;;[ I"path = 't.tmp'
;TI"FileUtils.rm_f(path)
;TI"f = File.new(path, 'a+')
;TI"f.pos # => 0
;T;0o;;0;[o; ;[I"(Writing occurs only at end-of-file:;T@o;;[I"f.write('foo')
;TI"f.pos # => 3
;TI"f.write('bar')
;TI"f.pos # => 6
;TI"
f.flush
;TI"#File.read(path) # => "foobar"
;TI"
;TI"f.rewind
;TI"f.write('baz')
;TI"
f.flush
;TI"&File.read(path) # => "foobarbaz"
;T;0o;;0;[o; ;[I"9\File may be read anywhere (even past end-of-file); ;TI"%see IO#rewind, IO#pos=, IO#seek:;T@o;;[I"f.rewind
;TI"f.read # => "foobarbaz"
;TI"
;TI"f.pos = 3
;TI"f.read # => "barbaz"
;TI"
;TI"f.seek(-3, :END)
;TI"f.read # => "baz"
;TI"
;TI"f.pos = 800
;TI"f.read # => ""
;T;0S;;i ;
I"\Data Mode;T@o; ;[I"ITo specify whether data is to be treated as text or as binary data, ;TI"Seither of the following may be suffixed to any of the string read/write modes ;TI"above:;T@o;;;;[o;;0;[o; ;[ I"A't': Text data; sets the default external encoding ;TI""to Encoding::UTF_8; ;TI"9on Windows, enables conversion between EOL and CRLF ;TI"Eand enables interpreting 0x1A as an end-of-file marker.;To;;0;[o; ;[ I"C'b': Binary data; sets the default external encoding ;TI"'to Encoding::ASCII_8BIT; ;TI"0x1A as an end-of-file marker.;T@o; ;[I";If neither is given, the stream defaults to text data.;T@o; ;[I"Examples:;T@o;;[I"File.new('t.txt', 'rt')
;TI"File.new('t.dat', 'rb')
;T;0o; ;[I"NWhen the data mode is specified, the read/write mode may not be omitted, ;TI"Cand the data mode must precede the file-create mode, if given:;T@o;;[I"5File.new('t.dat', 'b') # Raises an exception.
;TI"5File.new('t.dat', 'rxb') # Raises an exception.
;T;0S;;i ;
I"\File-Create Mode;T@o; ;[I"EThe following may be suffixed to any writable string mode above:;T@o;;;;[o;;0;[o; ;[I":'x': Creates the file if it does not exist; ;TI",raises an exception if the file exists.;T@o; ;[I"
Example:;T@o;;[I"File.new('t.tmp', 'wx')
;T;0o; ;[I"UWhen the file-create mode is specified, the read/write mode may not be omitted, ;TI"8and the file-create mode must follow the data mode:;T@o;;[I"5File.new('t.dat', 'x') # Raises an exception.
;TI"5File.new('t.dat', 'rxb') # Raises an exception.
;T;0S;;i;
I"\Integer Access Modes;T@o; ;[I"PWhen mode is an integer it must be one or more of the following constants, ;TI"Awhich may be combined by the bitwise OR operator |:;T@o;;;;[ o;;0;[o; ;[I"++File::RDONLY+: Open for reading only.;To;;0;[o; ;[I"++File::WRONLY+: Open for writing only.;To;;0;[o; ;[I"0+File::RDWR+: Open for reading and writing.;To;;0;[o; ;[I"-+File::APPEND+: Open for appending only.;T@o; ;[I"Examples:;T@o;;[I"%File.new('t.txt', File::RDONLY)
;TI">File.new('t.tmp', File::RDWR | File::CREAT | File::EXCL)
;T;0o; ;[I"XNote: Method IO#set_encoding does not allow the mode to be specified as an integer.;T@S;;i;
I".File-Create Mode Specified as an \Integer;T@o; ;[I" #
;TI""f.internal_encoding # => nil
;TI"(f = File.new('t.dat', 'rb:UTF-16')
;TI"9f.external_encoding # => #
;TI""f.internal_encoding # => nil
;TI"/f = File.new('t.dat', 'rb:UTF-16:UTF-16')
;TI"9f.external_encoding # => #
;TI"1f.internal_encoding # => #
;TI"
f.close
;T;0o; ;[I"KThe numerous encoding names are available in array Encoding.name_list:;T@o;;[I"IEncoding.name_list.take(3) # => ["ASCII-8BIT", "UTF-8", "US-ASCII"]
;T;0o; ;[I"QWhen the external encoding is set, strings read are tagged by that encoding ;TI"Kwhen reading, and strings written are converted to that encoding when ;TI"
writing.;T@o; ;[
I"8When both external and internal encodings are set, ;TI"Dstrings read are converted from external to internal encoding, ;TI"Kand strings written are converted from internal to external encoding. ;TI"=For further details about transcoding input and output, ;TI"8see {Encodings}[rdoc-ref:encodings.rdoc@Encodings].;T@o; ;[I"OIf the external encoding is 'BOM|UTF-8', 'BOM|UTF-16LE' ;TI"!or 'BOM|UTF16-BE', ;TI"9Ruby checks for a Unicode BOM in the input document ;TI"%to help determine the encoding. ;TI"=For UTF-16 encodings the file open mode must be binary. ;TI"If the BOM is found, ;TI"Cit is stripped and the external encoding from the BOM is used.;T@o; ;[I"BNote that the BOM-style encoding option is case insensitive, ;TI"+so 'bom|utf-8' is also valid.;T@S;;i;
I"\File Permissions;T@o; ;[I"EA \File object has _permissions_, an octal integer representing ;TI"Bthe permissions of an actual file in the underlying platform.;T@o; ;[I"DNote that file permissions are quite different from the _mode_ ;TI"%of a file stream (\File object).;T@o; ;[I" "100644"
;T;0o; ;[
I"'On a Unix-based operating system, ;TI"@the three low-order octal digits represent the permissions ;TI".for owner (6), group (4), and world (4). ;TI"FThe triplet of bits in each octal digit represent, respectively, ;TI"*read, write, and execute permissions.;T@o; ;[ I"JPermissions 0644 thus represent read-write access for owner ;TI"/and read-only access for group and world. ;TI"GSee man pages {open(2)}[https://www.unix.com/man-page/bsd/2/open] ;TI"?and {chmod(2)}[https://www.unix.com/man-page/bsd/2/chmod].;T@o; ;[I">For a directory, the meaning of the execute bit changes: ;TI"-when set, the directory can be searched.;T@o; ;[I"DHigher-order bits in permissions may indicate the type of file ;TI"O(plain, directory, pipe, socket, etc.) and various other special features.;T@o; ;[
I"[On non-Posix operating systems, permissions may include only read-only or read-write, ;TI"Kin which case, the remaining permission will resemble typical values. ;TI"NOn Windows, for instance, the default permissions are 0644; ;TI":The only change that can be made is to make the file ;TI"7read-only, which is reported as 0444.;T@o; ;[I"JFor a method that actually creates a file in the underlying platform ;TI"5(as opposed to merely creating a \File object), ;TI""permissions may be specified:;T@o;;[I"*File.new('t.tmp', File::CREAT, 0644)
;TI"*File.new('t.tmp', File::CREAT, 0444)
;T;0o; ;[I"%Permissions may also be changed:;T@o;;[I".f = File.new('t.tmp', File::CREAT, 0444)
;TI"f.chmod(0644)
;TI"f.chmod(0444)
;T;0S;;i;
I"\File \Constants;T@o; ;[I"7Various constants for use in \File and IO methods ;TI"-may be found in module File::Constants; ;TI"Oan array of their names is returned by File::Constants.constants.;T@S;;i;
I"What's Here;T@o; ;[I"+First, what's elsewhere. \Class \File:;T@o;;;;[o;;0;[o; ;[I":Inherits from {class IO}[rdoc-ref:IO@What-27s+Here], ;TI"Din particular, methods for creating, reading, and writing files;To;;0;[o; ;[I"Includes module FileTest, ;TI"1which provides dozens of additional methods.;T@o; ;[I"~ for a home directory.;To;;0;[o; ;[I"C::extname: Returns the file extension for the given file path.;To;;0;[o; ;[I"L::fnmatch? (aliased as ::fnmatch): Returns whether the given file path ;TI"matches the given pattern.;To;;0;[o; ;[I"=::join: Joins path components into a single path string.;To;;0;[o; ;[I"A::path: Returns the string representation of the given path.;To;;0;[o; ;[I"I::readlink: Returns the path to the file at the given symbolic link.;To;;0;[o; ;[I"C::realdirpath: Returns the real path for the given file path, ;TI"-where the last component need not exist.;To;;0;[o; ;[I"@::realpath: Returns the real path for the given file path, ;TI"%where all components must exist.;To;;0;[o; ;[I"O::split: Returns an array of two strings: the directory name and basename ;TI"#of the file at the given path.;To;;0;[o; ;[I"W#path (aliased as #to_path): Returns the string representation of the given path.;T@o; ;[I"_Times_;T@o;;;;[
o;;0;[o; ;[I"J::atime: Returns a Time for the most recent access to the given file.;To;;0;[o; ;[I"E::birthtime: Returns a Time for the creation of the given file.;To;;0;[o; ;[I"H::ctime: Returns a Time for the metadata change of the given file.;To;;0;[o; ;[I"F::mtime: Returns a Time for the most recent data modification to ;TI"#the content of the given file.;To;;0;[o; ;[I"A#atime: Returns a Time for the most recent access to +self+.;To;;0;[o; ;[I"9#birthtime: Returns a Time the creation for +self+.;To;;0;[o; ;[I">#ctime: Returns a Time for the metadata change of +self+.;To;;0;[o; ;[I"B#mtime: Returns a Time for the most recent data modification ;TI"to the content of +self+.;T@o; ;[I"_Types_;T@o;;;;[ o;;0;[o; ;[I"O::blockdev?: Returns whether the file at the given path is a block device.;To;;0;[o; ;[I"R::chardev?: Returns whether the file at the given path is a character device.;To;;0;[o; ;[I"M::directory?: Returns whether the file at the given path is a directory.;To;;0;[o; ;[I"M::executable?: Returns whether the file at the given path is executable ;TI"::umask: Returns the umask value for the current process.;To;;0;[o; ;[I"O::world_readable?: Returns whether the file at the given path is readable ;TI"by others.;To;;0;[o; ;[I"O::world_writable?: Returns whether the file at the given path is writable ;TI"by others.;To;;0;[o; ;[I"I::writable?: Returns whether the file at the given path is writable ;TI"