rbs 4.0.0.dev.4 → 4.0.0
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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +14 -14
- data/.github/workflows/bundle-update.yml +60 -0
- data/.github/workflows/c-check.yml +18 -11
- data/.github/workflows/comments.yml +5 -3
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/ruby.yml +27 -34
- data/.github/workflows/rust.yml +95 -0
- data/.github/workflows/typecheck.yml +2 -2
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +323 -0
- data/README.md +1 -1
- data/Rakefile +43 -33
- data/Steepfile +1 -0
- data/config.yml +426 -24
- data/core/array.rbs +307 -227
- data/core/basic_object.rbs +9 -8
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +2 -2
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +55 -34
- data/core/complex.rbs +104 -78
- data/core/dir.rbs +61 -49
- data/core/encoding.rbs +12 -15
- data/core/enumerable.rbs +179 -87
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +65 -2
- data/core/errno.rbs +11 -2
- data/core/errors.rbs +58 -29
- data/core/exception.rbs +13 -13
- data/core/fiber.rbs +74 -54
- data/core/file.rbs +280 -177
- data/core/file_test.rbs +3 -3
- data/core/float.rbs +257 -92
- data/core/gc.rbs +425 -281
- data/core/hash.rbs +1045 -739
- data/core/integer.rbs +135 -137
- data/core/io/buffer.rbs +53 -42
- data/core/io/wait.rbs +13 -35
- data/core/io.rbs +192 -144
- data/core/kernel.rbs +216 -155
- data/core/marshal.rbs +4 -4
- data/core/match_data.rbs +15 -13
- data/core/math.rbs +107 -66
- data/core/method.rbs +69 -33
- data/core/module.rbs +244 -106
- data/core/nil_class.rbs +7 -6
- data/core/numeric.rbs +74 -63
- data/core/object.rbs +9 -11
- data/core/object_space.rbs +30 -23
- data/core/pathname.rbs +1322 -0
- data/core/proc.rbs +95 -58
- data/core/process.rbs +222 -202
- data/core/ractor.rbs +371 -515
- data/core/random.rbs +21 -3
- data/core/range.rbs +159 -57
- data/core/rational.rbs +60 -89
- data/core/rbs/unnamed/argf.rbs +60 -53
- data/core/rbs/unnamed/env_class.rbs +19 -14
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +11 -118
- data/core/regexp.rbs +258 -214
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +38 -34
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +4 -71
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +16 -82
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +490 -360
- data/core/signal.rbs +26 -16
- data/core/string.rbs +3234 -1285
- data/core/struct.rbs +27 -26
- data/core/symbol.rbs +41 -34
- data/core/thread.rbs +135 -67
- data/core/time.rbs +81 -50
- data/core/trace_point.rbs +41 -35
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +24 -16
- data/core/warning.rbs +7 -7
- data/docs/aliases.md +79 -0
- data/docs/collection.md +3 -3
- data/docs/config.md +171 -0
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/inline.md +576 -0
- data/docs/sigs.md +3 -3
- data/docs/syntax.md +46 -16
- data/docs/type_fingerprint.md +21 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +544 -116
- data/ext/rbs_extension/ast_translation.h +3 -0
- data/ext/rbs_extension/class_constants.c +16 -2
- data/ext/rbs_extension/class_constants.h +8 -0
- data/ext/rbs_extension/extconf.rb +5 -1
- data/ext/rbs_extension/legacy_location.c +33 -56
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +44 -35
- data/include/rbs/ast.h +448 -173
- data/include/rbs/defines.h +27 -0
- data/include/rbs/lexer.h +30 -11
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +6 -6
- data/include/rbs/string.h +0 -2
- data/include/rbs/util/rbs_allocator.h +34 -13
- data/include/rbs/util/rbs_assert.h +12 -1
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs/util/rbs_encoding.h +2 -0
- data/include/rbs/util/rbs_unescape.h +2 -1
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +10 -10
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +293 -3
- data/lib/rbs/ast/ruby/comment_block.rb +24 -0
- data/lib/rbs/ast/ruby/declarations.rb +198 -3
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
- data/lib/rbs/ast/ruby/members.rb +532 -22
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +20 -15
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +38 -106
- data/lib/rbs/cli.rb +52 -19
- data/lib/rbs/collection/config/lockfile_generator.rb +14 -2
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
- data/lib/rbs/definition_builder/method_builder.rb +20 -0
- data/lib/rbs/definition_builder.rb +147 -25
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment.rb +227 -74
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/errors.rb +27 -18
- data/lib/rbs/inline_parser.rb +342 -6
- data/lib/rbs/location_aux.rb +1 -1
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/parser_aux.rb +20 -7
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +3 -28
- data/lib/rbs/prototype/rbi.rb +3 -20
- data/lib/rbs/prototype/runtime.rb +8 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +116 -38
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +19 -2
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +88 -78
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -2
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +4 -3
- data/rust/.gitignore +1 -0
- data/rust/Cargo.lock +378 -0
- data/rust/Cargo.toml +7 -0
- data/rust/ruby-rbs/Cargo.toml +22 -0
- data/rust/ruby-rbs/build.rs +764 -0
- data/rust/ruby-rbs/examples/locations.rs +60 -0
- data/rust/ruby-rbs/src/lib.rs +1 -0
- data/rust/ruby-rbs/src/node/mod.rs +742 -0
- data/rust/ruby-rbs/tests/sanity.rs +47 -0
- data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
- data/rust/ruby-rbs-sys/Cargo.toml +23 -0
- data/rust/ruby-rbs-sys/build.rs +204 -0
- data/rust/ruby-rbs-sys/src/lib.rs +50 -0
- data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
- data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
- data/rust/ruby-rbs-sys/wrapper.h +1 -0
- data/schema/typeParam.json +17 -1
- data/sig/ast/ruby/annotations.rbs +315 -4
- data/sig/ast/ruby/comment_block.rbs +8 -0
- data/sig/ast/ruby/declarations.rbs +102 -4
- data/sig/ast/ruby/members.rbs +108 -2
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +12 -8
- data/sig/cli.rbs +18 -18
- data/sig/definition.rbs +6 -1
- data/sig/definition_builder.rbs +2 -0
- data/sig/environment.rbs +70 -12
- data/sig/errors.rbs +13 -14
- data/sig/inline_parser.rbs +39 -2
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -1
- data/sig/method_builder.rbs +3 -1
- data/sig/parser.rbs +31 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/resolver/type_name_resolver.rbs +35 -7
- data/sig/source.rbs +3 -3
- data/sig/type_param.rbs +13 -8
- data/sig/types.rbs +6 -7
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +410 -153
- data/src/lexer.c +1392 -1313
- data/src/lexer.re +3 -0
- data/src/lexstate.c +58 -37
- data/src/location.c +8 -48
- data/src/parser.c +977 -516
- data/src/string.c +0 -48
- data/src/util/rbs_allocator.c +89 -71
- data/src/util/rbs_assert.c +1 -1
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +10 -14
- data/src/util/rbs_encoding.c +4 -8
- data/src/util/rbs_unescape.c +56 -20
- data/stdlib/bigdecimal/0/big_decimal.rbs +116 -98
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +7 -4
- data/stdlib/date/0/date.rbs +92 -79
- data/stdlib/date/0/date_time.rbs +25 -24
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/digest/0/digest.rbs +110 -0
- data/stdlib/erb/0/erb.rbs +748 -347
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +158 -139
- data/stdlib/forwardable/0/forwardable.rbs +13 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +217 -136
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +162 -134
- data/stdlib/objspace/0/objspace.rbs +17 -34
- data/stdlib/open-uri/0/open-uri.rbs +48 -8
- data/stdlib/open3/0/open3.rbs +469 -10
- data/stdlib/openssl/0/openssl.rbs +475 -357
- data/stdlib/optparse/0/optparse.rbs +26 -17
- data/stdlib/pathname/0/pathname.rbs +11 -1381
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +65 -12
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -1
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +22 -19
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +7 -20
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/addrinfo.rbs +7 -7
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +23 -10
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +11 -3
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +1177 -85
- data/stdlib/strscan/0/string_scanner.rbs +27 -25
- data/stdlib/tempfile/0/tempfile.rbs +25 -21
- data/stdlib/time/0/time.rbs +8 -6
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +42 -20
- data/stdlib/uri/0/file.rbs +3 -3
- data/stdlib/uri/0/generic.rbs +26 -18
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +12 -12
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_reader.rbs +6 -6
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +50 -6
data/core/file.rbs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# A File object is a representation of a file in the underlying platform.
|
|
3
3
|
#
|
|
4
4
|
# Class File extends module FileTest, supporting such singleton methods as
|
|
5
|
-
#
|
|
5
|
+
# <code>File.exist?</code>.
|
|
6
6
|
#
|
|
7
7
|
# ## About the Examples
|
|
8
8
|
#
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
# | 'a+' | Anywhere | 0 | End only | End |
|
|
94
94
|
# |------|----------|----------|----------|-----------|
|
|
95
95
|
#
|
|
96
|
-
# Note that modes
|
|
97
|
-
# (exception raised).
|
|
96
|
+
# Note that modes <code>'r'</code> and <code>'r+'</code> are not allowed for a
|
|
97
|
+
# non-existent file (exception raised).
|
|
98
98
|
#
|
|
99
99
|
# In the tables:
|
|
100
100
|
#
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
#
|
|
109
109
|
# ##### Read/Write Modes for Existing File
|
|
110
110
|
#
|
|
111
|
-
# *
|
|
111
|
+
# * <code>'r'</code>:
|
|
112
112
|
#
|
|
113
113
|
# * File is not initially truncated:
|
|
114
114
|
#
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
#
|
|
138
138
|
# f.write('foo') # Raises IOError.
|
|
139
139
|
#
|
|
140
|
-
# *
|
|
140
|
+
# * <code>'w'</code>:
|
|
141
141
|
#
|
|
142
142
|
# * File is initially truncated:
|
|
143
143
|
#
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
#
|
|
192
192
|
# f.read # Raises IOError.
|
|
193
193
|
#
|
|
194
|
-
# *
|
|
194
|
+
# * <code>'a'</code>:
|
|
195
195
|
#
|
|
196
196
|
# * File is not initially truncated:
|
|
197
197
|
#
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
#
|
|
224
224
|
# f.read # Raises IOError.
|
|
225
225
|
#
|
|
226
|
-
# *
|
|
226
|
+
# * <code>'r+'</code>:
|
|
227
227
|
#
|
|
228
228
|
# * File is not initially truncated:
|
|
229
229
|
#
|
|
@@ -278,7 +278,7 @@
|
|
|
278
278
|
# File.read(path)
|
|
279
279
|
# # => "WWWst lineXXXecond line\nFourth line\nFifth YYYe\n\u0000\u0000ZZZ"
|
|
280
280
|
#
|
|
281
|
-
# *
|
|
281
|
+
# * <code>'a+'</code>:
|
|
282
282
|
#
|
|
283
283
|
# * File is not initially truncated:
|
|
284
284
|
#
|
|
@@ -319,10 +319,10 @@
|
|
|
319
319
|
#
|
|
320
320
|
# ##### Read/Write Modes for File To Be Created
|
|
321
321
|
#
|
|
322
|
-
# Note that modes
|
|
323
|
-
# (exception raised).
|
|
322
|
+
# Note that modes <code>'r'</code> and <code>'r+'</code> are not allowed for a
|
|
323
|
+
# non-existent file (exception raised).
|
|
324
324
|
#
|
|
325
|
-
# *
|
|
325
|
+
# * <code>'w'</code>:
|
|
326
326
|
#
|
|
327
327
|
# * File's initial write position is 0:
|
|
328
328
|
#
|
|
@@ -372,7 +372,7 @@
|
|
|
372
372
|
#
|
|
373
373
|
# f.read # Raises IOError.
|
|
374
374
|
#
|
|
375
|
-
# *
|
|
375
|
+
# * <code>'a'</code>:
|
|
376
376
|
#
|
|
377
377
|
# * File's initial write position is 0:
|
|
378
378
|
#
|
|
@@ -399,7 +399,7 @@
|
|
|
399
399
|
#
|
|
400
400
|
# f.read # Raises IOError.
|
|
401
401
|
#
|
|
402
|
-
# *
|
|
402
|
+
# * <code>'w+'</code>:
|
|
403
403
|
#
|
|
404
404
|
# * File's initial position is 0:
|
|
405
405
|
#
|
|
@@ -463,7 +463,7 @@
|
|
|
463
463
|
# f.read
|
|
464
464
|
# # => "bah"
|
|
465
465
|
#
|
|
466
|
-
# *
|
|
466
|
+
# * <code>'a+'</code>:
|
|
467
467
|
#
|
|
468
468
|
# * File's initial write position is 0:
|
|
469
469
|
#
|
|
@@ -506,12 +506,13 @@
|
|
|
506
506
|
# To specify whether data is to be treated as text or as binary data, either of
|
|
507
507
|
# the following may be suffixed to any of the string read/write modes above:
|
|
508
508
|
#
|
|
509
|
-
# *
|
|
510
|
-
# on Windows, enables conversion between EOL
|
|
511
|
-
# interpreting `0x1A` as an end-of-file marker.
|
|
512
|
-
# *
|
|
513
|
-
#
|
|
514
|
-
# CRLF and disables interpreting `0x1A` as an end-of-file
|
|
509
|
+
# * <code>'t'</code>: Text data; sets the default external encoding to
|
|
510
|
+
# <code>Encoding::UTF_8</code>; on Windows, enables conversion between EOL
|
|
511
|
+
# and CRLF and enables interpreting `0x1A` as an end-of-file marker.
|
|
512
|
+
# * <code>'b'</code>: Binary data; sets the default external encoding to
|
|
513
|
+
# <code>Encoding::ASCII_8BIT</code>; on Windows, suppresses conversion
|
|
514
|
+
# between EOL and CRLF and disables interpreting `0x1A` as an end-of-file
|
|
515
|
+
# marker.
|
|
515
516
|
#
|
|
516
517
|
# If neither is given, the stream defaults to text data.
|
|
517
518
|
#
|
|
@@ -530,8 +531,8 @@
|
|
|
530
531
|
#
|
|
531
532
|
# The following may be suffixed to any writable string mode above:
|
|
532
533
|
#
|
|
533
|
-
# *
|
|
534
|
-
# file exists.
|
|
534
|
+
# * <code>'x'</code>: Creates the file if it does not exist; raises an
|
|
535
|
+
# exception if the file exists.
|
|
535
536
|
#
|
|
536
537
|
# Example:
|
|
537
538
|
#
|
|
@@ -546,12 +547,12 @@
|
|
|
546
547
|
# ### Integer Access Modes
|
|
547
548
|
#
|
|
548
549
|
# When mode is an integer it must be one or more of the following constants,
|
|
549
|
-
# which may be combined by the bitwise OR operator
|
|
550
|
+
# which may be combined by the bitwise OR operator <code>|</code>:
|
|
550
551
|
#
|
|
551
|
-
# *
|
|
552
|
-
# *
|
|
553
|
-
# *
|
|
554
|
-
# *
|
|
552
|
+
# * <code>File::RDONLY</code>: Open for reading only.
|
|
553
|
+
# * <code>File::WRONLY</code>: Open for writing only.
|
|
554
|
+
# * <code>File::RDWR</code>: Open for reading and writing.
|
|
555
|
+
# * <code>File::APPEND</code>: Open for appending only.
|
|
555
556
|
#
|
|
556
557
|
# Examples:
|
|
557
558
|
#
|
|
@@ -565,19 +566,19 @@
|
|
|
565
566
|
#
|
|
566
567
|
# These constants may also be ORed into the integer mode:
|
|
567
568
|
#
|
|
568
|
-
# *
|
|
569
|
-
# *
|
|
570
|
-
# exists.
|
|
569
|
+
# * <code>File::CREAT</code>: Create file if it does not exist.
|
|
570
|
+
# * <code>File::EXCL</code>: Raise an exception if <code>File::CREAT</code> is
|
|
571
|
+
# given and the file exists.
|
|
571
572
|
#
|
|
572
573
|
# ### Data Mode Specified as an Integer
|
|
573
574
|
#
|
|
574
575
|
# Data mode cannot be specified as an integer. When the stream access mode is
|
|
575
576
|
# given as an integer, the data mode is always text, never binary.
|
|
576
577
|
#
|
|
577
|
-
# Note that although there is a constant
|
|
578
|
-
# integer stream mode has no effect; this is because, as documented
|
|
579
|
-
# File::Constants, the
|
|
580
|
-
# does not change the external encoding.
|
|
578
|
+
# Note that although there is a constant <code>File::BINARY</code>, setting its
|
|
579
|
+
# value in an integer stream mode has no effect; this is because, as documented
|
|
580
|
+
# in File::Constants, the <code>File::BINARY</code> value disables line code
|
|
581
|
+
# conversion, but does not change the external encoding.
|
|
581
582
|
#
|
|
582
583
|
# ### Encodings
|
|
583
584
|
#
|
|
@@ -608,14 +609,14 @@
|
|
|
608
609
|
# internal to external encoding. For further details about transcoding input and
|
|
609
610
|
# output, see [Encodings](rdoc-ref:encodings.rdoc@Encodings).
|
|
610
611
|
#
|
|
611
|
-
# If the external encoding is
|
|
612
|
-
#
|
|
613
|
-
# determine the encoding. For UTF-16
|
|
614
|
-
# binary. If the BOM is found, it is
|
|
615
|
-
# BOM is used.
|
|
612
|
+
# If the external encoding is <code>'BOM|UTF-8'</code>,
|
|
613
|
+
# <code>'BOM|UTF-16LE'</code> or <code>'BOM|UTF16-BE'</code>, Ruby checks for a
|
|
614
|
+
# Unicode BOM in the input document to help determine the encoding. For UTF-16
|
|
615
|
+
# encodings the file open mode must be binary. If the BOM is found, it is
|
|
616
|
+
# stripped and the external encoding from the BOM is used.
|
|
616
617
|
#
|
|
617
|
-
# Note that the BOM-style encoding option is case insensitive, so
|
|
618
|
-
# is also valid.
|
|
618
|
+
# Note that the BOM-style encoding option is case insensitive, so
|
|
619
|
+
# <code>'bom|utf-8'</code> is also valid.
|
|
619
620
|
#
|
|
620
621
|
# ## File Permissions
|
|
621
622
|
#
|
|
@@ -669,7 +670,7 @@
|
|
|
669
670
|
#
|
|
670
671
|
# Various constants for use in File and IO methods may be found in module
|
|
671
672
|
# File::Constants; an array of their names is returned by
|
|
672
|
-
#
|
|
673
|
+
# <code>File::Constants.constants</code>.
|
|
673
674
|
#
|
|
674
675
|
# ## What's Here
|
|
675
676
|
#
|
|
@@ -705,7 +706,7 @@
|
|
|
705
706
|
# * ::basename: Returns the last component of the given file path.
|
|
706
707
|
# * ::dirname: Returns all but the last component of the given file path.
|
|
707
708
|
# * ::expand_path: Returns the absolute file path for the given path,
|
|
708
|
-
# expanding
|
|
709
|
+
# expanding <code>~</code> for a home directory.
|
|
709
710
|
# * ::extname: Returns the file extension for the given file path.
|
|
710
711
|
# * ::fnmatch? (aliased as ::fnmatch): Returns whether the given file path
|
|
711
712
|
# matches the given pattern.
|
|
@@ -847,7 +848,30 @@ class File < IO
|
|
|
847
848
|
# * [Open Options](rdoc-ref:IO@Open+Options).
|
|
848
849
|
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
|
849
850
|
#
|
|
850
|
-
def initialize: (
|
|
851
|
+
def initialize: (
|
|
852
|
+
path | int file_name,
|
|
853
|
+
?string | int mode,
|
|
854
|
+
?int perm,
|
|
855
|
+
# open options
|
|
856
|
+
?mode: Integer | String,
|
|
857
|
+
?flags: Integer,
|
|
858
|
+
?external_encoding: encoding,
|
|
859
|
+
?internal_encoding: encoding,
|
|
860
|
+
?encoding: encoding,
|
|
861
|
+
?textmode: boolish,
|
|
862
|
+
?binmode: boolish,
|
|
863
|
+
?autoclose: boolish,
|
|
864
|
+
?path: path,
|
|
865
|
+
# encoding options
|
|
866
|
+
?invalid: :replace | nil,
|
|
867
|
+
?undef: :replace | nil,
|
|
868
|
+
?replace: String | nil,
|
|
869
|
+
?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
|
|
870
|
+
?xml: :text | :attr | nil,
|
|
871
|
+
?cr_newline: bool,
|
|
872
|
+
?crlf_newline: bool,
|
|
873
|
+
?universal_newline: bool
|
|
874
|
+
) -> void
|
|
851
875
|
|
|
852
876
|
# <!--
|
|
853
877
|
# rdoc-file=file.c
|
|
@@ -856,12 +880,12 @@ class File < IO
|
|
|
856
880
|
# Converts a pathname to an absolute pathname. Relative paths are referenced
|
|
857
881
|
# from the current working directory of the process unless *dir_string* is
|
|
858
882
|
# given, in which case it will be used as the starting point. If the given
|
|
859
|
-
# pathname starts with a
|
|
860
|
-
# directory name.
|
|
883
|
+
# pathname starts with a ``<code>~</code>'' it is NOT expanded, it is treated as
|
|
884
|
+
# a normal directory name.
|
|
861
885
|
#
|
|
862
886
|
# File.absolute_path("~oracle/bin") #=> "<relative_path>/~oracle/bin"
|
|
863
887
|
#
|
|
864
|
-
def self.absolute_path: (
|
|
888
|
+
def self.absolute_path: (path file_name, ?path dir_string) -> String
|
|
865
889
|
|
|
866
890
|
# <!--
|
|
867
891
|
# rdoc-file=file.c
|
|
@@ -871,7 +895,7 @@ class File < IO
|
|
|
871
895
|
#
|
|
872
896
|
# File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
|
|
873
897
|
#
|
|
874
|
-
def self.absolute_path?: (
|
|
898
|
+
def self.absolute_path?: (path file_name) -> bool
|
|
875
899
|
|
|
876
900
|
# <!--
|
|
877
901
|
# rdoc-file=file.c
|
|
@@ -883,7 +907,7 @@ class File < IO
|
|
|
883
907
|
#
|
|
884
908
|
# File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003
|
|
885
909
|
#
|
|
886
|
-
def self.atime: (
|
|
910
|
+
def self.atime: (path | IO file_name) -> Time
|
|
887
911
|
|
|
888
912
|
# <!--
|
|
889
913
|
# rdoc-file=file.c
|
|
@@ -899,7 +923,7 @@ class File < IO
|
|
|
899
923
|
# File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
|
|
900
924
|
# File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby"
|
|
901
925
|
#
|
|
902
|
-
def self.basename: (
|
|
926
|
+
def self.basename: (path file_name, ?string suffix) -> String
|
|
903
927
|
|
|
904
928
|
# <!--
|
|
905
929
|
# rdoc-file=file.c
|
|
@@ -913,7 +937,7 @@ class File < IO
|
|
|
913
937
|
#
|
|
914
938
|
# If the platform doesn't have birthtime, raises NotImplementedError.
|
|
915
939
|
#
|
|
916
|
-
def self.birthtime: (
|
|
940
|
+
def self.birthtime: (path | IO file_name) -> Time
|
|
917
941
|
|
|
918
942
|
# <!--
|
|
919
943
|
# rdoc-file=file.c
|
|
@@ -924,7 +948,7 @@ class File < IO
|
|
|
924
948
|
# File.blockdev?('/dev/sda1') # => true
|
|
925
949
|
# File.blockdev?(File.new('t.tmp')) # => false
|
|
926
950
|
#
|
|
927
|
-
def self.blockdev?: (
|
|
951
|
+
def self.blockdev?: (path | IO file_name) -> bool
|
|
928
952
|
|
|
929
953
|
# <!--
|
|
930
954
|
# rdoc-file=file.c
|
|
@@ -935,7 +959,7 @@ class File < IO
|
|
|
935
959
|
# File.chardev?($stdin) # => true
|
|
936
960
|
# File.chardev?('t.txt') # => false
|
|
937
961
|
#
|
|
938
|
-
def self.chardev?: (
|
|
962
|
+
def self.chardev?: (path | IO file_name) -> bool
|
|
939
963
|
|
|
940
964
|
# <!--
|
|
941
965
|
# rdoc-file=file.c
|
|
@@ -943,12 +967,12 @@ class File < IO
|
|
|
943
967
|
# -->
|
|
944
968
|
# Changes permission bits on the named file(s) to the bit pattern represented by
|
|
945
969
|
# *mode_int*. Actual effects are operating system dependent (see the beginning
|
|
946
|
-
# of this section). On Unix systems, see
|
|
947
|
-
# number of files processed.
|
|
970
|
+
# of this section). On Unix systems, see <code>chmod(2)</code> for details.
|
|
971
|
+
# Returns the number of files processed.
|
|
948
972
|
#
|
|
949
973
|
# File.chmod(0644, "testfile", "out") #=> 2
|
|
950
974
|
#
|
|
951
|
-
def self.chmod: (int mode, *
|
|
975
|
+
def self.chmod: (int mode, *path file_name) -> Integer
|
|
952
976
|
|
|
953
977
|
# <!--
|
|
954
978
|
# rdoc-file=file.c
|
|
@@ -962,7 +986,7 @@ class File < IO
|
|
|
962
986
|
#
|
|
963
987
|
# File.chown(nil, 100, "testfile")
|
|
964
988
|
#
|
|
965
|
-
def self.chown: (int? owner, int? group, *
|
|
989
|
+
def self.chown: (int? owner, int? group, *path file_name) -> Integer
|
|
966
990
|
|
|
967
991
|
# <!--
|
|
968
992
|
# rdoc-file=file.c
|
|
@@ -977,7 +1001,7 @@ class File < IO
|
|
|
977
1001
|
#
|
|
978
1002
|
# File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
|
|
979
1003
|
#
|
|
980
|
-
def self.ctime: (
|
|
1004
|
+
def self.ctime: (path | IO file_name) -> Time
|
|
981
1005
|
|
|
982
1006
|
# <!--
|
|
983
1007
|
# rdoc-file=file.c
|
|
@@ -986,9 +1010,9 @@ class File < IO
|
|
|
986
1010
|
# -->
|
|
987
1011
|
# Deletes the named files, returning the number of names passed as arguments.
|
|
988
1012
|
# Raises an exception on any error. Since the underlying implementation relies
|
|
989
|
-
# on the
|
|
990
|
-
# error type (see https://linux.die.net/man/2/unlink) and has the
|
|
991
|
-
# Errno::ENOENT.
|
|
1013
|
+
# on the <code>unlink(2)</code> system call, the type of exception raised
|
|
1014
|
+
# depends on its error type (see https://linux.die.net/man/2/unlink) and has the
|
|
1015
|
+
# form of e.g. Errno::ENOENT.
|
|
992
1016
|
#
|
|
993
1017
|
# See also Dir::rmdir.
|
|
994
1018
|
#
|
|
@@ -1010,7 +1034,7 @@ class File < IO
|
|
|
1010
1034
|
#
|
|
1011
1035
|
# Argument `path` can be an IO object.
|
|
1012
1036
|
#
|
|
1013
|
-
def self.directory?: (
|
|
1037
|
+
def self.directory?: (path | IO path) -> bool
|
|
1014
1038
|
|
|
1015
1039
|
# <!--
|
|
1016
1040
|
# rdoc-file=file.c
|
|
@@ -1028,7 +1052,7 @@ class File < IO
|
|
|
1028
1052
|
# File.dirname("/home/gumby/work/ruby.rb", 2) #=> "/home/gumby"
|
|
1029
1053
|
# File.dirname("/home/gumby/work/ruby.rb", 4) #=> "/"
|
|
1030
1054
|
#
|
|
1031
|
-
def self.dirname: (
|
|
1055
|
+
def self.dirname: (path file_name, ?Integer level) -> String
|
|
1032
1056
|
|
|
1033
1057
|
# <!--
|
|
1034
1058
|
# rdoc-file=file.c
|
|
@@ -1054,7 +1078,7 @@ class File < IO
|
|
|
1054
1078
|
# Note that some OS-level security features may cause this to return true even
|
|
1055
1079
|
# though the file is not executable by the effective user/group.
|
|
1056
1080
|
#
|
|
1057
|
-
def self.executable?: (
|
|
1081
|
+
def self.executable?: (path file_name) -> bool
|
|
1058
1082
|
|
|
1059
1083
|
# <!--
|
|
1060
1084
|
# rdoc-file=file.c
|
|
@@ -1070,7 +1094,7 @@ class File < IO
|
|
|
1070
1094
|
# Note that some OS-level security features may cause this to return true even
|
|
1071
1095
|
# though the file is not executable by the real user/group.
|
|
1072
1096
|
#
|
|
1073
|
-
def self.executable_real?: (
|
|
1097
|
+
def self.executable_real?: (path file_name) -> bool
|
|
1074
1098
|
|
|
1075
1099
|
# <!--
|
|
1076
1100
|
# rdoc-file=file.c
|
|
@@ -1082,7 +1106,7 @@ class File < IO
|
|
|
1082
1106
|
#
|
|
1083
1107
|
# "file exists" means that stat() or fstat() system call is successful.
|
|
1084
1108
|
#
|
|
1085
|
-
def self.exist?: (
|
|
1109
|
+
def self.exist?: (path | IO file_name) -> bool
|
|
1086
1110
|
|
|
1087
1111
|
# <!--
|
|
1088
1112
|
# rdoc-file=file.c
|
|
@@ -1091,9 +1115,9 @@ class File < IO
|
|
|
1091
1115
|
# Converts a pathname to an absolute pathname. Relative paths are referenced
|
|
1092
1116
|
# from the current working directory of the process unless `dir_string` is
|
|
1093
1117
|
# given, in which case it will be used as the starting point. The given pathname
|
|
1094
|
-
# may start with a
|
|
1095
|
-
# (the environment variable `HOME` must be set correctly).
|
|
1096
|
-
# to the named user's home directory.
|
|
1118
|
+
# may start with a ``<code>~</code>'', which expands to the process owner's home
|
|
1119
|
+
# directory (the environment variable `HOME` must be set correctly).
|
|
1120
|
+
# ``<code>~</code>*user*'' expands to the named user's home directory.
|
|
1097
1121
|
#
|
|
1098
1122
|
# File.expand_path("~oracle/bin") #=> "/home/oracle/bin"
|
|
1099
1123
|
#
|
|
@@ -1107,9 +1131,9 @@ class File < IO
|
|
|
1107
1131
|
# #=> ".../path/to/project/lib/mygem.rb"
|
|
1108
1132
|
#
|
|
1109
1133
|
# So first it resolves the parent of __FILE__, that is bin/, then go to the
|
|
1110
|
-
# parent, the root of the project and appends
|
|
1134
|
+
# parent, the root of the project and appends <code>lib/mygem.rb</code>.
|
|
1111
1135
|
#
|
|
1112
|
-
def self.expand_path: (
|
|
1136
|
+
def self.expand_path: (path file_name, ?path dir_string) -> String
|
|
1113
1137
|
|
|
1114
1138
|
# <!--
|
|
1115
1139
|
# rdoc-file=file.c
|
|
@@ -1135,7 +1159,7 @@ class File < IO
|
|
|
1135
1159
|
# File.extname(".profile") #=> ""
|
|
1136
1160
|
# File.extname(".profile.sh") #=> ".sh"
|
|
1137
1161
|
#
|
|
1138
|
-
def self.extname: (
|
|
1162
|
+
def self.extname: (path path) -> String
|
|
1139
1163
|
|
|
1140
1164
|
# <!--
|
|
1141
1165
|
# rdoc-file=file.c
|
|
@@ -1148,7 +1172,7 @@ class File < IO
|
|
|
1148
1172
|
# If the `file` argument is a symbolic link, it will resolve the symbolic link
|
|
1149
1173
|
# and use the file referenced by the link.
|
|
1150
1174
|
#
|
|
1151
|
-
def self.file?: (
|
|
1175
|
+
def self.file?: (path | IO file) -> bool
|
|
1152
1176
|
|
|
1153
1177
|
# <!--
|
|
1154
1178
|
# rdoc-file=dir.rb
|
|
@@ -1159,48 +1183,48 @@ class File < IO
|
|
|
1159
1183
|
# regular expression; instead it follows rules similar to shell filename
|
|
1160
1184
|
# globbing. It may contain the following metacharacters:
|
|
1161
1185
|
#
|
|
1162
|
-
#
|
|
1186
|
+
# <code>*</code>
|
|
1163
1187
|
# : Matches any file. Can be restricted by other values in the glob.
|
|
1164
|
-
# Equivalent to
|
|
1188
|
+
# Equivalent to <code>/.*/x</code> in regexp.
|
|
1165
1189
|
#
|
|
1166
|
-
#
|
|
1190
|
+
# <code>*</code>
|
|
1167
1191
|
# : Matches all regular files
|
|
1168
1192
|
#
|
|
1169
|
-
#
|
|
1193
|
+
# <code>c*</code>
|
|
1170
1194
|
# : Matches all files beginning with `c`
|
|
1171
1195
|
#
|
|
1172
|
-
#
|
|
1196
|
+
# <code>*c</code>
|
|
1173
1197
|
# : Matches all files ending with `c`
|
|
1174
1198
|
#
|
|
1175
|
-
#
|
|
1199
|
+
# <code>*c*</code>
|
|
1176
1200
|
# : Matches all files that have `c` in them (including at the beginning or
|
|
1177
1201
|
# end).
|
|
1178
1202
|
#
|
|
1179
1203
|
#
|
|
1180
|
-
# To match hidden files (that start with a
|
|
1181
|
-
# flag.
|
|
1204
|
+
# To match hidden files (that start with a <code>.</code>) set the
|
|
1205
|
+
# File::FNM_DOTMATCH flag.
|
|
1182
1206
|
#
|
|
1183
1207
|
#
|
|
1184
|
-
#
|
|
1208
|
+
# <code>**</code>
|
|
1185
1209
|
# : Matches directories recursively or files expansively.
|
|
1186
1210
|
#
|
|
1187
1211
|
#
|
|
1188
|
-
#
|
|
1189
|
-
# : Matches any one character. Equivalent to
|
|
1212
|
+
# <code>?</code>
|
|
1213
|
+
# : Matches any one character. Equivalent to <code>/.{1}/</code> in regexp.
|
|
1190
1214
|
#
|
|
1191
1215
|
#
|
|
1192
|
-
#
|
|
1216
|
+
# <code>[set]</code>
|
|
1193
1217
|
# : Matches any one character in `set`. Behaves exactly like character sets
|
|
1194
|
-
# in Regexp, including set negation (
|
|
1218
|
+
# in Regexp, including set negation (<code>[^a-z]</code>).
|
|
1195
1219
|
#
|
|
1196
1220
|
#
|
|
1197
|
-
#
|
|
1221
|
+
# <code>\</code>
|
|
1198
1222
|
# : Escapes the next metacharacter.
|
|
1199
1223
|
#
|
|
1200
1224
|
#
|
|
1201
|
-
#
|
|
1225
|
+
# <code>{a,b}</code>
|
|
1202
1226
|
# : Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled.
|
|
1203
|
-
# Behaves like a Regexp union (
|
|
1227
|
+
# Behaves like a Regexp union (<code>(?:a|b)</code>).
|
|
1204
1228
|
#
|
|
1205
1229
|
#
|
|
1206
1230
|
# `flags` is a bitwise OR of the `FNM_XXX` constants. The same glob pattern and
|
|
@@ -1252,7 +1276,7 @@ class File < IO
|
|
|
1252
1276
|
# File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
|
|
1253
1277
|
# File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
|
|
1254
1278
|
#
|
|
1255
|
-
def self.fnmatch: (string pattern,
|
|
1279
|
+
def self.fnmatch: (string pattern, path path, ?int flags) -> bool
|
|
1256
1280
|
|
|
1257
1281
|
# <!--
|
|
1258
1282
|
# rdoc-file=dir.rb
|
|
@@ -1273,7 +1297,7 @@ class File < IO
|
|
|
1273
1297
|
# File.ftype("/dev/tty") #=> "characterSpecial"
|
|
1274
1298
|
# File.ftype("/tmp/.X11-unix/X0") #=> "socket"
|
|
1275
1299
|
#
|
|
1276
|
-
def self.ftype: (
|
|
1300
|
+
def self.ftype: (path file_name) -> String
|
|
1277
1301
|
|
|
1278
1302
|
# <!--
|
|
1279
1303
|
# rdoc-file=file.c
|
|
@@ -1284,7 +1308,7 @@ class File < IO
|
|
|
1284
1308
|
#
|
|
1285
1309
|
# *file_name* can be an IO object.
|
|
1286
1310
|
#
|
|
1287
|
-
def self.grpowned?: (
|
|
1311
|
+
def self.grpowned?: (path | IO file_name) -> bool
|
|
1288
1312
|
|
|
1289
1313
|
# <!--
|
|
1290
1314
|
# rdoc-file=file.c
|
|
@@ -1304,13 +1328,13 @@ class File < IO
|
|
|
1304
1328
|
# open("d", "w") {}
|
|
1305
1329
|
# p File.identical?("a", "d") #=> false
|
|
1306
1330
|
#
|
|
1307
|
-
def self.identical?: (
|
|
1331
|
+
def self.identical?: (path | IO file_1, path | IO file_2) -> bool
|
|
1308
1332
|
|
|
1309
1333
|
# <!--
|
|
1310
1334
|
# rdoc-file=file.c
|
|
1311
1335
|
# - File.join(string, ...) -> string
|
|
1312
1336
|
# -->
|
|
1313
|
-
# Returns a new string formed by joining the strings using
|
|
1337
|
+
# Returns a new string formed by joining the strings using <code>"/"</code>.
|
|
1314
1338
|
#
|
|
1315
1339
|
# File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
|
|
1316
1340
|
#
|
|
@@ -1324,7 +1348,7 @@ class File < IO
|
|
|
1324
1348
|
# change the permissions associated with the link, not the file referenced by
|
|
1325
1349
|
# the link). Often not available.
|
|
1326
1350
|
#
|
|
1327
|
-
def self.lchmod: (int mode, *
|
|
1351
|
+
def self.lchmod: (int mode, *path file_name) -> Integer
|
|
1328
1352
|
|
|
1329
1353
|
# <!--
|
|
1330
1354
|
# rdoc-file=file.c
|
|
@@ -1334,7 +1358,7 @@ class File < IO
|
|
|
1334
1358
|
# change the owner associated with the link, not the file referenced by the
|
|
1335
1359
|
# link). Often not available. Returns number of files in the argument list.
|
|
1336
1360
|
#
|
|
1337
|
-
def self.lchown: (int? owner, int? group, *
|
|
1361
|
+
def self.lchown: (int? owner, int? group, *path file_name) -> Integer
|
|
1338
1362
|
|
|
1339
1363
|
# <!--
|
|
1340
1364
|
# rdoc-file=file.c
|
|
@@ -1347,7 +1371,7 @@ class File < IO
|
|
|
1347
1371
|
# File.link("testfile", ".testfile") #=> 0
|
|
1348
1372
|
# IO.readlines(".testfile")[0] #=> "This is line one\n"
|
|
1349
1373
|
#
|
|
1350
|
-
def self.link: (
|
|
1374
|
+
def self.link: (path old_name, path new_name) -> 0
|
|
1351
1375
|
|
|
1352
1376
|
# <!--
|
|
1353
1377
|
# rdoc-file=file.c
|
|
@@ -1360,7 +1384,7 @@ class File < IO
|
|
|
1360
1384
|
# File.stat('symlink').size # => 47
|
|
1361
1385
|
# File.lstat('symlink').size # => 5
|
|
1362
1386
|
#
|
|
1363
|
-
def self.lstat: (
|
|
1387
|
+
def self.lstat: (path file_name) -> File::Stat
|
|
1364
1388
|
|
|
1365
1389
|
# <!--
|
|
1366
1390
|
# rdoc-file=file.c
|
|
@@ -1371,7 +1395,7 @@ class File < IO
|
|
|
1371
1395
|
# opposed to its referent; for the inverse behavior, see File.utime. Returns the
|
|
1372
1396
|
# number of file names in the argument list.
|
|
1373
1397
|
#
|
|
1374
|
-
def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *
|
|
1398
|
+
def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
|
|
1375
1399
|
|
|
1376
1400
|
# <!--
|
|
1377
1401
|
# rdoc-file=file.c
|
|
@@ -1381,7 +1405,7 @@ class File < IO
|
|
|
1381
1405
|
# FIFO's permissions. It is modified by the process's umask in the usual way:
|
|
1382
1406
|
# the permissions of the created file are (mode & ~umask).
|
|
1383
1407
|
#
|
|
1384
|
-
def self.mkfifo: (
|
|
1408
|
+
def self.mkfifo: (path file_name, ?int mode) -> 0
|
|
1385
1409
|
|
|
1386
1410
|
# <!--
|
|
1387
1411
|
# rdoc-file=file.c
|
|
@@ -1393,7 +1417,7 @@ class File < IO
|
|
|
1393
1417
|
#
|
|
1394
1418
|
# File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
|
|
1395
1419
|
#
|
|
1396
|
-
def self.mtime: (
|
|
1420
|
+
def self.mtime: (path | IO file_name) -> Time
|
|
1397
1421
|
|
|
1398
1422
|
# <!--
|
|
1399
1423
|
# rdoc-file=io.c
|
|
@@ -1407,19 +1431,65 @@ class File < IO
|
|
|
1407
1431
|
# With a block given, calls the block with the File object and returns the
|
|
1408
1432
|
# block's value.
|
|
1409
1433
|
#
|
|
1410
|
-
def self.open: (
|
|
1411
|
-
|
|
1434
|
+
def self.open: (
|
|
1435
|
+
path | int file_name,
|
|
1436
|
+
?string | int mode,
|
|
1437
|
+
?int perm,
|
|
1438
|
+
# open options
|
|
1439
|
+
?mode: Integer | String,
|
|
1440
|
+
?flags: Integer,
|
|
1441
|
+
?external_encoding: encoding,
|
|
1442
|
+
?internal_encoding: encoding,
|
|
1443
|
+
?encoding: encoding,
|
|
1444
|
+
?textmode: boolish,
|
|
1445
|
+
?binmode: boolish,
|
|
1446
|
+
?autoclose: boolish,
|
|
1447
|
+
?path: path,
|
|
1448
|
+
# encoding options
|
|
1449
|
+
?invalid: :replace | nil,
|
|
1450
|
+
?undef: :replace | nil,
|
|
1451
|
+
?replace: String | nil,
|
|
1452
|
+
?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
|
|
1453
|
+
?xml: :text | :attr | nil,
|
|
1454
|
+
?cr_newline: bool,
|
|
1455
|
+
?crlf_newline: bool,
|
|
1456
|
+
?universal_newline: bool
|
|
1457
|
+
) -> instance
|
|
1458
|
+
| [T] (
|
|
1459
|
+
path | int file_name,
|
|
1460
|
+
?string | int mode,
|
|
1461
|
+
?int perm,
|
|
1462
|
+
# open options
|
|
1463
|
+
?mode: Integer | String,
|
|
1464
|
+
?flags: Integer,
|
|
1465
|
+
?external_encoding: encoding,
|
|
1466
|
+
?internal_encoding: encoding,
|
|
1467
|
+
?encoding: encoding,
|
|
1468
|
+
?textmode: boolish,
|
|
1469
|
+
?binmode: boolish,
|
|
1470
|
+
?autoclose: boolish,
|
|
1471
|
+
?path: path,
|
|
1472
|
+
# encoding options
|
|
1473
|
+
?invalid: :replace | nil,
|
|
1474
|
+
?undef: :replace | nil,
|
|
1475
|
+
?replace: String | nil,
|
|
1476
|
+
?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
|
|
1477
|
+
?xml: :text | :attr | nil,
|
|
1478
|
+
?cr_newline: bool,
|
|
1479
|
+
?crlf_newline: bool,
|
|
1480
|
+
?universal_newline: bool
|
|
1481
|
+
) { (File) -> T } -> T
|
|
1412
1482
|
|
|
1413
1483
|
# <!--
|
|
1414
1484
|
# rdoc-file=file.c
|
|
1415
1485
|
# - File.owned?(file_name) -> true or false
|
|
1416
1486
|
# -->
|
|
1417
|
-
# Returns `true` if the named file exists and the effective
|
|
1487
|
+
# Returns `true` if the named file exists and the effective user id of the
|
|
1418
1488
|
# calling process is the owner of the file.
|
|
1419
1489
|
#
|
|
1420
1490
|
# *file_name* can be an IO object.
|
|
1421
1491
|
#
|
|
1422
|
-
def self.owned?: (
|
|
1492
|
+
def self.owned?: (path | IO file_name) -> bool
|
|
1423
1493
|
|
|
1424
1494
|
# <!--
|
|
1425
1495
|
# rdoc-file=file.c
|
|
@@ -1427,10 +1497,27 @@ class File < IO
|
|
|
1427
1497
|
# -->
|
|
1428
1498
|
# Returns the string representation of the path
|
|
1429
1499
|
#
|
|
1430
|
-
#
|
|
1431
|
-
#
|
|
1500
|
+
# File.path(File::NULL) #=> "/dev/null"
|
|
1501
|
+
# File.path(Pathname.new("/tmp")) #=> "/tmp"
|
|
1502
|
+
#
|
|
1503
|
+
# If `path` is not a String:
|
|
1504
|
+
#
|
|
1505
|
+
# 1. If it has the `to_path` method, that method will be called to coerce to a
|
|
1506
|
+
# String.
|
|
1507
|
+
#
|
|
1508
|
+
# 2. Otherwise, or if the coerced result is not a String too, the standard
|
|
1509
|
+
# coersion using `to_str` method will take place on that object. (See also
|
|
1510
|
+
# String.try_convert)
|
|
1511
|
+
#
|
|
1512
|
+
# The coerced string must satisfy the following conditions:
|
|
1513
|
+
#
|
|
1514
|
+
# 1. It must be in an ASCII-compatible encoding; otherwise, an
|
|
1515
|
+
# Encoding::CompatibilityError is raised.
|
|
1432
1516
|
#
|
|
1433
|
-
|
|
1517
|
+
# 2. It must not contain the NUL character (<code>\0</code>); otherwise, an
|
|
1518
|
+
# ArgumentError is raised.
|
|
1519
|
+
#
|
|
1520
|
+
def self.path: (path path) -> String
|
|
1434
1521
|
|
|
1435
1522
|
# <!--
|
|
1436
1523
|
# rdoc-file=file.c
|
|
@@ -1442,7 +1529,7 @@ class File < IO
|
|
|
1442
1529
|
# File.pipe?('tmp/fifo') # => true
|
|
1443
1530
|
# File.pipe?('t.txt') # => false
|
|
1444
1531
|
#
|
|
1445
|
-
def self.pipe?: (
|
|
1532
|
+
def self.pipe?: (path | IO file_name) -> bool
|
|
1446
1533
|
|
|
1447
1534
|
# <!--
|
|
1448
1535
|
# rdoc-file=file.c
|
|
@@ -1454,7 +1541,7 @@ class File < IO
|
|
|
1454
1541
|
# Note that some OS-level security features may cause this to return true even
|
|
1455
1542
|
# though the file is not readable by the effective user/group.
|
|
1456
1543
|
#
|
|
1457
|
-
def self.readable?: (
|
|
1544
|
+
def self.readable?: (path file_name) -> bool
|
|
1458
1545
|
|
|
1459
1546
|
# <!--
|
|
1460
1547
|
# rdoc-file=file.c
|
|
@@ -1466,7 +1553,7 @@ class File < IO
|
|
|
1466
1553
|
# Note that some OS-level security features may cause this to return true even
|
|
1467
1554
|
# though the file is not readable by the real user/group.
|
|
1468
1555
|
#
|
|
1469
|
-
def self.readable_real?: (
|
|
1556
|
+
def self.readable_real?: (path file_name) -> bool
|
|
1470
1557
|
|
|
1471
1558
|
# <!--
|
|
1472
1559
|
# rdoc-file=file.c
|
|
@@ -1478,7 +1565,7 @@ class File < IO
|
|
|
1478
1565
|
# File.symlink("testfile", "link2test") #=> 0
|
|
1479
1566
|
# File.readlink("link2test") #=> "testfile"
|
|
1480
1567
|
#
|
|
1481
|
-
def self.readlink: (
|
|
1568
|
+
def self.readlink: (path link_name) -> String
|
|
1482
1569
|
|
|
1483
1570
|
# <!--
|
|
1484
1571
|
# rdoc-file=file.c
|
|
@@ -1492,7 +1579,7 @@ class File < IO
|
|
|
1492
1579
|
#
|
|
1493
1580
|
# The last component of the real pathname can be nonexistent.
|
|
1494
1581
|
#
|
|
1495
|
-
def self.realdirpath: (
|
|
1582
|
+
def self.realdirpath: (path pathname, ?path dir_string) -> String
|
|
1496
1583
|
|
|
1497
1584
|
# <!--
|
|
1498
1585
|
# rdoc-file=file.c
|
|
@@ -1506,7 +1593,7 @@ class File < IO
|
|
|
1506
1593
|
#
|
|
1507
1594
|
# All components of the pathname must exist when this method is called.
|
|
1508
1595
|
#
|
|
1509
|
-
def self.realpath: (
|
|
1596
|
+
def self.realpath: (path pathname, ?path dir_string) -> String
|
|
1510
1597
|
|
|
1511
1598
|
# <!--
|
|
1512
1599
|
# rdoc-file=file.c
|
|
@@ -1517,7 +1604,7 @@ class File < IO
|
|
|
1517
1604
|
#
|
|
1518
1605
|
# File.rename("afile", "afile.bak") #=> 0
|
|
1519
1606
|
#
|
|
1520
|
-
def self.rename: (
|
|
1607
|
+
def self.rename: (path old_name, path new_name) -> 0
|
|
1521
1608
|
|
|
1522
1609
|
# <!--
|
|
1523
1610
|
# rdoc-file=file.c
|
|
@@ -1527,7 +1614,7 @@ class File < IO
|
|
|
1527
1614
|
#
|
|
1528
1615
|
# *file_name* can be an IO object.
|
|
1529
1616
|
#
|
|
1530
|
-
def self.setgid?: (
|
|
1617
|
+
def self.setgid?: (path | IO file_name) -> bool
|
|
1531
1618
|
|
|
1532
1619
|
# <!--
|
|
1533
1620
|
# rdoc-file=file.c
|
|
@@ -1537,7 +1624,7 @@ class File < IO
|
|
|
1537
1624
|
#
|
|
1538
1625
|
# *file_name* can be an IO object.
|
|
1539
1626
|
#
|
|
1540
|
-
def self.setuid?: (
|
|
1627
|
+
def self.setuid?: (path | IO file_name) -> bool
|
|
1541
1628
|
|
|
1542
1629
|
# <!--
|
|
1543
1630
|
# rdoc-file=file.c
|
|
@@ -1547,7 +1634,7 @@ class File < IO
|
|
|
1547
1634
|
#
|
|
1548
1635
|
# *file_name* can be an IO object.
|
|
1549
1636
|
#
|
|
1550
|
-
def self.size: (
|
|
1637
|
+
def self.size: (path | IO file_name) -> Integer
|
|
1551
1638
|
|
|
1552
1639
|
# <!--
|
|
1553
1640
|
# rdoc-file=file.c
|
|
@@ -1558,7 +1645,7 @@ class File < IO
|
|
|
1558
1645
|
#
|
|
1559
1646
|
# *file_name* can be an IO object.
|
|
1560
1647
|
#
|
|
1561
|
-
def self.size?: (
|
|
1648
|
+
def self.size?: (path | IO file_name) -> Integer?
|
|
1562
1649
|
|
|
1563
1650
|
# <!--
|
|
1564
1651
|
# rdoc-file=file.c
|
|
@@ -1570,7 +1657,7 @@ class File < IO
|
|
|
1570
1657
|
# File.socket?(Socket.new(:INET, :STREAM)) # => true
|
|
1571
1658
|
# File.socket?(File.new('t.txt')) # => false
|
|
1572
1659
|
#
|
|
1573
|
-
def self.socket?: (
|
|
1660
|
+
def self.socket?: (path | IO file_name) -> bool
|
|
1574
1661
|
|
|
1575
1662
|
# <!--
|
|
1576
1663
|
# rdoc-file=file.c
|
|
@@ -1581,7 +1668,7 @@ class File < IO
|
|
|
1581
1668
|
#
|
|
1582
1669
|
# File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
|
|
1583
1670
|
#
|
|
1584
|
-
def self.split: (
|
|
1671
|
+
def self.split: (path file_name) -> [ String, String ]
|
|
1585
1672
|
|
|
1586
1673
|
# <!--
|
|
1587
1674
|
# rdoc-file=file.c
|
|
@@ -1591,7 +1678,7 @@ class File < IO
|
|
|
1591
1678
|
#
|
|
1592
1679
|
# File.stat('t.txt').class # => File::Stat
|
|
1593
1680
|
#
|
|
1594
|
-
def self.stat: (
|
|
1681
|
+
def self.stat: (path file_name) -> File::Stat
|
|
1595
1682
|
|
|
1596
1683
|
# <!--
|
|
1597
1684
|
# rdoc-file=file.c
|
|
@@ -1601,7 +1688,7 @@ class File < IO
|
|
|
1601
1688
|
#
|
|
1602
1689
|
# *file_name* can be an IO object.
|
|
1603
1690
|
#
|
|
1604
|
-
def self.sticky?: (
|
|
1691
|
+
def self.sticky?: (path | IO file_name) -> bool
|
|
1605
1692
|
|
|
1606
1693
|
# <!--
|
|
1607
1694
|
# rdoc-file=file.c
|
|
@@ -1613,7 +1700,7 @@ class File < IO
|
|
|
1613
1700
|
#
|
|
1614
1701
|
# File.symlink("testfile", "link2test") #=> 0
|
|
1615
1702
|
#
|
|
1616
|
-
def self.symlink: (
|
|
1703
|
+
def self.symlink: (path old_name, path new_name) -> 0
|
|
1617
1704
|
|
|
1618
1705
|
# <!--
|
|
1619
1706
|
# rdoc-file=file.c
|
|
@@ -1625,7 +1712,7 @@ class File < IO
|
|
|
1625
1712
|
# File.symlink?('symlink') # => true
|
|
1626
1713
|
# File.symlink?('t.txt') # => false
|
|
1627
1714
|
#
|
|
1628
|
-
def self.symlink?: (
|
|
1715
|
+
def self.symlink?: (path file_name) -> bool
|
|
1629
1716
|
|
|
1630
1717
|
# <!--
|
|
1631
1718
|
# rdoc-file=file.c
|
|
@@ -1640,7 +1727,7 @@ class File < IO
|
|
|
1640
1727
|
# File.truncate("out", 5) #=> 0
|
|
1641
1728
|
# File.size("out") #=> 5
|
|
1642
1729
|
#
|
|
1643
|
-
def self.truncate: (
|
|
1730
|
+
def self.truncate: (path file_name, int length) -> 0
|
|
1644
1731
|
|
|
1645
1732
|
# <!--
|
|
1646
1733
|
# rdoc-file=file.c
|
|
@@ -1664,13 +1751,13 @@ class File < IO
|
|
|
1664
1751
|
# -->
|
|
1665
1752
|
# Deletes the named files, returning the number of names passed as arguments.
|
|
1666
1753
|
# Raises an exception on any error. Since the underlying implementation relies
|
|
1667
|
-
# on the
|
|
1668
|
-
# error type (see https://linux.die.net/man/2/unlink) and has the
|
|
1669
|
-
# Errno::ENOENT.
|
|
1754
|
+
# on the <code>unlink(2)</code> system call, the type of exception raised
|
|
1755
|
+
# depends on its error type (see https://linux.die.net/man/2/unlink) and has the
|
|
1756
|
+
# form of e.g. Errno::ENOENT.
|
|
1670
1757
|
#
|
|
1671
1758
|
# See also Dir::rmdir.
|
|
1672
1759
|
#
|
|
1673
|
-
def self.unlink: (*
|
|
1760
|
+
def self.unlink: (*path file_name) -> Integer
|
|
1674
1761
|
|
|
1675
1762
|
# <!--
|
|
1676
1763
|
# rdoc-file=file.c
|
|
@@ -1681,7 +1768,7 @@ class File < IO
|
|
|
1681
1768
|
# than the link itself; for the inverse behavior see File.lutime. Returns the
|
|
1682
1769
|
# number of file names in the argument list.
|
|
1683
1770
|
#
|
|
1684
|
-
def self.utime: (Time | Numeric atime, Time | Numeric mtime, *
|
|
1771
|
+
def self.utime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
|
|
1685
1772
|
|
|
1686
1773
|
# <!--
|
|
1687
1774
|
# rdoc-file=file.c
|
|
@@ -1689,7 +1776,7 @@ class File < IO
|
|
|
1689
1776
|
# -->
|
|
1690
1777
|
# If *file_name* is readable by others, returns an integer representing the file
|
|
1691
1778
|
# permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
|
|
1692
|
-
# bits is platform dependent; on Unix systems, see
|
|
1779
|
+
# bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
|
|
1693
1780
|
#
|
|
1694
1781
|
# *file_name* can be an IO object.
|
|
1695
1782
|
#
|
|
@@ -1697,7 +1784,7 @@ class File < IO
|
|
|
1697
1784
|
# m = File.world_readable?("/etc/passwd")
|
|
1698
1785
|
# sprintf("%o", m) #=> "644"
|
|
1699
1786
|
#
|
|
1700
|
-
def self.world_readable?: (
|
|
1787
|
+
def self.world_readable?: (path | IO file_name) -> Integer?
|
|
1701
1788
|
|
|
1702
1789
|
# <!--
|
|
1703
1790
|
# rdoc-file=file.c
|
|
@@ -1705,7 +1792,7 @@ class File < IO
|
|
|
1705
1792
|
# -->
|
|
1706
1793
|
# If *file_name* is writable by others, returns an integer representing the file
|
|
1707
1794
|
# permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
|
|
1708
|
-
# bits is platform dependent; on Unix systems, see
|
|
1795
|
+
# bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
|
|
1709
1796
|
#
|
|
1710
1797
|
# *file_name* can be an IO object.
|
|
1711
1798
|
#
|
|
@@ -1713,7 +1800,7 @@ class File < IO
|
|
|
1713
1800
|
# m = File.world_writable?("/tmp")
|
|
1714
1801
|
# sprintf("%o", m) #=> "777"
|
|
1715
1802
|
#
|
|
1716
|
-
def self.world_writable?: (
|
|
1803
|
+
def self.world_writable?: (path | IO file_name) -> Integer?
|
|
1717
1804
|
|
|
1718
1805
|
# <!--
|
|
1719
1806
|
# rdoc-file=file.c
|
|
@@ -1725,7 +1812,7 @@ class File < IO
|
|
|
1725
1812
|
# Note that some OS-level security features may cause this to return true even
|
|
1726
1813
|
# though the file is not writable by the effective user/group.
|
|
1727
1814
|
#
|
|
1728
|
-
def self.writable?: (
|
|
1815
|
+
def self.writable?: (path file_name) -> bool
|
|
1729
1816
|
|
|
1730
1817
|
# <!--
|
|
1731
1818
|
# rdoc-file=file.c
|
|
@@ -1737,7 +1824,7 @@ class File < IO
|
|
|
1737
1824
|
# Note that some OS-level security features may cause this to return true even
|
|
1738
1825
|
# though the file is not writable by the real user/group.
|
|
1739
1826
|
#
|
|
1740
|
-
def self.writable_real?: (
|
|
1827
|
+
def self.writable_real?: (path file_name) -> bool
|
|
1741
1828
|
|
|
1742
1829
|
# <!--
|
|
1743
1830
|
# rdoc-file=file.c
|
|
@@ -1747,7 +1834,7 @@ class File < IO
|
|
|
1747
1834
|
#
|
|
1748
1835
|
# *file_name* can be an IO object.
|
|
1749
1836
|
#
|
|
1750
|
-
def self.zero?: (
|
|
1837
|
+
def self.zero?: (path | IO file_name) -> bool
|
|
1751
1838
|
|
|
1752
1839
|
# <!--
|
|
1753
1840
|
# rdoc-file=file.c
|
|
@@ -1778,7 +1865,8 @@ class File < IO
|
|
|
1778
1865
|
# -->
|
|
1779
1866
|
# Changes permission bits on *file* to the bit pattern represented by
|
|
1780
1867
|
# *mode_int*. Actual effects are platform dependent; on Unix systems, see
|
|
1781
|
-
#
|
|
1868
|
+
# <code>chmod(2)</code> for details. Follows symbolic links. Also see
|
|
1869
|
+
# File#lchmod.
|
|
1782
1870
|
#
|
|
1783
1871
|
# f = File.new("out", "w");
|
|
1784
1872
|
# f.chmod(0644) #=> 0
|
|
@@ -1816,18 +1904,18 @@ class File < IO
|
|
|
1816
1904
|
# rdoc-file=file.c
|
|
1817
1905
|
# - flock(locking_constant) -> 0 or false
|
|
1818
1906
|
# -->
|
|
1819
|
-
# Locks or unlocks file
|
|
1907
|
+
# Locks or unlocks file +self+ according to the given `locking_constant`,
|
|
1820
1908
|
# a bitwise OR of the values in the table below.
|
|
1821
1909
|
# Not available on all platforms.
|
|
1822
|
-
# Returns `false` if
|
|
1823
|
-
# blocked;
|
|
1910
|
+
# Returns `false` if <code>File::LOCK_NB</code> is specified and the operation
|
|
1911
|
+
# would have blocked;
|
|
1824
1912
|
# otherwise returns `0`.
|
|
1825
|
-
# Constant | Lock |
|
|
1826
|
-
#
|
|
1827
|
-
# +File::LOCK_EX+| Exclusive |
|
|
1828
|
-
# +File::LOCK_NB+|Non-blocking|No blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <
|
|
1829
|
-
# +File::LOCK_SH+| Shared |
|
|
1830
|
-
# +File::LOCK_UN+| Unlock |
|
|
1913
|
+
# Constant | Lock | Effect
|
|
1914
|
+
# ---------------|------------|------------------------------------------------------------------------------------------------------------------
|
|
1915
|
+
# +File::LOCK_EX+| Exclusive | Only one process may hold an exclusive lock for +self+ at a time.
|
|
1916
|
+
# +File::LOCK_NB+|Non-blocking|No blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <code>|</code>.
|
|
1917
|
+
# +File::LOCK_SH+| Shared | Multiple processes may each hold a shared lock for +self+ at the same time.
|
|
1918
|
+
# +File::LOCK_UN+| Unlock | Remove an existing lock held by this process.
|
|
1831
1919
|
# Example:
|
|
1832
1920
|
# # Update a counter using an exclusive lock.
|
|
1833
1921
|
# # Don't use File::WRONLY because it truncates the file.
|
|
@@ -1953,7 +2041,7 @@ File::SEPARATOR: String
|
|
|
1953
2041
|
File::Separator: String
|
|
1954
2042
|
|
|
1955
2043
|
# <!-- rdoc-file=file.c -->
|
|
1956
|
-
# Module
|
|
2044
|
+
# Module <code>File::Constants</code> defines file-related constants.
|
|
1957
2045
|
#
|
|
1958
2046
|
# There are two families of constants here:
|
|
1959
2047
|
#
|
|
@@ -2217,14 +2305,14 @@ File::Separator: String
|
|
|
2217
2305
|
#
|
|
2218
2306
|
# #### File::FNM_DOTMATCH
|
|
2219
2307
|
#
|
|
2220
|
-
# Flag File::FNM_DOTMATCH makes the
|
|
2221
|
-
#
|
|
2308
|
+
# Flag File::FNM_DOTMATCH makes the <code>'*'</code> pattern match a filename
|
|
2309
|
+
# starting with <code>'.'</code>.
|
|
2222
2310
|
#
|
|
2223
2311
|
# #### File::FNM_EXTGLOB
|
|
2224
2312
|
#
|
|
2225
|
-
# Flag File::FNM_EXTGLOB enables pattern
|
|
2226
|
-
# '*a*' and pattern '*b*'; behaves like a [regexp
|
|
2227
|
-
# (e.g.,
|
|
2313
|
+
# Flag File::FNM_EXTGLOB enables pattern <code>'{_a_,_b_}'</code>, which matches
|
|
2314
|
+
# pattern '*a*' and pattern '*b*'; behaves like a [regexp
|
|
2315
|
+
# union](rdoc-ref:Regexp.union) (e.g., <code>'(?:_a_|_b_)'</code>):
|
|
2228
2316
|
#
|
|
2229
2317
|
# pattern = '{LEGAL,BSDL}'
|
|
2230
2318
|
# Dir.glob(pattern) # => ["LEGAL", "BSDL"]
|
|
@@ -2233,12 +2321,13 @@ File::Separator: String
|
|
|
2233
2321
|
#
|
|
2234
2322
|
# #### File::FNM_NOESCAPE
|
|
2235
2323
|
#
|
|
2236
|
-
# Flag File::FNM_NOESCAPE disables
|
|
2324
|
+
# Flag File::FNM_NOESCAPE disables <code>'\'</code> escaping.
|
|
2237
2325
|
#
|
|
2238
2326
|
# #### File::FNM_PATHNAME
|
|
2239
2327
|
#
|
|
2240
|
-
# Flag File::FNM_PATHNAME specifies that patterns
|
|
2241
|
-
# the directory separator (the value of constant
|
|
2328
|
+
# Flag File::FNM_PATHNAME specifies that patterns <code>'*'</code> and
|
|
2329
|
+
# <code>'?'</code> do not match the directory separator (the value of constant
|
|
2330
|
+
# File::SEPARATOR).
|
|
2242
2331
|
#
|
|
2243
2332
|
# #### File::FNM_SHORTNAME
|
|
2244
2333
|
#
|
|
@@ -2257,8 +2346,8 @@ File::Separator: String
|
|
|
2257
2346
|
#
|
|
2258
2347
|
# Flag File::NULL contains the string value of the null device:
|
|
2259
2348
|
#
|
|
2260
|
-
# * On a Unix-like OS,
|
|
2261
|
-
# * On Windows,
|
|
2349
|
+
# * On a Unix-like OS, <code>'/dev/null'</code>.
|
|
2350
|
+
# * On Windows, <code>'NUL'</code>.
|
|
2262
2351
|
#
|
|
2263
2352
|
module File::Constants
|
|
2264
2353
|
end
|
|
@@ -2429,10 +2518,8 @@ class File::Stat < Object
|
|
|
2429
2518
|
|
|
2430
2519
|
# <!--
|
|
2431
2520
|
# rdoc-file=file.c
|
|
2432
|
-
# - new(
|
|
2521
|
+
# - File::Stat.new(file_name) -> stat
|
|
2433
2522
|
# -->
|
|
2434
|
-
# File::Stat.new(file_name) -> stat
|
|
2435
|
-
#
|
|
2436
2523
|
# Create a File::Stat object for the given file name (raising an exception if
|
|
2437
2524
|
# the file doesn't exist).
|
|
2438
2525
|
#
|
|
@@ -2440,16 +2527,31 @@ class File::Stat < Object
|
|
|
2440
2527
|
|
|
2441
2528
|
# <!--
|
|
2442
2529
|
# rdoc-file=file.c
|
|
2443
|
-
# -
|
|
2530
|
+
# - self <=> other -> -1, 0, 1, or nil
|
|
2444
2531
|
# -->
|
|
2445
|
-
# Compares
|
|
2532
|
+
# Compares `self` and `other`, by comparing their modification times; that is,
|
|
2533
|
+
# by comparing <code>self.mtime</code> and <code>other.mtime</code>.
|
|
2534
|
+
#
|
|
2535
|
+
# Returns:
|
|
2536
|
+
#
|
|
2537
|
+
# * <code>-1</code>, if <code>self.mtime</code> is earlier.
|
|
2538
|
+
# * `0`, if the two values are equal.
|
|
2539
|
+
# * `1`, if <code>self.mtime</code> is later.
|
|
2540
|
+
# * `nil`, if `other` is not a File::Stat object.
|
|
2541
|
+
#
|
|
2542
|
+
# Examples:
|
|
2446
2543
|
#
|
|
2447
|
-
#
|
|
2544
|
+
# stat0 = File.stat('README.md')
|
|
2545
|
+
# stat1 = File.stat('NEWS.md')
|
|
2546
|
+
# stat0.mtime # => 2025-12-20 15:33:05.6972341 -0600
|
|
2547
|
+
# stat1.mtime # => 2025-12-20 16:02:08.2672945 -0600
|
|
2548
|
+
# stat0 <=> stat1 # => -1
|
|
2549
|
+
# stat0 <=> stat0.dup # => 0
|
|
2550
|
+
# stat1 <=> stat0 # => 1
|
|
2551
|
+
# stat0 <=> :foo # => nil
|
|
2448
2552
|
#
|
|
2449
|
-
#
|
|
2450
|
-
#
|
|
2451
|
-
# f2 = File.new("f2", "w")
|
|
2452
|
-
# f1.stat <=> f2.stat #=> -1
|
|
2553
|
+
# Class File::Stat includes module Comparable, each of whose methods uses
|
|
2554
|
+
# File::Stat#<=> for comparison.
|
|
2453
2555
|
#
|
|
2454
2556
|
def <=>: (File::Stat other) -> Integer
|
|
2455
2557
|
| (untyped) -> nil
|
|
@@ -2558,7 +2660,7 @@ class File::Stat < Object
|
|
|
2558
2660
|
# rdoc-file=file.c
|
|
2559
2661
|
# - stat.dev_major -> integer
|
|
2560
2662
|
# -->
|
|
2561
|
-
# Returns the major part of
|
|
2663
|
+
# Returns the major part of <code>File_Stat#dev</code> or `nil`.
|
|
2562
2664
|
#
|
|
2563
2665
|
# File.stat("/dev/fd1").dev_major #=> 2
|
|
2564
2666
|
# File.stat("/dev/tty").dev_major #=> 5
|
|
@@ -2569,7 +2671,7 @@ class File::Stat < Object
|
|
|
2569
2671
|
# rdoc-file=file.c
|
|
2570
2672
|
# - stat.dev_minor -> integer
|
|
2571
2673
|
# -->
|
|
2572
|
-
# Returns the minor part of
|
|
2674
|
+
# Returns the minor part of <code>File_Stat#dev</code> or `nil`.
|
|
2573
2675
|
#
|
|
2574
2676
|
# File.stat("/dev/fd1").dev_minor #=> 1
|
|
2575
2677
|
# File.stat("/dev/tty").dev_minor #=> 0
|
|
@@ -2603,7 +2705,8 @@ class File::Stat < Object
|
|
|
2603
2705
|
# rdoc-file=file.c
|
|
2604
2706
|
# - stat.executable_real? -> true or false
|
|
2605
2707
|
# -->
|
|
2606
|
-
# Same as
|
|
2708
|
+
# Same as <code>executable?</code>, but tests using the real owner of the
|
|
2709
|
+
# process.
|
|
2607
2710
|
#
|
|
2608
2711
|
def executable_real?: () -> bool
|
|
2609
2712
|
|
|
@@ -2683,7 +2786,7 @@ class File::Stat < Object
|
|
|
2683
2786
|
# - stat.mode -> integer
|
|
2684
2787
|
# -->
|
|
2685
2788
|
# Returns an integer representing the permission bits of *stat*. The meaning of
|
|
2686
|
-
# the bits is platform dependent; on Unix systems, see
|
|
2789
|
+
# the bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
|
|
2687
2790
|
#
|
|
2688
2791
|
# File.chmod(0644, "testfile") #=> 1
|
|
2689
2792
|
# s = File.stat("testfile")
|
|
@@ -2750,7 +2853,7 @@ class File::Stat < Object
|
|
|
2750
2853
|
# rdoc-file=file.c
|
|
2751
2854
|
# - stat.rdev_major -> integer
|
|
2752
2855
|
# -->
|
|
2753
|
-
# Returns the major part of
|
|
2856
|
+
# Returns the major part of <code>File_Stat#rdev</code> or `nil`.
|
|
2754
2857
|
#
|
|
2755
2858
|
# File.stat("/dev/fd1").rdev_major #=> 2
|
|
2756
2859
|
# File.stat("/dev/tty").rdev_major #=> 5
|
|
@@ -2761,7 +2864,7 @@ class File::Stat < Object
|
|
|
2761
2864
|
# rdoc-file=file.c
|
|
2762
2865
|
# - stat.rdev_minor -> integer
|
|
2763
2866
|
# -->
|
|
2764
|
-
# Returns the minor part of
|
|
2867
|
+
# Returns the minor part of <code>File_Stat#rdev</code> or `nil`.
|
|
2765
2868
|
#
|
|
2766
2869
|
# File.stat("/dev/fd1").rdev_minor #=> 1
|
|
2767
2870
|
# File.stat("/dev/tty").rdev_minor #=> 0
|
|
@@ -2884,7 +2987,7 @@ class File::Stat < Object
|
|
|
2884
2987
|
# -->
|
|
2885
2988
|
# If *stat* is readable by others, returns an integer representing the file
|
|
2886
2989
|
# permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
|
|
2887
|
-
# platform dependent; on Unix systems, see
|
|
2990
|
+
# platform dependent; on Unix systems, see <code>stat(2)</code>.
|
|
2888
2991
|
#
|
|
2889
2992
|
# m = File.stat("/etc/passwd").world_readable? #=> 420
|
|
2890
2993
|
# sprintf("%o", m) #=> "644"
|
|
@@ -2897,7 +3000,7 @@ class File::Stat < Object
|
|
|
2897
3000
|
# -->
|
|
2898
3001
|
# If *stat* is writable by others, returns an integer representing the file
|
|
2899
3002
|
# permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
|
|
2900
|
-
# platform dependent; on Unix systems, see
|
|
3003
|
+
# platform dependent; on Unix systems, see <code>stat(2)</code>.
|
|
2901
3004
|
#
|
|
2902
3005
|
# m = File.stat("/tmp").world_writable? #=> 511
|
|
2903
3006
|
# sprintf("%o", m) #=> "777"
|