D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
File
/
Filename :
cdesc-File.ri
back
Copy
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 <tt>File.exist?</tt>.;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 <tt>'r'</tt> and <tt>'r+'</tt> 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"I<tt>End only</tt> 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"<tt>'r'</tt>:;T@o;;;;[ o;;0;[o; ;[I"&\File is not initially truncated:;T@o;;[I".f = File.new('t.txt') # => #<File: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"<tt>'w'</tt>:;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"<tt>'a'</tt>:;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"<tt>'r+'</tt>:;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"# => #<File:t.tmp> ;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"<tt>'a+'</tt>:;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 <tt>'r'</tt> and <tt>'r+'</tt> are not allowed ;TI"0for a non-existent file (exception raised).;T@o;;;;[ o;;0;[o; ;[I"<tt>'w'</tt>:;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"<tt>'a'</tt>:;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"<tt>'w+'</tt>:;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"<tt>'a+'</tt>:;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<tt>'t'</tt>: Text data; sets the default external encoding ;TI""to <tt>Encoding::UTF_8</tt>; ;TI"9on Windows, enables conversion between EOL and CRLF ;TI"Eand enables interpreting <tt>0x1A</tt> as an end-of-file marker.;To;;0;[o; ;[ I"C<tt>'b'</tt>: Binary data; sets the default external encoding ;TI"'to <tt>Encoding::ASCII_8BIT</tt>; ;TI"<on Windows, suppresses conversion between EOL and CRLF ;TI"Fand disables interpreting <tt>0x1A</tt> 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":<tt>'x'</tt>: 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 <tt>|</tt>:;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"<These constants may also be ORed into the integer mode:;T@o;;;;[o;;0;[o; ;[I"5+File::CREAT+: Create file if it does not exist.;To;;0;[o; ;[I"T+File::EXCL+: Raise an exception if +File::CREAT+ is given and the file exists.;T@S;;i; I"(\Data Mode Specified as an \Integer;T@o; ;[I"3\Data mode cannot be specified as an integer. ;TI"9When the stream access mode is given as an integer, ;TI"0the data mode is always text, never binary.;T@o; ;[ I"<Note that although there is a constant +File::BINARY+, ;TI"@setting its value in an integer stream mode has no effect; ;TI"8this is because, as documented in File::Constants, ;TI"=the +File::BINARY+ value disables line code conversion, ;TI"/but does not change the external encoding.;T@S;;i; I"Encodings;T@o; ;[I";Any of the string modes above may specify encodings - ;TI"Meither external encoding only or both external and internal encodings - ;TI"Bby appending one or both encoding names, separated by colons:;T@o;;[I"!f = File.new('t.dat', 'rb') ;TI"5f.external_encoding # => #<Encoding:ASCII-8BIT> ;TI""f.internal_encoding # => nil ;TI"(f = File.new('t.dat', 'rb:UTF-16') ;TI"9f.external_encoding # => #<Encoding:UTF-16 (dummy)> ;TI""f.internal_encoding # => nil ;TI"/f = File.new('t.dat', 'rb:UTF-16:UTF-16') ;TI"9f.external_encoding # => #<Encoding:UTF-16 (dummy)> ;TI"1f.internal_encoding # => #<Encoding:UTF-16> ;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 <tt>'BOM|UTF-8'</tt>, <tt>'BOM|UTF-16LE'</tt> ;TI"!or <tt>'BOM|UTF16-BE'</tt>, ;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 <tt>'bom|utf-8'</tt> 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"<In a \File object, the permissions are available thus, ;TI"@where method +mode+, despite its name, returns permissions:;T@o;;[I"f = File.new('t.txt') ;TI"(f.lstat.mode.to_s(8) # => "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 <tt>0644</tt> 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 <code>0644</code>; ;TI":The only change that can be made is to make the file ;TI"7read-only, which is reported as <code>0444</code>.;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 <tt>File::Constants.constants</tt>.;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"<Here, class \File provides methods that are useful for:;T@o;;;;[ o;;0;[o; ;[I"'{Creating}[rdoc-ref:File@Creating];To;;0;[o; ;[I"'{Querying}[rdoc-ref:File@Querying];To;;0;[o; ;[I"'{Settings}[rdoc-ref:File@Settings];To;;0;[o; ;[I"!{Other}[rdoc-ref:File@Other];T@S;;i; I" Creating;T@o;;;;[ o;;0;[o; ;[I"?::new: Opens the file at the given path; returns the file.;To;;0;[o; ;[I"U::open: Same as ::new, but when given a block will yield the file to the block, ;TI"/and close the file upon exiting the block.;To;;0;[o; ;[I"G::link: Creates a new name for an existing file using a hard link.;To;;0;[o; ;[I"?::mkfifo: Returns the FIFO file created at the given path.;To;;0;[o; ;[I"@::symlink: Creates a symbolic link for the given file path.;T@S;;i; I" Querying;T@o; ;[I"_Paths_;T@o;;;;[o;;0;[o; ;[I"H::absolute_path: Returns the absolute file path for the given path.;To;;0;[o; ;[I"P::absolute_path?: Returns whether the given path is the absolute file path.;To;;0;[o; ;[I"C::basename: Returns the last component of the given file path.;To;;0;[o; ;[I"J::dirname: Returns all but the last component of the given file path.;To;;0;[o; ;[I"G::expand_path: Returns the absolute file path for the given path, ;TI"/expanding <tt>~</tt> 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"<by the effective user and group of the current process.;To;;0;[o; ;[I"R::executable_real?: Returns whether the file at the given path is executable ;TI"7by the real user and group of the current process.;To;;0;[o; ;[I"A::exist?: Returns whether the file at the given path exists.;To;;0;[o; ;[I"K::file?: Returns whether the file at the given path is a regular file.;To;;0;[o; ;[I"M::ftype: Returns a string giving the type of the file at the given path.;To;;0;[o; ;[I"M::grpowned?: Returns whether the effective group of the current process ;TI"%owns the file at the given path.;To;;0;[o; ;[I"N::identical?: Returns whether the files at two given paths are identical.;To;;0;[o; ;[I"G::lstat: Returns the File::Stat object for the last symbolic link ;TI"in the given path.;To;;0;[o; ;[I"I::owned?: Returns whether the effective user of the current process ;TI"%owns the file at the given path.;To;;0;[o; ;[I"C::pipe?: Returns whether the file at the given path is a pipe.;To;;0;[o; ;[I"I::readable?: Returns whether the file at the given path is readable ;TI"<by the effective user and group of the current process.;To;;0;[o; ;[I"N::readable_real?: Returns whether the file at the given path is readable ;TI"7by the real user and group of the current process.;To;;0;[o; ;[I"U::setgid?: Returns whether the setgid bit is set for the file at the given path.;To;;0;[o; ;[I"U::setuid?: Returns whether the setuid bit is set for the file at the given path.;To;;0;[o; ;[I"G::socket?: Returns whether the file at the given path is a socket.;To;;0;[o; ;[I"J::stat: Returns the File::Stat object for the file at the given path.;To;;0;[o; ;[I"R::sticky?: Returns whether the file at the given path has its sticky bit set.;To;;0;[o; ;[I"O::symlink?: Returns whether the file at the given path is a symbolic link.;To;;0;[o; ;[I">::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"<by the effective user and group of the current process.;To;;0;[o; ;[I"N::writable_real?: Returns whether the file at the given path is writable ;TI"7by the real user and group of the current process.;To;;0;[o; ;[I"F#lstat: Returns the File::Stat object for the last symbolic link ;TI"in the path for +self+.;T@o; ;[I"_Contents_;T@o;;;;[ o;;0;[o; ;[I"O::empty? (aliased as ::zero?): Returns whether the file at the given path ;TI"exists and is empty.;To;;0;[o; ;[I"D::size: Returns the size (bytes) of the file at the given path.;To;;0;[o; ;[I"C::size?: Returns +nil+ if there is no file at the given path, ;TI"Gor if that file is empty; otherwise returns the file size (bytes).;To;;0;[o; ;[I"/#size: Returns the size (bytes) of +self+.;T@S;;i; I" Settings;T@o;;;;[ o;;0;[o; ;[I"@::chmod: Changes permissions of the file at the given path.;To;;0;[o; ;[I"=::chown: Change ownership of the file at the given path.;To;;0;[o; ;[I"O::lchmod: Changes permissions of the last symbolic link in the given path.;To;;0;[o; ;[I"G::lchown: Change ownership of the last symbolic in the given path.;To;;0;[o; ;[I"T::lutime: For each given file path, sets the access time and modification time ;TI"+of the last symbolic link in the path.;To;;0;[o; ;[I"F::rename: Moves the file at one given path to another given path.;To;;0;[o; ;[I"F::utime: Sets the access time and modification time of each file ;TI"at the given paths.;To;;0;[o; ;[I"%#flock: Locks or unlocks +self+.;T@S;;i; I" Other;T@o;;;;[o;;0;[o; ;[I"M::truncate: Truncates the file at the given file path to the given size.;To;;0;[o; ;[I"O::unlink (aliased as ::delete): Deletes the file for each given file path.;To;;0;[o; ;[I"3#truncate: Truncates +self+ to the given size.;T: @fileI"file.c;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ U:RDoc::Constant[i I"Separator;TI"File::Separator;T:public0o;;[o; ;[I"&separates directory parts in path;T@;@�;0@�@cRDoc::NormalClass0U;[i I"SEPARATOR;TI"File::SEPARATOR;T;0o;;[o; ;[I"&separates directory parts in path;T@;@�;0@�@@�0U;[i I"ALT_SEPARATOR;TI"File::ALT_SEPARATOR;T;0o;;[o; ;[I",platform specific alternative separator;T@;@�;0@�@@�0U;[i I"PATH_SEPARATOR;TI"File::PATH_SEPARATOR;T;0o;;[o; ;[I"path list separator;T@;@�;0@�@@�0[ [[I" class;T[[;[D[I"absolute_path;TI"file.c;T[I"absolute_path?;T@�[I" atime;T@�[I" basename;T@�[I"birthtime;T@�[I"blockdev?;T@�[I" chardev?;T@�[I" chmod;T@�[I" chown;T@�[I" ctime;T@�[I"delete;T@�[I"directory?;T@�[I"dirname;T@�[I"empty?;T@�[I"executable?;T@�[I"executable_real?;T@�[I"exist?;T@�[I"expand_path;T@�[I"extname;T@�[I" file?;T@�[I"fnmatch;TI"dir.rb;T[I" fnmatch?;T@ [I" ftype;T@�[I"grpowned?;T@�[I"identical?;T@�[I" join;T@�[I"lchmod;T@�[I"lchown;T@�[I" link;T@�[I" lstat;T@�[I"lutime;T@�[I"mkfifo;T@�[I" mtime;T@�[I"new;TI" io.c;T[I" open;T@%[I"owned?;T@�[I" path;T@�[I" pipe?;T@�[I"readable?;T@�[I"readable_real?;T@�[I" readlink;T@�[I"realdirpath;T@�[I" realpath;T@�[I"rename;T@�[I"setgid?;T@�[I"setuid?;T@�[I" size;T@�[I" size?;T@�[I"socket?;T@�[I" split;T@�[I" stat;T@�[I"sticky?;T@�[I"symlink;T@�[I" symlink?;T@�[I" truncate;T@�[I" umask;T@�[I"unlink;T@�[I" utime;T@�[I"world_readable?;T@�[I"world_writable?;T@�[I"writable?;T@�[I"writable_real?;T@�[I" zero?;T@�[:protected[ [:private[ [I" instance;T[[;[[I" atime;T@�[I"birthtime;T@�[I" chmod;T@�[I" chown;T@�[I" ctime;T@�[I" flock;T@�[I" lstat;T@�[I" mtime;T@�[I" size;T@�[I" truncate;T@�[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[I" dir.c;TI"!ext/pathname/lib/pathname.rb;T@�I" io.c;TI"lib/bundler.rb;TI"lib/cgi/session.rb;TI"lib/cgi/session/pstore.rb;TI"lib/fileutils.rb;TI"lib/logger.rb;TI"lib/logger/log_device.rb;TI"lib/mkmf.rb;TI"lib/open-uri.rb;TI"lib/optparse.rb;TI"lib/pp.rb;TI"lib/pstore.rb;TI"lib/rubygems.rb;TI"(lib/rubygems/basic_specification.rb;TI"1lib/rubygems/commands/environment_command.rb;TI"+lib/rubygems/commands/setup_command.rb;TI" lib/rubygems/config_file.rb;TI"lib/rubygems/defaults.rb;TI"&lib/rubygems/ext/cargo_builder.rb;TI"lib/rubygems/installer.rb;TI"lib/rubygems/package.rb;TI"!lib/rubygems/path_support.rb;TI"lib/tempfile.rb;T@�cRDoc::TopLevel