rbs 4.0.0.dev.4 → 4.1.0.pre.2
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/.clang-format +1 -0
- data/.github/dependabot.yml +16 -14
- data/.github/workflows/bundle-update.yml +63 -0
- data/.github/workflows/c-check.yml +21 -11
- data/.github/workflows/comments.yml +5 -3
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/jruby.yml +67 -0
- data/.github/workflows/milestone.yml +83 -0
- data/.github/workflows/ruby.yml +63 -24
- data/.github/workflows/rust.yml +184 -0
- data/.github/workflows/truffleruby.yml +54 -0
- data/.github/workflows/typecheck.yml +5 -2
- data/.github/workflows/wasm.yml +53 -0
- data/.github/workflows/windows.yml +8 -2
- data/.gitignore +11 -0
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +357 -0
- data/README.md +4 -4
- data/Rakefile +365 -33
- data/Steepfile +8 -0
- data/config.yml +450 -24
- data/core/array.rbs +443 -363
- data/core/basic_object.rbs +9 -8
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +9 -8
- data/core/class.rbs +11 -8
- 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 +288 -196
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator/product.rbs +5 -5
- data/core/enumerator.rbs +91 -28
- 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 +260 -1151
- data/core/file_constants.rbs +463 -0
- data/core/file_stat.rbs +534 -0
- data/core/file_test.rbs +3 -3
- data/core/float.rbs +257 -92
- data/core/gc.rbs +425 -281
- data/core/hash.rbs +1151 -829
- data/core/integer.rbs +156 -195
- data/core/io/buffer.rbs +53 -42
- data/core/io/wait.rbs +13 -35
- data/core/io.rbs +216 -150
- data/core/kernel.rbs +239 -163
- 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 +302 -150
- data/core/nil_class.rbs +7 -6
- data/core/numeric.rbs +77 -63
- data/core/object.rbs +9 -11
- data/core/object_space/weak_key_map.rbs +7 -7
- 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 +181 -79
- data/core/rational.rbs +60 -89
- data/core/rbs/ops.rbs +154 -0
- data/core/rbs/unnamed/argf.rbs +63 -56
- 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 +78 -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 +493 -363
- data/core/signal.rbs +26 -16
- data/core/string.rbs +3234 -1285
- data/core/struct.rbs +43 -42
- data/core/symbol.rbs +41 -34
- data/core/thread.rbs +141 -73
- 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/CONTRIBUTING.md +2 -1
- 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 +634 -0
- data/docs/rbs_by_example.md +20 -20
- data/docs/rust.md +96 -0
- data/docs/sigs.md +3 -3
- data/docs/syntax.md +48 -18
- data/docs/type_fingerprint.md +21 -0
- data/docs/wasm_serialization.md +80 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +1441 -671
- data/ext/rbs_extension/ast_translation.h +7 -0
- data/ext/rbs_extension/class_constants.c +18 -2
- data/ext/rbs_extension/class_constants.h +9 -0
- data/ext/rbs_extension/extconf.rb +6 -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 +183 -39
- data/include/rbs/ast.h +597 -297
- data/include/rbs/defines.h +40 -0
- data/include/rbs/lexer.h +31 -11
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +6 -6
- data/include/rbs/serialize.h +39 -0
- 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/annotate/rdoc_annotator.rb +27 -31
- 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 +335 -3
- data/lib/rbs/ast/ruby/comment_block.rb +30 -4
- data/lib/rbs/ast/ruby/declarations.rb +209 -4
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +1 -1
- data/lib/rbs/ast/ruby/members.rb +571 -22
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +66 -24
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +38 -106
- data/lib/rbs/cli.rb +55 -24
- data/lib/rbs/collection/config/lockfile_generator.rb +28 -3
- data/lib/rbs/collection/sources/git.rb +7 -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 +32 -6
- data/lib/rbs/definition_builder.rb +147 -25
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment.rb +235 -75
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/errors.rb +27 -18
- data/lib/rbs/inline_parser.rb +377 -15
- 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/namespace.rb +47 -11
- 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 +10 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +120 -44
- data/lib/rbs/rewriter.rb +70 -0
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +25 -3
- data/lib/rbs/type_name.rb +34 -14
- data/lib/rbs/types.rb +88 -78
- data/lib/rbs/unit_test/type_assertions.rb +44 -8
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/wasm/deserializer.rb +213 -0
- data/lib/rbs/wasm/location.rb +61 -0
- data/lib/rbs/wasm/parser.rb +137 -0
- data/lib/rbs/wasm/runtime.rb +217 -0
- data/lib/rbs/wasm/serialization_schema.rb +110 -0
- data/lib/rbs.rb +13 -2
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +24 -6
- data/schema/typeParam.json +17 -1
- data/sig/annotate/rdoc_annotater.rbs +12 -9
- data/sig/ast/ruby/annotations.rbs +364 -4
- data/sig/ast/ruby/comment_block.rbs +8 -0
- data/sig/ast/ruby/declarations.rbs +102 -4
- data/sig/ast/ruby/members.rbs +128 -2
- data/sig/buffer.rbs +19 -1
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +12 -8
- data/sig/cli.rbs +18 -18
- data/sig/collection/config/lockfile_generator.rbs +2 -0
- 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 +41 -2
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -2
- data/sig/method_builder.rbs +3 -1
- data/sig/namespace.rbs +20 -0
- data/sig/parser.rbs +41 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/resolver/type_name_resolver.rbs +36 -10
- data/sig/rewriter.rbs +45 -0
- data/sig/source.rbs +3 -3
- data/sig/type_param.rbs +13 -8
- data/sig/typename.rbs +15 -0
- data/sig/types.rbs +6 -7
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +15 -0
- data/sig/wasm/deserializer.rbs +66 -0
- data/sig/wasm/serialization_schema.rbs +13 -0
- data/src/ast.c +443 -162
- data/src/lexer.c +1415 -1313
- data/src/lexer.re +4 -0
- data/src/lexstate.c +63 -37
- data/src/location.c +7 -47
- data/src/parser.c +1032 -521
- data/src/serialize.c +958 -0
- data/src/string.c +0 -48
- data/src/util/rbs_allocator.c +89 -74
- 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/abbrev/0/array.rbs +1 -1
- 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/csv/0/csv.rbs +5 -5
- 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 +111 -1
- data/stdlib/erb/0/erb.rbs +748 -347
- data/stdlib/etc/0/etc.rbs +73 -54
- data/stdlib/fileutils/0/fileutils.rbs +179 -160
- data/stdlib/forwardable/0/forwardable.rbs +13 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +223 -142
- 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 +482 -364
- 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 +26 -69
- 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 +3 -3
- 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 +1209 -95
- data/stdlib/strscan/0/string_scanner.rbs +101 -80
- 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 +4 -1
- data/stdlib/tsort/0/interfaces.rbs +8 -8
- data/stdlib/tsort/0/tsort.rbs +16 -15
- 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 +8 -8
- 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
- data/wasm/README.md +59 -0
- data/wasm/rbs_wasm.c +411 -0
- metadata +56 -8
- data/.vscode/extensions.json +0 -5
- data/.vscode/settings.json +0 -19
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.
|
|
@@ -809,6 +810,30 @@
|
|
|
809
810
|
# * #truncate: Truncates `self` to the given size.
|
|
810
811
|
#
|
|
811
812
|
class File < IO
|
|
813
|
+
# The string that `File.ftype` and `File::Stat#ftype` return
|
|
814
|
+
type ftype = 'file' | 'directory' | 'characterSpecial' | 'blockSpecial'
|
|
815
|
+
| 'fifo' | 'link' | 'socket' | 'unknown'
|
|
816
|
+
|
|
817
|
+
# <!-- rdoc-file=file.c -->
|
|
818
|
+
# platform specific alternative separator
|
|
819
|
+
#
|
|
820
|
+
ALT_SEPARATOR: String?
|
|
821
|
+
|
|
822
|
+
# <!-- rdoc-file=file.c -->
|
|
823
|
+
# path list separator
|
|
824
|
+
#
|
|
825
|
+
PATH_SEPARATOR: String
|
|
826
|
+
|
|
827
|
+
# <!-- rdoc-file=file.c -->
|
|
828
|
+
# separates directory parts in path
|
|
829
|
+
#
|
|
830
|
+
SEPARATOR: String
|
|
831
|
+
|
|
832
|
+
# <!-- rdoc-file=file.c -->
|
|
833
|
+
# separates directory parts in path
|
|
834
|
+
#
|
|
835
|
+
Separator: String
|
|
836
|
+
|
|
812
837
|
# <!--
|
|
813
838
|
# rdoc-file=io.c
|
|
814
839
|
# - File.new(path, mode = 'r', perm = 0666, **opts) -> file
|
|
@@ -847,7 +872,30 @@ class File < IO
|
|
|
847
872
|
# * [Open Options](rdoc-ref:IO@Open+Options).
|
|
848
873
|
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
|
849
874
|
#
|
|
850
|
-
def initialize: (
|
|
875
|
+
def initialize: (
|
|
876
|
+
path | int file_name,
|
|
877
|
+
?string | int mode,
|
|
878
|
+
?int perm,
|
|
879
|
+
# open options
|
|
880
|
+
?mode: Integer | String,
|
|
881
|
+
?flags: Integer,
|
|
882
|
+
?external_encoding: encoding,
|
|
883
|
+
?internal_encoding: encoding,
|
|
884
|
+
?encoding: encoding,
|
|
885
|
+
?textmode: boolish,
|
|
886
|
+
?binmode: boolish,
|
|
887
|
+
?autoclose: boolish,
|
|
888
|
+
?path: path,
|
|
889
|
+
# encoding options
|
|
890
|
+
?invalid: :replace | nil,
|
|
891
|
+
?undef: :replace | nil,
|
|
892
|
+
?replace: String | nil,
|
|
893
|
+
?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
|
|
894
|
+
?xml: :text | :attr | nil,
|
|
895
|
+
?cr_newline: bool,
|
|
896
|
+
?crlf_newline: bool,
|
|
897
|
+
?universal_newline: bool
|
|
898
|
+
) -> void
|
|
851
899
|
|
|
852
900
|
# <!--
|
|
853
901
|
# rdoc-file=file.c
|
|
@@ -856,12 +904,12 @@ class File < IO
|
|
|
856
904
|
# Converts a pathname to an absolute pathname. Relative paths are referenced
|
|
857
905
|
# from the current working directory of the process unless *dir_string* is
|
|
858
906
|
# given, in which case it will be used as the starting point. If the given
|
|
859
|
-
# pathname starts with a
|
|
860
|
-
# directory name.
|
|
907
|
+
# pathname starts with a ``<code>~</code>'' it is NOT expanded, it is treated as
|
|
908
|
+
# a normal directory name.
|
|
861
909
|
#
|
|
862
910
|
# File.absolute_path("~oracle/bin") #=> "<relative_path>/~oracle/bin"
|
|
863
911
|
#
|
|
864
|
-
def self.absolute_path: (
|
|
912
|
+
def self.absolute_path: (path file_name, ?path dir_string) -> String
|
|
865
913
|
|
|
866
914
|
# <!--
|
|
867
915
|
# rdoc-file=file.c
|
|
@@ -871,7 +919,7 @@ class File < IO
|
|
|
871
919
|
#
|
|
872
920
|
# File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
|
|
873
921
|
#
|
|
874
|
-
def self.absolute_path?: (
|
|
922
|
+
def self.absolute_path?: (path file_name) -> bool
|
|
875
923
|
|
|
876
924
|
# <!--
|
|
877
925
|
# rdoc-file=file.c
|
|
@@ -883,7 +931,7 @@ class File < IO
|
|
|
883
931
|
#
|
|
884
932
|
# File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003
|
|
885
933
|
#
|
|
886
|
-
def self.atime: (
|
|
934
|
+
def self.atime: (path | IO file_name) -> Time
|
|
887
935
|
|
|
888
936
|
# <!--
|
|
889
937
|
# rdoc-file=file.c
|
|
@@ -899,7 +947,7 @@ class File < IO
|
|
|
899
947
|
# File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
|
|
900
948
|
# File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby"
|
|
901
949
|
#
|
|
902
|
-
def self.basename: (
|
|
950
|
+
def self.basename: (path file_name, ?string suffix) -> String
|
|
903
951
|
|
|
904
952
|
# <!--
|
|
905
953
|
# rdoc-file=file.c
|
|
@@ -913,7 +961,7 @@ class File < IO
|
|
|
913
961
|
#
|
|
914
962
|
# If the platform doesn't have birthtime, raises NotImplementedError.
|
|
915
963
|
#
|
|
916
|
-
def self.birthtime: (
|
|
964
|
+
def self.birthtime: (path | IO file_name) -> Time
|
|
917
965
|
|
|
918
966
|
# <!--
|
|
919
967
|
# rdoc-file=file.c
|
|
@@ -924,7 +972,7 @@ class File < IO
|
|
|
924
972
|
# File.blockdev?('/dev/sda1') # => true
|
|
925
973
|
# File.blockdev?(File.new('t.tmp')) # => false
|
|
926
974
|
#
|
|
927
|
-
def self.blockdev?: (
|
|
975
|
+
def self.blockdev?: (path | IO file_name) -> bool
|
|
928
976
|
|
|
929
977
|
# <!--
|
|
930
978
|
# rdoc-file=file.c
|
|
@@ -935,7 +983,7 @@ class File < IO
|
|
|
935
983
|
# File.chardev?($stdin) # => true
|
|
936
984
|
# File.chardev?('t.txt') # => false
|
|
937
985
|
#
|
|
938
|
-
def self.chardev?: (
|
|
986
|
+
def self.chardev?: (path | IO file_name) -> bool
|
|
939
987
|
|
|
940
988
|
# <!--
|
|
941
989
|
# rdoc-file=file.c
|
|
@@ -943,12 +991,12 @@ class File < IO
|
|
|
943
991
|
# -->
|
|
944
992
|
# Changes permission bits on the named file(s) to the bit pattern represented by
|
|
945
993
|
# *mode_int*. Actual effects are operating system dependent (see the beginning
|
|
946
|
-
# of this section). On Unix systems, see
|
|
947
|
-
# number of files processed.
|
|
994
|
+
# of this section). On Unix systems, see <code>chmod(2)</code> for details.
|
|
995
|
+
# Returns the number of files processed.
|
|
948
996
|
#
|
|
949
997
|
# File.chmod(0644, "testfile", "out") #=> 2
|
|
950
998
|
#
|
|
951
|
-
def self.chmod: (int mode, *
|
|
999
|
+
def self.chmod: (int mode, *path file_name) -> Integer
|
|
952
1000
|
|
|
953
1001
|
# <!--
|
|
954
1002
|
# rdoc-file=file.c
|
|
@@ -962,7 +1010,7 @@ class File < IO
|
|
|
962
1010
|
#
|
|
963
1011
|
# File.chown(nil, 100, "testfile")
|
|
964
1012
|
#
|
|
965
|
-
def self.chown: (int? owner, int? group, *
|
|
1013
|
+
def self.chown: (int? owner, int? group, *path file_name) -> Integer
|
|
966
1014
|
|
|
967
1015
|
# <!--
|
|
968
1016
|
# rdoc-file=file.c
|
|
@@ -977,7 +1025,7 @@ class File < IO
|
|
|
977
1025
|
#
|
|
978
1026
|
# File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
|
|
979
1027
|
#
|
|
980
|
-
def self.ctime: (
|
|
1028
|
+
def self.ctime: (path | IO file_name) -> Time
|
|
981
1029
|
|
|
982
1030
|
# <!--
|
|
983
1031
|
# rdoc-file=file.c
|
|
@@ -986,9 +1034,9 @@ class File < IO
|
|
|
986
1034
|
# -->
|
|
987
1035
|
# Deletes the named files, returning the number of names passed as arguments.
|
|
988
1036
|
# 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.
|
|
1037
|
+
# on the <code>unlink(2)</code> system call, the type of exception raised
|
|
1038
|
+
# depends on its error type (see https://linux.die.net/man/2/unlink) and has the
|
|
1039
|
+
# form of e.g. Errno::ENOENT.
|
|
992
1040
|
#
|
|
993
1041
|
# See also Dir::rmdir.
|
|
994
1042
|
#
|
|
@@ -1010,7 +1058,7 @@ class File < IO
|
|
|
1010
1058
|
#
|
|
1011
1059
|
# Argument `path` can be an IO object.
|
|
1012
1060
|
#
|
|
1013
|
-
def self.directory?: (
|
|
1061
|
+
def self.directory?: (path | IO path) -> bool
|
|
1014
1062
|
|
|
1015
1063
|
# <!--
|
|
1016
1064
|
# rdoc-file=file.c
|
|
@@ -1028,7 +1076,7 @@ class File < IO
|
|
|
1028
1076
|
# File.dirname("/home/gumby/work/ruby.rb", 2) #=> "/home/gumby"
|
|
1029
1077
|
# File.dirname("/home/gumby/work/ruby.rb", 4) #=> "/"
|
|
1030
1078
|
#
|
|
1031
|
-
def self.dirname: (
|
|
1079
|
+
def self.dirname: (path file_name, ?Integer level) -> String
|
|
1032
1080
|
|
|
1033
1081
|
# <!--
|
|
1034
1082
|
# rdoc-file=file.c
|
|
@@ -1054,7 +1102,7 @@ class File < IO
|
|
|
1054
1102
|
# Note that some OS-level security features may cause this to return true even
|
|
1055
1103
|
# though the file is not executable by the effective user/group.
|
|
1056
1104
|
#
|
|
1057
|
-
def self.executable?: (
|
|
1105
|
+
def self.executable?: (path file_name) -> bool
|
|
1058
1106
|
|
|
1059
1107
|
# <!--
|
|
1060
1108
|
# rdoc-file=file.c
|
|
@@ -1070,7 +1118,7 @@ class File < IO
|
|
|
1070
1118
|
# Note that some OS-level security features may cause this to return true even
|
|
1071
1119
|
# though the file is not executable by the real user/group.
|
|
1072
1120
|
#
|
|
1073
|
-
def self.executable_real?: (
|
|
1121
|
+
def self.executable_real?: (path file_name) -> bool
|
|
1074
1122
|
|
|
1075
1123
|
# <!--
|
|
1076
1124
|
# rdoc-file=file.c
|
|
@@ -1082,7 +1130,7 @@ class File < IO
|
|
|
1082
1130
|
#
|
|
1083
1131
|
# "file exists" means that stat() or fstat() system call is successful.
|
|
1084
1132
|
#
|
|
1085
|
-
def self.exist?: (
|
|
1133
|
+
def self.exist?: (path | IO file_name) -> bool
|
|
1086
1134
|
|
|
1087
1135
|
# <!--
|
|
1088
1136
|
# rdoc-file=file.c
|
|
@@ -1091,9 +1139,9 @@ class File < IO
|
|
|
1091
1139
|
# Converts a pathname to an absolute pathname. Relative paths are referenced
|
|
1092
1140
|
# from the current working directory of the process unless `dir_string` is
|
|
1093
1141
|
# 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.
|
|
1142
|
+
# may start with a ``<code>~</code>'', which expands to the process owner's home
|
|
1143
|
+
# directory (the environment variable `HOME` must be set correctly).
|
|
1144
|
+
# ``<code>~</code>*user*'' expands to the named user's home directory.
|
|
1097
1145
|
#
|
|
1098
1146
|
# File.expand_path("~oracle/bin") #=> "/home/oracle/bin"
|
|
1099
1147
|
#
|
|
@@ -1107,9 +1155,9 @@ class File < IO
|
|
|
1107
1155
|
# #=> ".../path/to/project/lib/mygem.rb"
|
|
1108
1156
|
#
|
|
1109
1157
|
# So first it resolves the parent of __FILE__, that is bin/, then go to the
|
|
1110
|
-
# parent, the root of the project and appends
|
|
1158
|
+
# parent, the root of the project and appends <code>lib/mygem.rb</code>.
|
|
1111
1159
|
#
|
|
1112
|
-
def self.expand_path: (
|
|
1160
|
+
def self.expand_path: (path file_name, ?path dir_string) -> String
|
|
1113
1161
|
|
|
1114
1162
|
# <!--
|
|
1115
1163
|
# rdoc-file=file.c
|
|
@@ -1135,7 +1183,7 @@ class File < IO
|
|
|
1135
1183
|
# File.extname(".profile") #=> ""
|
|
1136
1184
|
# File.extname(".profile.sh") #=> ".sh"
|
|
1137
1185
|
#
|
|
1138
|
-
def self.extname: (
|
|
1186
|
+
def self.extname: (path path) -> String
|
|
1139
1187
|
|
|
1140
1188
|
# <!--
|
|
1141
1189
|
# rdoc-file=file.c
|
|
@@ -1148,7 +1196,7 @@ class File < IO
|
|
|
1148
1196
|
# If the `file` argument is a symbolic link, it will resolve the symbolic link
|
|
1149
1197
|
# and use the file referenced by the link.
|
|
1150
1198
|
#
|
|
1151
|
-
def self.file?: (
|
|
1199
|
+
def self.file?: (path | IO file) -> bool
|
|
1152
1200
|
|
|
1153
1201
|
# <!--
|
|
1154
1202
|
# rdoc-file=dir.rb
|
|
@@ -1159,48 +1207,48 @@ class File < IO
|
|
|
1159
1207
|
# regular expression; instead it follows rules similar to shell filename
|
|
1160
1208
|
# globbing. It may contain the following metacharacters:
|
|
1161
1209
|
#
|
|
1162
|
-
#
|
|
1210
|
+
# <code>*</code>
|
|
1163
1211
|
# : Matches any file. Can be restricted by other values in the glob.
|
|
1164
|
-
# Equivalent to
|
|
1212
|
+
# Equivalent to <code>/.*/x</code> in regexp.
|
|
1165
1213
|
#
|
|
1166
|
-
#
|
|
1214
|
+
# <code>*</code>
|
|
1167
1215
|
# : Matches all regular files
|
|
1168
1216
|
#
|
|
1169
|
-
#
|
|
1217
|
+
# <code>c*</code>
|
|
1170
1218
|
# : Matches all files beginning with `c`
|
|
1171
1219
|
#
|
|
1172
|
-
#
|
|
1220
|
+
# <code>*c</code>
|
|
1173
1221
|
# : Matches all files ending with `c`
|
|
1174
1222
|
#
|
|
1175
|
-
#
|
|
1223
|
+
# <code>*c*</code>
|
|
1176
1224
|
# : Matches all files that have `c` in them (including at the beginning or
|
|
1177
1225
|
# end).
|
|
1178
1226
|
#
|
|
1179
1227
|
#
|
|
1180
|
-
# To match hidden files (that start with a
|
|
1181
|
-
# flag.
|
|
1228
|
+
# To match hidden files (that start with a <code>.</code>) set the
|
|
1229
|
+
# File::FNM_DOTMATCH flag.
|
|
1182
1230
|
#
|
|
1183
1231
|
#
|
|
1184
|
-
#
|
|
1232
|
+
# <code>**</code>
|
|
1185
1233
|
# : Matches directories recursively or files expansively.
|
|
1186
1234
|
#
|
|
1187
1235
|
#
|
|
1188
|
-
#
|
|
1189
|
-
# : Matches any one character. Equivalent to
|
|
1236
|
+
# <code>?</code>
|
|
1237
|
+
# : Matches any one character. Equivalent to <code>/.{1}/</code> in regexp.
|
|
1190
1238
|
#
|
|
1191
1239
|
#
|
|
1192
|
-
#
|
|
1240
|
+
# <code>[set]</code>
|
|
1193
1241
|
# : Matches any one character in `set`. Behaves exactly like character sets
|
|
1194
|
-
# in Regexp, including set negation (
|
|
1242
|
+
# in Regexp, including set negation (<code>[^a-z]</code>).
|
|
1195
1243
|
#
|
|
1196
1244
|
#
|
|
1197
|
-
#
|
|
1245
|
+
# <code>\</code>
|
|
1198
1246
|
# : Escapes the next metacharacter.
|
|
1199
1247
|
#
|
|
1200
1248
|
#
|
|
1201
|
-
#
|
|
1249
|
+
# <code>{a,b}</code>
|
|
1202
1250
|
# : Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled.
|
|
1203
|
-
# Behaves like a Regexp union (
|
|
1251
|
+
# Behaves like a Regexp union (<code>(?:a|b)</code>).
|
|
1204
1252
|
#
|
|
1205
1253
|
#
|
|
1206
1254
|
# `flags` is a bitwise OR of the `FNM_XXX` constants. The same glob pattern and
|
|
@@ -1252,7 +1300,7 @@ class File < IO
|
|
|
1252
1300
|
# File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
|
|
1253
1301
|
# File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
|
|
1254
1302
|
#
|
|
1255
|
-
def self.fnmatch: (string pattern,
|
|
1303
|
+
def self.fnmatch: (string pattern, path path, ?int flags) -> bool
|
|
1256
1304
|
|
|
1257
1305
|
# <!--
|
|
1258
1306
|
# rdoc-file=dir.rb
|
|
@@ -1273,7 +1321,7 @@ class File < IO
|
|
|
1273
1321
|
# File.ftype("/dev/tty") #=> "characterSpecial"
|
|
1274
1322
|
# File.ftype("/tmp/.X11-unix/X0") #=> "socket"
|
|
1275
1323
|
#
|
|
1276
|
-
def self.ftype: (
|
|
1324
|
+
def self.ftype: (path file_name) -> String
|
|
1277
1325
|
|
|
1278
1326
|
# <!--
|
|
1279
1327
|
# rdoc-file=file.c
|
|
@@ -1284,7 +1332,7 @@ class File < IO
|
|
|
1284
1332
|
#
|
|
1285
1333
|
# *file_name* can be an IO object.
|
|
1286
1334
|
#
|
|
1287
|
-
def self.grpowned?: (
|
|
1335
|
+
def self.grpowned?: (path | IO file_name) -> bool
|
|
1288
1336
|
|
|
1289
1337
|
# <!--
|
|
1290
1338
|
# rdoc-file=file.c
|
|
@@ -1304,13 +1352,13 @@ class File < IO
|
|
|
1304
1352
|
# open("d", "w") {}
|
|
1305
1353
|
# p File.identical?("a", "d") #=> false
|
|
1306
1354
|
#
|
|
1307
|
-
def self.identical?: (
|
|
1355
|
+
def self.identical?: (path | IO file_1, path | IO file_2) -> bool
|
|
1308
1356
|
|
|
1309
1357
|
# <!--
|
|
1310
1358
|
# rdoc-file=file.c
|
|
1311
1359
|
# - File.join(string, ...) -> string
|
|
1312
1360
|
# -->
|
|
1313
|
-
# Returns a new string formed by joining the strings using
|
|
1361
|
+
# Returns a new string formed by joining the strings using <code>"/"</code>.
|
|
1314
1362
|
#
|
|
1315
1363
|
# File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
|
|
1316
1364
|
#
|
|
@@ -1324,7 +1372,7 @@ class File < IO
|
|
|
1324
1372
|
# change the permissions associated with the link, not the file referenced by
|
|
1325
1373
|
# the link). Often not available.
|
|
1326
1374
|
#
|
|
1327
|
-
def self.lchmod: (int mode, *
|
|
1375
|
+
def self.lchmod: (int mode, *path file_name) -> Integer
|
|
1328
1376
|
|
|
1329
1377
|
# <!--
|
|
1330
1378
|
# rdoc-file=file.c
|
|
@@ -1334,7 +1382,7 @@ class File < IO
|
|
|
1334
1382
|
# change the owner associated with the link, not the file referenced by the
|
|
1335
1383
|
# link). Often not available. Returns number of files in the argument list.
|
|
1336
1384
|
#
|
|
1337
|
-
def self.lchown: (int? owner, int? group, *
|
|
1385
|
+
def self.lchown: (int? owner, int? group, *path file_name) -> Integer
|
|
1338
1386
|
|
|
1339
1387
|
# <!--
|
|
1340
1388
|
# rdoc-file=file.c
|
|
@@ -1347,7 +1395,7 @@ class File < IO
|
|
|
1347
1395
|
# File.link("testfile", ".testfile") #=> 0
|
|
1348
1396
|
# IO.readlines(".testfile")[0] #=> "This is line one\n"
|
|
1349
1397
|
#
|
|
1350
|
-
def self.link: (
|
|
1398
|
+
def self.link: (path old_name, path new_name) -> 0
|
|
1351
1399
|
|
|
1352
1400
|
# <!--
|
|
1353
1401
|
# rdoc-file=file.c
|
|
@@ -1360,7 +1408,7 @@ class File < IO
|
|
|
1360
1408
|
# File.stat('symlink').size # => 47
|
|
1361
1409
|
# File.lstat('symlink').size # => 5
|
|
1362
1410
|
#
|
|
1363
|
-
def self.lstat: (
|
|
1411
|
+
def self.lstat: (path file_name) -> File::Stat
|
|
1364
1412
|
|
|
1365
1413
|
# <!--
|
|
1366
1414
|
# rdoc-file=file.c
|
|
@@ -1371,7 +1419,7 @@ class File < IO
|
|
|
1371
1419
|
# opposed to its referent; for the inverse behavior, see File.utime. Returns the
|
|
1372
1420
|
# number of file names in the argument list.
|
|
1373
1421
|
#
|
|
1374
|
-
def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *
|
|
1422
|
+
def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
|
|
1375
1423
|
|
|
1376
1424
|
# <!--
|
|
1377
1425
|
# rdoc-file=file.c
|
|
@@ -1381,7 +1429,7 @@ class File < IO
|
|
|
1381
1429
|
# FIFO's permissions. It is modified by the process's umask in the usual way:
|
|
1382
1430
|
# the permissions of the created file are (mode & ~umask).
|
|
1383
1431
|
#
|
|
1384
|
-
def self.mkfifo: (
|
|
1432
|
+
def self.mkfifo: (path file_name, ?int mode) -> 0
|
|
1385
1433
|
|
|
1386
1434
|
# <!--
|
|
1387
1435
|
# rdoc-file=file.c
|
|
@@ -1393,7 +1441,7 @@ class File < IO
|
|
|
1393
1441
|
#
|
|
1394
1442
|
# File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
|
|
1395
1443
|
#
|
|
1396
|
-
def self.mtime: (
|
|
1444
|
+
def self.mtime: (path | IO file_name) -> Time
|
|
1397
1445
|
|
|
1398
1446
|
# <!--
|
|
1399
1447
|
# rdoc-file=io.c
|
|
@@ -1407,19 +1455,65 @@ class File < IO
|
|
|
1407
1455
|
# With a block given, calls the block with the File object and returns the
|
|
1408
1456
|
# block's value.
|
|
1409
1457
|
#
|
|
1410
|
-
def self.open: (
|
|
1411
|
-
|
|
1458
|
+
def self.open: (
|
|
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
|
+
) -> instance
|
|
1482
|
+
| [T] (
|
|
1483
|
+
path | int file_name,
|
|
1484
|
+
?string | int mode,
|
|
1485
|
+
?int perm,
|
|
1486
|
+
# open options
|
|
1487
|
+
?mode: Integer | String,
|
|
1488
|
+
?flags: Integer,
|
|
1489
|
+
?external_encoding: encoding,
|
|
1490
|
+
?internal_encoding: encoding,
|
|
1491
|
+
?encoding: encoding,
|
|
1492
|
+
?textmode: boolish,
|
|
1493
|
+
?binmode: boolish,
|
|
1494
|
+
?autoclose: boolish,
|
|
1495
|
+
?path: path,
|
|
1496
|
+
# encoding options
|
|
1497
|
+
?invalid: :replace | nil,
|
|
1498
|
+
?undef: :replace | nil,
|
|
1499
|
+
?replace: String | nil,
|
|
1500
|
+
?fallback: Hash[string, string] | ^(String) -> string | Method | nil,
|
|
1501
|
+
?xml: :text | :attr | nil,
|
|
1502
|
+
?cr_newline: bool,
|
|
1503
|
+
?crlf_newline: bool,
|
|
1504
|
+
?universal_newline: bool
|
|
1505
|
+
) { (File) -> T } -> T
|
|
1412
1506
|
|
|
1413
1507
|
# <!--
|
|
1414
1508
|
# rdoc-file=file.c
|
|
1415
1509
|
# - File.owned?(file_name) -> true or false
|
|
1416
1510
|
# -->
|
|
1417
|
-
# Returns `true` if the named file exists and the effective
|
|
1511
|
+
# Returns `true` if the named file exists and the effective user id of the
|
|
1418
1512
|
# calling process is the owner of the file.
|
|
1419
1513
|
#
|
|
1420
1514
|
# *file_name* can be an IO object.
|
|
1421
1515
|
#
|
|
1422
|
-
def self.owned?: (
|
|
1516
|
+
def self.owned?: (path | IO file_name) -> bool
|
|
1423
1517
|
|
|
1424
1518
|
# <!--
|
|
1425
1519
|
# rdoc-file=file.c
|
|
@@ -1427,10 +1521,27 @@ class File < IO
|
|
|
1427
1521
|
# -->
|
|
1428
1522
|
# Returns the string representation of the path
|
|
1429
1523
|
#
|
|
1430
|
-
#
|
|
1431
|
-
#
|
|
1524
|
+
# File.path(File::NULL) #=> "/dev/null"
|
|
1525
|
+
# File.path(Pathname.new("/tmp")) #=> "/tmp"
|
|
1526
|
+
#
|
|
1527
|
+
# If `path` is not a String:
|
|
1528
|
+
#
|
|
1529
|
+
# 1. If it has the `to_path` method, that method will be called to coerce to a
|
|
1530
|
+
# String.
|
|
1432
1531
|
#
|
|
1433
|
-
|
|
1532
|
+
# 2. Otherwise, or if the coerced result is not a String too, the standard
|
|
1533
|
+
# coersion using `to_str` method will take place on that object. (See also
|
|
1534
|
+
# String.try_convert)
|
|
1535
|
+
#
|
|
1536
|
+
# The coerced string must satisfy the following conditions:
|
|
1537
|
+
#
|
|
1538
|
+
# 1. It must be in an ASCII-compatible encoding; otherwise, an
|
|
1539
|
+
# Encoding::CompatibilityError is raised.
|
|
1540
|
+
#
|
|
1541
|
+
# 2. It must not contain the NUL character (<code>\0</code>); otherwise, an
|
|
1542
|
+
# ArgumentError is raised.
|
|
1543
|
+
#
|
|
1544
|
+
def self.path: (path path) -> String
|
|
1434
1545
|
|
|
1435
1546
|
# <!--
|
|
1436
1547
|
# rdoc-file=file.c
|
|
@@ -1442,7 +1553,7 @@ class File < IO
|
|
|
1442
1553
|
# File.pipe?('tmp/fifo') # => true
|
|
1443
1554
|
# File.pipe?('t.txt') # => false
|
|
1444
1555
|
#
|
|
1445
|
-
def self.pipe?: (
|
|
1556
|
+
def self.pipe?: (path | IO file_name) -> bool
|
|
1446
1557
|
|
|
1447
1558
|
# <!--
|
|
1448
1559
|
# rdoc-file=file.c
|
|
@@ -1454,7 +1565,7 @@ class File < IO
|
|
|
1454
1565
|
# Note that some OS-level security features may cause this to return true even
|
|
1455
1566
|
# though the file is not readable by the effective user/group.
|
|
1456
1567
|
#
|
|
1457
|
-
def self.readable?: (
|
|
1568
|
+
def self.readable?: (path file_name) -> bool
|
|
1458
1569
|
|
|
1459
1570
|
# <!--
|
|
1460
1571
|
# rdoc-file=file.c
|
|
@@ -1466,7 +1577,7 @@ class File < IO
|
|
|
1466
1577
|
# Note that some OS-level security features may cause this to return true even
|
|
1467
1578
|
# though the file is not readable by the real user/group.
|
|
1468
1579
|
#
|
|
1469
|
-
def self.readable_real?: (
|
|
1580
|
+
def self.readable_real?: (path file_name) -> bool
|
|
1470
1581
|
|
|
1471
1582
|
# <!--
|
|
1472
1583
|
# rdoc-file=file.c
|
|
@@ -1478,7 +1589,7 @@ class File < IO
|
|
|
1478
1589
|
# File.symlink("testfile", "link2test") #=> 0
|
|
1479
1590
|
# File.readlink("link2test") #=> "testfile"
|
|
1480
1591
|
#
|
|
1481
|
-
def self.readlink: (
|
|
1592
|
+
def self.readlink: (path link_name) -> String
|
|
1482
1593
|
|
|
1483
1594
|
# <!--
|
|
1484
1595
|
# rdoc-file=file.c
|
|
@@ -1492,7 +1603,7 @@ class File < IO
|
|
|
1492
1603
|
#
|
|
1493
1604
|
# The last component of the real pathname can be nonexistent.
|
|
1494
1605
|
#
|
|
1495
|
-
def self.realdirpath: (
|
|
1606
|
+
def self.realdirpath: (path pathname, ?path dir_string) -> String
|
|
1496
1607
|
|
|
1497
1608
|
# <!--
|
|
1498
1609
|
# rdoc-file=file.c
|
|
@@ -1506,7 +1617,7 @@ class File < IO
|
|
|
1506
1617
|
#
|
|
1507
1618
|
# All components of the pathname must exist when this method is called.
|
|
1508
1619
|
#
|
|
1509
|
-
def self.realpath: (
|
|
1620
|
+
def self.realpath: (path pathname, ?path dir_string) -> String
|
|
1510
1621
|
|
|
1511
1622
|
# <!--
|
|
1512
1623
|
# rdoc-file=file.c
|
|
@@ -1517,7 +1628,7 @@ class File < IO
|
|
|
1517
1628
|
#
|
|
1518
1629
|
# File.rename("afile", "afile.bak") #=> 0
|
|
1519
1630
|
#
|
|
1520
|
-
def self.rename: (
|
|
1631
|
+
def self.rename: (path old_name, path new_name) -> 0
|
|
1521
1632
|
|
|
1522
1633
|
# <!--
|
|
1523
1634
|
# rdoc-file=file.c
|
|
@@ -1527,7 +1638,7 @@ class File < IO
|
|
|
1527
1638
|
#
|
|
1528
1639
|
# *file_name* can be an IO object.
|
|
1529
1640
|
#
|
|
1530
|
-
def self.setgid?: (
|
|
1641
|
+
def self.setgid?: (path | IO file_name) -> bool
|
|
1531
1642
|
|
|
1532
1643
|
# <!--
|
|
1533
1644
|
# rdoc-file=file.c
|
|
@@ -1537,7 +1648,7 @@ class File < IO
|
|
|
1537
1648
|
#
|
|
1538
1649
|
# *file_name* can be an IO object.
|
|
1539
1650
|
#
|
|
1540
|
-
def self.setuid?: (
|
|
1651
|
+
def self.setuid?: (path | IO file_name) -> bool
|
|
1541
1652
|
|
|
1542
1653
|
# <!--
|
|
1543
1654
|
# rdoc-file=file.c
|
|
@@ -1547,7 +1658,7 @@ class File < IO
|
|
|
1547
1658
|
#
|
|
1548
1659
|
# *file_name* can be an IO object.
|
|
1549
1660
|
#
|
|
1550
|
-
def self.size: (
|
|
1661
|
+
def self.size: (path | IO file_name) -> Integer
|
|
1551
1662
|
|
|
1552
1663
|
# <!--
|
|
1553
1664
|
# rdoc-file=file.c
|
|
@@ -1558,7 +1669,7 @@ class File < IO
|
|
|
1558
1669
|
#
|
|
1559
1670
|
# *file_name* can be an IO object.
|
|
1560
1671
|
#
|
|
1561
|
-
def self.size?: (
|
|
1672
|
+
def self.size?: (path | IO file_name) -> Integer?
|
|
1562
1673
|
|
|
1563
1674
|
# <!--
|
|
1564
1675
|
# rdoc-file=file.c
|
|
@@ -1570,7 +1681,7 @@ class File < IO
|
|
|
1570
1681
|
# File.socket?(Socket.new(:INET, :STREAM)) # => true
|
|
1571
1682
|
# File.socket?(File.new('t.txt')) # => false
|
|
1572
1683
|
#
|
|
1573
|
-
def self.socket?: (
|
|
1684
|
+
def self.socket?: (path | IO file_name) -> bool
|
|
1574
1685
|
|
|
1575
1686
|
# <!--
|
|
1576
1687
|
# rdoc-file=file.c
|
|
@@ -1581,7 +1692,7 @@ class File < IO
|
|
|
1581
1692
|
#
|
|
1582
1693
|
# File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
|
|
1583
1694
|
#
|
|
1584
|
-
def self.split: (
|
|
1695
|
+
def self.split: (path file_name) -> [ String, String ]
|
|
1585
1696
|
|
|
1586
1697
|
# <!--
|
|
1587
1698
|
# rdoc-file=file.c
|
|
@@ -1591,7 +1702,7 @@ class File < IO
|
|
|
1591
1702
|
#
|
|
1592
1703
|
# File.stat('t.txt').class # => File::Stat
|
|
1593
1704
|
#
|
|
1594
|
-
def self.stat: (
|
|
1705
|
+
def self.stat: (path file_name) -> File::Stat
|
|
1595
1706
|
|
|
1596
1707
|
# <!--
|
|
1597
1708
|
# rdoc-file=file.c
|
|
@@ -1601,7 +1712,7 @@ class File < IO
|
|
|
1601
1712
|
#
|
|
1602
1713
|
# *file_name* can be an IO object.
|
|
1603
1714
|
#
|
|
1604
|
-
def self.sticky?: (
|
|
1715
|
+
def self.sticky?: (path | IO file_name) -> bool
|
|
1605
1716
|
|
|
1606
1717
|
# <!--
|
|
1607
1718
|
# rdoc-file=file.c
|
|
@@ -1613,7 +1724,7 @@ class File < IO
|
|
|
1613
1724
|
#
|
|
1614
1725
|
# File.symlink("testfile", "link2test") #=> 0
|
|
1615
1726
|
#
|
|
1616
|
-
def self.symlink: (
|
|
1727
|
+
def self.symlink: (path old_name, path new_name) -> 0
|
|
1617
1728
|
|
|
1618
1729
|
# <!--
|
|
1619
1730
|
# rdoc-file=file.c
|
|
@@ -1625,7 +1736,7 @@ class File < IO
|
|
|
1625
1736
|
# File.symlink?('symlink') # => true
|
|
1626
1737
|
# File.symlink?('t.txt') # => false
|
|
1627
1738
|
#
|
|
1628
|
-
def self.symlink?: (
|
|
1739
|
+
def self.symlink?: (path file_name) -> bool
|
|
1629
1740
|
|
|
1630
1741
|
# <!--
|
|
1631
1742
|
# rdoc-file=file.c
|
|
@@ -1640,7 +1751,7 @@ class File < IO
|
|
|
1640
1751
|
# File.truncate("out", 5) #=> 0
|
|
1641
1752
|
# File.size("out") #=> 5
|
|
1642
1753
|
#
|
|
1643
|
-
def self.truncate: (
|
|
1754
|
+
def self.truncate: (path file_name, int length) -> 0
|
|
1644
1755
|
|
|
1645
1756
|
# <!--
|
|
1646
1757
|
# rdoc-file=file.c
|
|
@@ -1664,13 +1775,13 @@ class File < IO
|
|
|
1664
1775
|
# -->
|
|
1665
1776
|
# Deletes the named files, returning the number of names passed as arguments.
|
|
1666
1777
|
# 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.
|
|
1778
|
+
# on the <code>unlink(2)</code> system call, the type of exception raised
|
|
1779
|
+
# depends on its error type (see https://linux.die.net/man/2/unlink) and has the
|
|
1780
|
+
# form of e.g. Errno::ENOENT.
|
|
1670
1781
|
#
|
|
1671
1782
|
# See also Dir::rmdir.
|
|
1672
1783
|
#
|
|
1673
|
-
def self.unlink: (*
|
|
1784
|
+
def self.unlink: (*path file_name) -> Integer
|
|
1674
1785
|
|
|
1675
1786
|
# <!--
|
|
1676
1787
|
# rdoc-file=file.c
|
|
@@ -1681,7 +1792,7 @@ class File < IO
|
|
|
1681
1792
|
# than the link itself; for the inverse behavior see File.lutime. Returns the
|
|
1682
1793
|
# number of file names in the argument list.
|
|
1683
1794
|
#
|
|
1684
|
-
def self.utime: (Time | Numeric atime, Time | Numeric mtime, *
|
|
1795
|
+
def self.utime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
|
|
1685
1796
|
|
|
1686
1797
|
# <!--
|
|
1687
1798
|
# rdoc-file=file.c
|
|
@@ -1689,7 +1800,7 @@ class File < IO
|
|
|
1689
1800
|
# -->
|
|
1690
1801
|
# If *file_name* is readable by others, returns an integer representing the file
|
|
1691
1802
|
# permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
|
|
1692
|
-
# bits is platform dependent; on Unix systems, see
|
|
1803
|
+
# bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
|
|
1693
1804
|
#
|
|
1694
1805
|
# *file_name* can be an IO object.
|
|
1695
1806
|
#
|
|
@@ -1697,7 +1808,7 @@ class File < IO
|
|
|
1697
1808
|
# m = File.world_readable?("/etc/passwd")
|
|
1698
1809
|
# sprintf("%o", m) #=> "644"
|
|
1699
1810
|
#
|
|
1700
|
-
def self.world_readable?: (
|
|
1811
|
+
def self.world_readable?: (path | IO file_name) -> Integer?
|
|
1701
1812
|
|
|
1702
1813
|
# <!--
|
|
1703
1814
|
# rdoc-file=file.c
|
|
@@ -1705,7 +1816,7 @@ class File < IO
|
|
|
1705
1816
|
# -->
|
|
1706
1817
|
# If *file_name* is writable by others, returns an integer representing the file
|
|
1707
1818
|
# permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
|
|
1708
|
-
# bits is platform dependent; on Unix systems, see
|
|
1819
|
+
# bits is platform dependent; on Unix systems, see <code>stat(2)</code>.
|
|
1709
1820
|
#
|
|
1710
1821
|
# *file_name* can be an IO object.
|
|
1711
1822
|
#
|
|
@@ -1713,7 +1824,7 @@ class File < IO
|
|
|
1713
1824
|
# m = File.world_writable?("/tmp")
|
|
1714
1825
|
# sprintf("%o", m) #=> "777"
|
|
1715
1826
|
#
|
|
1716
|
-
def self.world_writable?: (
|
|
1827
|
+
def self.world_writable?: (path | IO file_name) -> Integer?
|
|
1717
1828
|
|
|
1718
1829
|
# <!--
|
|
1719
1830
|
# rdoc-file=file.c
|
|
@@ -1725,7 +1836,7 @@ class File < IO
|
|
|
1725
1836
|
# Note that some OS-level security features may cause this to return true even
|
|
1726
1837
|
# though the file is not writable by the effective user/group.
|
|
1727
1838
|
#
|
|
1728
|
-
def self.writable?: (
|
|
1839
|
+
def self.writable?: (path file_name) -> bool
|
|
1729
1840
|
|
|
1730
1841
|
# <!--
|
|
1731
1842
|
# rdoc-file=file.c
|
|
@@ -1737,7 +1848,7 @@ class File < IO
|
|
|
1737
1848
|
# Note that some OS-level security features may cause this to return true even
|
|
1738
1849
|
# though the file is not writable by the real user/group.
|
|
1739
1850
|
#
|
|
1740
|
-
def self.writable_real?: (
|
|
1851
|
+
def self.writable_real?: (path file_name) -> bool
|
|
1741
1852
|
|
|
1742
1853
|
# <!--
|
|
1743
1854
|
# rdoc-file=file.c
|
|
@@ -1747,7 +1858,7 @@ class File < IO
|
|
|
1747
1858
|
#
|
|
1748
1859
|
# *file_name* can be an IO object.
|
|
1749
1860
|
#
|
|
1750
|
-
def self.zero?: (
|
|
1861
|
+
def self.zero?: (path | IO file_name) -> bool
|
|
1751
1862
|
|
|
1752
1863
|
# <!--
|
|
1753
1864
|
# rdoc-file=file.c
|
|
@@ -1778,7 +1889,8 @@ class File < IO
|
|
|
1778
1889
|
# -->
|
|
1779
1890
|
# Changes permission bits on *file* to the bit pattern represented by
|
|
1780
1891
|
# *mode_int*. Actual effects are platform dependent; on Unix systems, see
|
|
1781
|
-
#
|
|
1892
|
+
# <code>chmod(2)</code> for details. Follows symbolic links. Also see
|
|
1893
|
+
# File#lchmod.
|
|
1782
1894
|
#
|
|
1783
1895
|
# f = File.new("out", "w");
|
|
1784
1896
|
# f.chmod(0644) #=> 0
|
|
@@ -1816,18 +1928,18 @@ class File < IO
|
|
|
1816
1928
|
# rdoc-file=file.c
|
|
1817
1929
|
# - flock(locking_constant) -> 0 or false
|
|
1818
1930
|
# -->
|
|
1819
|
-
# Locks or unlocks file
|
|
1931
|
+
# Locks or unlocks file +self+ according to the given `locking_constant`,
|
|
1820
1932
|
# a bitwise OR of the values in the table below.
|
|
1821
1933
|
# Not available on all platforms.
|
|
1822
|
-
# Returns `false` if
|
|
1823
|
-
# blocked;
|
|
1934
|
+
# Returns `false` if <code>File::LOCK_NB</code> is specified and the operation
|
|
1935
|
+
# would have blocked;
|
|
1824
1936
|
# 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 |
|
|
1937
|
+
# Constant | Lock | Effect
|
|
1938
|
+
# ---------------|------------|------------------------------------------------------------------------------------------------------------------
|
|
1939
|
+
# +File::LOCK_EX+| Exclusive | Only one process may hold an exclusive lock for +self+ at a time.
|
|
1940
|
+
# +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>.
|
|
1941
|
+
# +File::LOCK_SH+| Shared | Multiple processes may each hold a shared lock for +self+ at the same time.
|
|
1942
|
+
# +File::LOCK_UN+| Unlock | Remove an existing lock held by this process.
|
|
1831
1943
|
# Example:
|
|
1832
1944
|
# # Update a counter using an exclusive lock.
|
|
1833
1945
|
# # Don't use File::WRONLY because it truncates the file.
|
|
@@ -1931,1006 +2043,3 @@ class File < IO
|
|
|
1931
2043
|
#
|
|
1932
2044
|
def truncate: (int length) -> 0
|
|
1933
2045
|
end
|
|
1934
|
-
|
|
1935
|
-
# <!-- rdoc-file=file.c -->
|
|
1936
|
-
# platform specific alternative separator
|
|
1937
|
-
#
|
|
1938
|
-
File::ALT_SEPARATOR: String?
|
|
1939
|
-
|
|
1940
|
-
# <!-- rdoc-file=file.c -->
|
|
1941
|
-
# path list separator
|
|
1942
|
-
#
|
|
1943
|
-
File::PATH_SEPARATOR: String
|
|
1944
|
-
|
|
1945
|
-
# <!-- rdoc-file=file.c -->
|
|
1946
|
-
# separates directory parts in path
|
|
1947
|
-
#
|
|
1948
|
-
File::SEPARATOR: String
|
|
1949
|
-
|
|
1950
|
-
# <!-- rdoc-file=file.c -->
|
|
1951
|
-
# separates directory parts in path
|
|
1952
|
-
#
|
|
1953
|
-
File::Separator: String
|
|
1954
|
-
|
|
1955
|
-
# <!-- rdoc-file=file.c -->
|
|
1956
|
-
# Module `File::Constants` defines file-related constants.
|
|
1957
|
-
#
|
|
1958
|
-
# There are two families of constants here:
|
|
1959
|
-
#
|
|
1960
|
-
# * Those having to do with [file
|
|
1961
|
-
# access](rdoc-ref:File::Constants@File+Access).
|
|
1962
|
-
# * Those having to do with [filename
|
|
1963
|
-
# globbing](rdoc-ref:File::Constants@Filename+Globbing+Constants+-28File-3A-
|
|
1964
|
-
# 3AFNM_-2A-29).
|
|
1965
|
-
#
|
|
1966
|
-
# File constants defined for the local process may be retrieved with method
|
|
1967
|
-
# File::Constants.constants:
|
|
1968
|
-
#
|
|
1969
|
-
# File::Constants.constants.take(5)
|
|
1970
|
-
# # => [:RDONLY, :WRONLY, :RDWR, :APPEND, :CREAT]
|
|
1971
|
-
#
|
|
1972
|
-
# ## File Access
|
|
1973
|
-
#
|
|
1974
|
-
# File-access constants may be used with optional argument `mode` in calls to
|
|
1975
|
-
# the following methods:
|
|
1976
|
-
#
|
|
1977
|
-
# * File.new.
|
|
1978
|
-
# * File.open.
|
|
1979
|
-
# * IO.for_fd.
|
|
1980
|
-
# * IO.new.
|
|
1981
|
-
# * IO.open.
|
|
1982
|
-
# * IO.popen.
|
|
1983
|
-
# * IO.reopen.
|
|
1984
|
-
# * IO.sysopen.
|
|
1985
|
-
# * StringIO.new.
|
|
1986
|
-
# * StringIO.open.
|
|
1987
|
-
# * StringIO#reopen.
|
|
1988
|
-
#
|
|
1989
|
-
# ### Read/Write Access
|
|
1990
|
-
#
|
|
1991
|
-
# Read-write access for a stream may be specified by a file-access constant.
|
|
1992
|
-
#
|
|
1993
|
-
# The constant may be specified as part of a bitwise OR of other such constants.
|
|
1994
|
-
#
|
|
1995
|
-
# Any combination of the constants in this section may be specified.
|
|
1996
|
-
#
|
|
1997
|
-
# #### File::RDONLY
|
|
1998
|
-
#
|
|
1999
|
-
# Flag File::RDONLY specifies the stream should be opened for reading only:
|
|
2000
|
-
#
|
|
2001
|
-
# filepath = '/tmp/t.tmp'
|
|
2002
|
-
# f = File.new(filepath, File::RDONLY)
|
|
2003
|
-
# f.write('Foo') # Raises IOError (not opened for writing).
|
|
2004
|
-
#
|
|
2005
|
-
# #### File::WRONLY
|
|
2006
|
-
#
|
|
2007
|
-
# Flag File::WRONLY specifies that the stream should be opened for writing only:
|
|
2008
|
-
#
|
|
2009
|
-
# f = File.new(filepath, File::WRONLY)
|
|
2010
|
-
# f.read # Raises IOError (not opened for reading).
|
|
2011
|
-
#
|
|
2012
|
-
# #### File::RDWR
|
|
2013
|
-
#
|
|
2014
|
-
# Flag File::RDWR specifies that the stream should be opened for both reading
|
|
2015
|
-
# and writing:
|
|
2016
|
-
#
|
|
2017
|
-
# f = File.new(filepath, File::RDWR)
|
|
2018
|
-
# f.write('Foo') # => 3
|
|
2019
|
-
# f.rewind # => 0
|
|
2020
|
-
# f.read # => "Foo"
|
|
2021
|
-
#
|
|
2022
|
-
# ### File Positioning
|
|
2023
|
-
#
|
|
2024
|
-
# #### File::APPEND
|
|
2025
|
-
#
|
|
2026
|
-
# Flag File::APPEND specifies that the stream should be opened in append mode.
|
|
2027
|
-
#
|
|
2028
|
-
# Before each write operation, the position is set to end-of-stream. The
|
|
2029
|
-
# modification of the position and the following write operation are performed
|
|
2030
|
-
# as a single atomic step.
|
|
2031
|
-
#
|
|
2032
|
-
# #### File::TRUNC
|
|
2033
|
-
#
|
|
2034
|
-
# Flag File::TRUNC specifies that the stream should be truncated at its
|
|
2035
|
-
# beginning. If the file exists and is successfully opened for writing, it is to
|
|
2036
|
-
# be truncated to position zero; its ctime and mtime are updated.
|
|
2037
|
-
#
|
|
2038
|
-
# There is no effect on a FIFO special file or a terminal device. The effect on
|
|
2039
|
-
# other file types is implementation-defined. The result of using File::TRUNC
|
|
2040
|
-
# with File::RDONLY is undefined.
|
|
2041
|
-
#
|
|
2042
|
-
# ### Creating and Preserving
|
|
2043
|
-
#
|
|
2044
|
-
# #### File::CREAT
|
|
2045
|
-
#
|
|
2046
|
-
# Flag File::CREAT specifies that the stream should be created if it does not
|
|
2047
|
-
# already exist.
|
|
2048
|
-
#
|
|
2049
|
-
# If the file exists:
|
|
2050
|
-
#
|
|
2051
|
-
# - Raise an exception if File::EXCL is also specified.
|
|
2052
|
-
# - Otherwise, do nothing.
|
|
2053
|
-
#
|
|
2054
|
-
# If the file does not exist, then it is created. Upon successful completion,
|
|
2055
|
-
# the atime, ctime, and mtime of the file are updated, and the ctime and mtime
|
|
2056
|
-
# of the parent directory are updated.
|
|
2057
|
-
#
|
|
2058
|
-
# #### File::EXCL
|
|
2059
|
-
#
|
|
2060
|
-
# Flag File::EXCL specifies that the stream should not already exist; If flags
|
|
2061
|
-
# File::CREAT and File::EXCL are both specified and the stream already exists,
|
|
2062
|
-
# an exception is raised.
|
|
2063
|
-
#
|
|
2064
|
-
# The check for the existence and creation of the file is performed as an atomic
|
|
2065
|
-
# operation.
|
|
2066
|
-
#
|
|
2067
|
-
# If both File::EXCL and File::CREAT are specified and the path names a symbolic
|
|
2068
|
-
# link, an exception is raised regardless of the contents of the symbolic link.
|
|
2069
|
-
#
|
|
2070
|
-
# If File::EXCL is specified and File::CREAT is not specified, the result is
|
|
2071
|
-
# undefined.
|
|
2072
|
-
#
|
|
2073
|
-
# ### POSIX File Constants
|
|
2074
|
-
#
|
|
2075
|
-
# Some file-access constants are defined only on POSIX-compliant systems; those
|
|
2076
|
-
# are:
|
|
2077
|
-
#
|
|
2078
|
-
# * File::SYNC.
|
|
2079
|
-
# * File::DSYNC.
|
|
2080
|
-
# * File::RSYNC.
|
|
2081
|
-
# * File::DIRECT.
|
|
2082
|
-
# * File::NOATIME.
|
|
2083
|
-
# * File::NOCTTY.
|
|
2084
|
-
# * File::NOFOLLOW.
|
|
2085
|
-
# * File::TMPFILE.
|
|
2086
|
-
#
|
|
2087
|
-
# #### File::SYNC, File::RSYNC, and File::DSYNC
|
|
2088
|
-
#
|
|
2089
|
-
# Flag File::SYNC, File::RSYNC, or File::DSYNC specifies synchronization of I/O
|
|
2090
|
-
# operations with the underlying file system.
|
|
2091
|
-
#
|
|
2092
|
-
# These flags are valid only for POSIX-compliant systems.
|
|
2093
|
-
#
|
|
2094
|
-
# * File::SYNC specifies that all write operations (both data and metadata)
|
|
2095
|
-
# are immediately to be flushed to the underlying storage device. This means
|
|
2096
|
-
# that the data is written to the storage device, and the file's metadata
|
|
2097
|
-
# (e.g., file size, timestamps, permissions) are also synchronized. This
|
|
2098
|
-
# guarantees that data is safely stored on the storage medium before
|
|
2099
|
-
# returning control to the calling program. This flag can have a significant
|
|
2100
|
-
# impact on performance since it requires synchronous writes, which can be
|
|
2101
|
-
# slower compared to asynchronous writes.
|
|
2102
|
-
#
|
|
2103
|
-
# * File::RSYNC specifies that any read operations on the file will not return
|
|
2104
|
-
# until all outstanding write operations (those that have been issued but
|
|
2105
|
-
# not completed) are also synchronized. This is useful when you want to read
|
|
2106
|
-
# the most up-to-date data, which may still be in the process of being
|
|
2107
|
-
# written.
|
|
2108
|
-
#
|
|
2109
|
-
# * File::DSYNC specifies that all *data* write operations are immediately to
|
|
2110
|
-
# be flushed to the underlying storage device; this differs from File::SYNC,
|
|
2111
|
-
# which requires that *metadata* also be synchronized.
|
|
2112
|
-
#
|
|
2113
|
-
# Note that the behavior of these flags may vary slightly depending on the
|
|
2114
|
-
# operating system and filesystem being used. Additionally, using these flags
|
|
2115
|
-
# can have an impact on performance due to the synchronous nature of the I/O
|
|
2116
|
-
# operations, so they should be used judiciously, especially in
|
|
2117
|
-
# performance-critical applications.
|
|
2118
|
-
#
|
|
2119
|
-
# #### File::NOCTTY
|
|
2120
|
-
#
|
|
2121
|
-
# Flag File::NOCTTY specifies that if the stream is a terminal device, that
|
|
2122
|
-
# device does not become the controlling terminal for the process.
|
|
2123
|
-
#
|
|
2124
|
-
# Defined only for POSIX-compliant systems.
|
|
2125
|
-
#
|
|
2126
|
-
# #### File::DIRECT
|
|
2127
|
-
#
|
|
2128
|
-
# Flag File::DIRECT requests that cache effects of the I/O to and from the
|
|
2129
|
-
# stream be minimized.
|
|
2130
|
-
#
|
|
2131
|
-
# Defined only for POSIX-compliant systems.
|
|
2132
|
-
#
|
|
2133
|
-
# #### File::NOATIME
|
|
2134
|
-
#
|
|
2135
|
-
# Flag File::NOATIME specifies that act of opening the stream should not modify
|
|
2136
|
-
# its access time (atime).
|
|
2137
|
-
#
|
|
2138
|
-
# Defined only for POSIX-compliant systems.
|
|
2139
|
-
#
|
|
2140
|
-
# #### File::NOFOLLOW
|
|
2141
|
-
#
|
|
2142
|
-
# Flag File::NOFOLLOW specifies that if path is a symbolic link, it should not
|
|
2143
|
-
# be followed.
|
|
2144
|
-
#
|
|
2145
|
-
# Defined only for POSIX-compliant systems.
|
|
2146
|
-
#
|
|
2147
|
-
# #### File::TMPFILE
|
|
2148
|
-
#
|
|
2149
|
-
# Flag File::TMPFILE specifies that the opened stream should be a new temporary
|
|
2150
|
-
# file.
|
|
2151
|
-
#
|
|
2152
|
-
# Defined only for POSIX-compliant systems.
|
|
2153
|
-
#
|
|
2154
|
-
# ### Other File-Access Constants
|
|
2155
|
-
#
|
|
2156
|
-
# #### File::NONBLOCK
|
|
2157
|
-
#
|
|
2158
|
-
# When possible, the file is opened in nonblocking mode. Neither the open
|
|
2159
|
-
# operation nor any subsequent I/O operations on the file will cause the calling
|
|
2160
|
-
# process to wait.
|
|
2161
|
-
#
|
|
2162
|
-
# #### File::BINARY
|
|
2163
|
-
#
|
|
2164
|
-
# Flag File::BINARY specifies that the stream is to be accessed in binary mode.
|
|
2165
|
-
#
|
|
2166
|
-
# #### File::SHARE_DELETE
|
|
2167
|
-
#
|
|
2168
|
-
# Flag File::SHARE_DELETE enables other processes to open the stream with delete
|
|
2169
|
-
# access.
|
|
2170
|
-
#
|
|
2171
|
-
# Windows only.
|
|
2172
|
-
#
|
|
2173
|
-
# If the stream is opened for (local) delete access without File::SHARE_DELETE,
|
|
2174
|
-
# and another process attempts to open it with delete access, the attempt fails
|
|
2175
|
-
# and the stream is not opened for that process.
|
|
2176
|
-
#
|
|
2177
|
-
# ## Locking
|
|
2178
|
-
#
|
|
2179
|
-
# Four file constants relate to stream locking; see File#flock:
|
|
2180
|
-
#
|
|
2181
|
-
# #### File::LOCK_EX
|
|
2182
|
-
#
|
|
2183
|
-
# Flag File::LOCK_EX specifies an exclusive lock; only one process a a time may
|
|
2184
|
-
# lock the stream.
|
|
2185
|
-
#
|
|
2186
|
-
# #### File::LOCK_NB
|
|
2187
|
-
#
|
|
2188
|
-
# Flag File::LOCK_NB specifies non-blocking locking for the stream; may be
|
|
2189
|
-
# combined with File::LOCK_EX or File::LOCK_SH.
|
|
2190
|
-
#
|
|
2191
|
-
# #### File::LOCK_SH
|
|
2192
|
-
#
|
|
2193
|
-
# Flag File::LOCK_SH specifies that multiple processes may lock the stream at
|
|
2194
|
-
# the same time.
|
|
2195
|
-
#
|
|
2196
|
-
# #### File::LOCK_UN
|
|
2197
|
-
#
|
|
2198
|
-
# Flag File::LOCK_UN specifies that the stream is not to be locked.
|
|
2199
|
-
#
|
|
2200
|
-
# ## Filename Globbing Constants (File::FNM_*)
|
|
2201
|
-
#
|
|
2202
|
-
# Filename-globbing constants may be used with optional argument `flags` in
|
|
2203
|
-
# calls to the following methods:
|
|
2204
|
-
#
|
|
2205
|
-
# * Dir.glob.
|
|
2206
|
-
# * File.fnmatch.
|
|
2207
|
-
# * Pathname#fnmatch.
|
|
2208
|
-
# * Pathname.glob.
|
|
2209
|
-
# * Pathname#glob.
|
|
2210
|
-
#
|
|
2211
|
-
# The constants are:
|
|
2212
|
-
#
|
|
2213
|
-
# #### File::FNM_CASEFOLD
|
|
2214
|
-
#
|
|
2215
|
-
# Flag File::FNM_CASEFOLD makes patterns case insensitive for File.fnmatch (but
|
|
2216
|
-
# not Dir.glob).
|
|
2217
|
-
#
|
|
2218
|
-
# #### File::FNM_DOTMATCH
|
|
2219
|
-
#
|
|
2220
|
-
# Flag File::FNM_DOTMATCH makes the `'*'` pattern match a filename starting with
|
|
2221
|
-
# `'.'`.
|
|
2222
|
-
#
|
|
2223
|
-
# #### File::FNM_EXTGLOB
|
|
2224
|
-
#
|
|
2225
|
-
# Flag File::FNM_EXTGLOB enables pattern `'{*a*,*b*}'`, which matches pattern
|
|
2226
|
-
# '*a*' and pattern '*b*'; behaves like a [regexp union](rdoc-ref:Regexp.union)
|
|
2227
|
-
# (e.g., `'(?:*a*|*b*)'`):
|
|
2228
|
-
#
|
|
2229
|
-
# pattern = '{LEGAL,BSDL}'
|
|
2230
|
-
# Dir.glob(pattern) # => ["LEGAL", "BSDL"]
|
|
2231
|
-
# Pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
|
|
2232
|
-
# pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
|
|
2233
|
-
#
|
|
2234
|
-
# #### File::FNM_NOESCAPE
|
|
2235
|
-
#
|
|
2236
|
-
# Flag File::FNM_NOESCAPE disables `'\'` escaping.
|
|
2237
|
-
#
|
|
2238
|
-
# #### File::FNM_PATHNAME
|
|
2239
|
-
#
|
|
2240
|
-
# Flag File::FNM_PATHNAME specifies that patterns `'*'` and `'?'` do not match
|
|
2241
|
-
# the directory separator (the value of constant File::SEPARATOR).
|
|
2242
|
-
#
|
|
2243
|
-
# #### File::FNM_SHORTNAME
|
|
2244
|
-
#
|
|
2245
|
-
# Flag File::FNM_SHORTNAME allows patterns to match short names if they exist.
|
|
2246
|
-
#
|
|
2247
|
-
# Windows only.
|
|
2248
|
-
#
|
|
2249
|
-
# #### File::FNM_SYSCASE
|
|
2250
|
-
#
|
|
2251
|
-
# Flag File::FNM_SYSCASE specifies that case sensitivity is the same as in the
|
|
2252
|
-
# underlying operating system; effective for File.fnmatch, but not Dir.glob.
|
|
2253
|
-
#
|
|
2254
|
-
# ## Other Constants
|
|
2255
|
-
#
|
|
2256
|
-
# #### File::NULL
|
|
2257
|
-
#
|
|
2258
|
-
# Flag File::NULL contains the string value of the null device:
|
|
2259
|
-
#
|
|
2260
|
-
# * On a Unix-like OS, `'/dev/null'`.
|
|
2261
|
-
# * On Windows, `'NUL'`.
|
|
2262
|
-
#
|
|
2263
|
-
module File::Constants
|
|
2264
|
-
end
|
|
2265
|
-
|
|
2266
|
-
# <!-- rdoc-file=file.c -->
|
|
2267
|
-
# [File::APPEND](rdoc-ref:File::Constants@File-3A-3AAPPEND)
|
|
2268
|
-
#
|
|
2269
|
-
File::Constants::APPEND: Integer
|
|
2270
|
-
|
|
2271
|
-
# <!-- rdoc-file=file.c -->
|
|
2272
|
-
# [File::BINARY](rdoc-ref:File::Constants@File-3A-3ABINARY)
|
|
2273
|
-
#
|
|
2274
|
-
File::Constants::BINARY: Integer
|
|
2275
|
-
|
|
2276
|
-
# <!-- rdoc-file=file.c -->
|
|
2277
|
-
# [File::CREAT](rdoc-ref:File::Constants@File-3A-3ACREAT)
|
|
2278
|
-
#
|
|
2279
|
-
File::Constants::CREAT: Integer
|
|
2280
|
-
|
|
2281
|
-
# <!-- rdoc-file=file.c -->
|
|
2282
|
-
# [File::DIRECT](rdoc-ref:File::Constants@File-3A-3ADIRECT)
|
|
2283
|
-
#
|
|
2284
|
-
File::Constants::DIRECT: Integer
|
|
2285
|
-
|
|
2286
|
-
# <!-- rdoc-file=file.c -->
|
|
2287
|
-
# [File::DSYNC](rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+an
|
|
2288
|
-
# d+File-3A-3ADSYNC)
|
|
2289
|
-
#
|
|
2290
|
-
File::Constants::DSYNC: Integer
|
|
2291
|
-
|
|
2292
|
-
# <!-- rdoc-file=file.c -->
|
|
2293
|
-
# [File::EXCL](rdoc-ref:File::Constants@File-3A-3AEXCL)
|
|
2294
|
-
#
|
|
2295
|
-
File::Constants::EXCL: Integer
|
|
2296
|
-
|
|
2297
|
-
# <!-- rdoc-file=dir.c -->
|
|
2298
|
-
# [File::FNM_CASEFOLD](rdoc-ref:File::Constants@File-3A-3AFNM_CASEFOLD)
|
|
2299
|
-
#
|
|
2300
|
-
File::Constants::FNM_CASEFOLD: Integer
|
|
2301
|
-
|
|
2302
|
-
# <!-- rdoc-file=dir.c -->
|
|
2303
|
-
# [File::FNM_DOTMATCH](rdoc-ref:File::Constants@File-3A-3AFNM_DOTMATCH)
|
|
2304
|
-
#
|
|
2305
|
-
File::Constants::FNM_DOTMATCH: Integer
|
|
2306
|
-
|
|
2307
|
-
# <!-- rdoc-file=dir.c -->
|
|
2308
|
-
# [File::FNM_EXTGLOB](rdoc-ref:File::Constants@File-3A-3AFNM_EXTGLOB)
|
|
2309
|
-
#
|
|
2310
|
-
File::Constants::FNM_EXTGLOB: Integer
|
|
2311
|
-
|
|
2312
|
-
# <!-- rdoc-file=dir.c -->
|
|
2313
|
-
# [File::FNM_NOESCAPE](rdoc-ref:File::Constants@File-3A-3AFNM_NOESCAPE)
|
|
2314
|
-
#
|
|
2315
|
-
File::Constants::FNM_NOESCAPE: Integer
|
|
2316
|
-
|
|
2317
|
-
# <!-- rdoc-file=dir.c -->
|
|
2318
|
-
# [File::FNM_PATHNAME](rdoc-ref:File::Constants@File-3A-3AFNM_PATHNAME)
|
|
2319
|
-
#
|
|
2320
|
-
File::Constants::FNM_PATHNAME: Integer
|
|
2321
|
-
|
|
2322
|
-
# <!-- rdoc-file=dir.c -->
|
|
2323
|
-
# [File::FNM_SHORTNAME](rdoc-ref:File::Constants@File-3A-3AFNM_SHORTNAME)
|
|
2324
|
-
#
|
|
2325
|
-
File::Constants::FNM_SHORTNAME: Integer
|
|
2326
|
-
|
|
2327
|
-
# <!-- rdoc-file=dir.c -->
|
|
2328
|
-
# [File::FNM_SYSCASE](rdoc-ref:File::Constants@File-3A-3AFNM_SYSCASE)
|
|
2329
|
-
#
|
|
2330
|
-
File::Constants::FNM_SYSCASE: Integer
|
|
2331
|
-
|
|
2332
|
-
# <!-- rdoc-file=file.c -->
|
|
2333
|
-
# [File::LOCK_EX](rdoc-ref:File::Constants@File-3A-3ALOCK_EX)
|
|
2334
|
-
#
|
|
2335
|
-
File::Constants::LOCK_EX: Integer
|
|
2336
|
-
|
|
2337
|
-
# <!-- rdoc-file=file.c -->
|
|
2338
|
-
# [File::LOCK_NB](rdoc-ref:File::Constants@File-3A-3ALOCK_NB)
|
|
2339
|
-
#
|
|
2340
|
-
File::Constants::LOCK_NB: Integer
|
|
2341
|
-
|
|
2342
|
-
# <!-- rdoc-file=file.c -->
|
|
2343
|
-
# [File::LOCK_SH](rdoc-ref:File::Constants@File-3A-3ALOCK_SH)
|
|
2344
|
-
#
|
|
2345
|
-
File::Constants::LOCK_SH: Integer
|
|
2346
|
-
|
|
2347
|
-
# <!-- rdoc-file=file.c -->
|
|
2348
|
-
# [File::LOCK_UN](rdoc-ref:File::Constants@File-3A-3ALOCK_UN)
|
|
2349
|
-
#
|
|
2350
|
-
File::Constants::LOCK_UN: Integer
|
|
2351
|
-
|
|
2352
|
-
# <!-- rdoc-file=file.c -->
|
|
2353
|
-
# [File::NOATIME](rdoc-ref:File::Constants@File-3A-3ANOATIME)
|
|
2354
|
-
#
|
|
2355
|
-
File::Constants::NOATIME: Integer
|
|
2356
|
-
|
|
2357
|
-
# <!-- rdoc-file=file.c -->
|
|
2358
|
-
# [File::NOCTTY](rdoc-ref:File::Constants@File-3A-3ANOCTTY)
|
|
2359
|
-
#
|
|
2360
|
-
File::Constants::NOCTTY: Integer
|
|
2361
|
-
|
|
2362
|
-
# <!-- rdoc-file=file.c -->
|
|
2363
|
-
# [File::NOFOLLOW](rdoc-ref:File::Constants@File-3A-3ANOFOLLOW)
|
|
2364
|
-
#
|
|
2365
|
-
File::Constants::NOFOLLOW: Integer
|
|
2366
|
-
|
|
2367
|
-
# <!-- rdoc-file=file.c -->
|
|
2368
|
-
# [File::NONBLOCK](rdoc-ref:File::Constants@File-3A-3ANONBLOCK)
|
|
2369
|
-
#
|
|
2370
|
-
File::Constants::NONBLOCK: Integer
|
|
2371
|
-
|
|
2372
|
-
# <!-- rdoc-file=file.c -->
|
|
2373
|
-
# [File::NULL](rdoc-ref:File::Constants@File-3A-3ANULL)
|
|
2374
|
-
#
|
|
2375
|
-
File::Constants::NULL: String
|
|
2376
|
-
|
|
2377
|
-
# <!-- rdoc-file=file.c -->
|
|
2378
|
-
# [File::RDONLY](rdoc-ref:File::Constants@File-3A-3ARDONLY)
|
|
2379
|
-
#
|
|
2380
|
-
File::Constants::RDONLY: Integer
|
|
2381
|
-
|
|
2382
|
-
# <!-- rdoc-file=file.c -->
|
|
2383
|
-
# [File::RDWR](rdoc-ref:File::Constants@File-3A-3ARDWR)
|
|
2384
|
-
#
|
|
2385
|
-
File::Constants::RDWR: Integer
|
|
2386
|
-
|
|
2387
|
-
# <!-- rdoc-file=file.c -->
|
|
2388
|
-
# [File::RSYNC](rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+an
|
|
2389
|
-
# d+File-3A-3ADSYNC)
|
|
2390
|
-
#
|
|
2391
|
-
File::Constants::RSYNC: Integer
|
|
2392
|
-
|
|
2393
|
-
# <!-- rdoc-file=file.c -->
|
|
2394
|
-
# [File::SHARE_DELETE](rdoc-ref:File::Constants@File-3A-3ASHARE_DELETE)
|
|
2395
|
-
#
|
|
2396
|
-
File::Constants::SHARE_DELETE: Integer
|
|
2397
|
-
|
|
2398
|
-
# <!-- rdoc-file=file.c -->
|
|
2399
|
-
# [File::SYNC](rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+and
|
|
2400
|
-
# +File-3A-3ADSYNC)
|
|
2401
|
-
#
|
|
2402
|
-
File::Constants::SYNC: Integer
|
|
2403
|
-
|
|
2404
|
-
# <!-- rdoc-file=file.c -->
|
|
2405
|
-
# [File::TMPFILE](rdoc-ref:File::Constants@File-3A-3ATMPFILE)
|
|
2406
|
-
#
|
|
2407
|
-
File::Constants::TMPFILE: Integer
|
|
2408
|
-
|
|
2409
|
-
# <!-- rdoc-file=file.c -->
|
|
2410
|
-
# [File::TRUNC](rdoc-ref:File::Constants@File-3A-3ATRUNC)
|
|
2411
|
-
#
|
|
2412
|
-
File::Constants::TRUNC: Integer
|
|
2413
|
-
|
|
2414
|
-
# <!-- rdoc-file=file.c -->
|
|
2415
|
-
# [File::WRONLY](rdoc-ref:File::Constants@File-3A-3AWRONLY)
|
|
2416
|
-
#
|
|
2417
|
-
File::Constants::WRONLY: Integer
|
|
2418
|
-
|
|
2419
|
-
# <!-- rdoc-file=file.c -->
|
|
2420
|
-
# Objects of class File::Stat encapsulate common status information for File
|
|
2421
|
-
# objects. The information is recorded at the moment the File::Stat object is
|
|
2422
|
-
# created; changes made to the file after that point will not be reflected.
|
|
2423
|
-
# File::Stat objects are returned by IO#stat, File::stat, File#lstat, and
|
|
2424
|
-
# File::lstat. Many of these methods return platform-specific values, and not
|
|
2425
|
-
# all values are meaningful on all systems. See also Kernel#test.
|
|
2426
|
-
#
|
|
2427
|
-
class File::Stat < Object
|
|
2428
|
-
include Comparable
|
|
2429
|
-
|
|
2430
|
-
# <!--
|
|
2431
|
-
# rdoc-file=file.c
|
|
2432
|
-
# - new(p1)
|
|
2433
|
-
# -->
|
|
2434
|
-
# File::Stat.new(file_name) -> stat
|
|
2435
|
-
#
|
|
2436
|
-
# Create a File::Stat object for the given file name (raising an exception if
|
|
2437
|
-
# the file doesn't exist).
|
|
2438
|
-
#
|
|
2439
|
-
def initialize: (String file) -> void
|
|
2440
|
-
|
|
2441
|
-
# <!--
|
|
2442
|
-
# rdoc-file=file.c
|
|
2443
|
-
# - stat <=> other_stat -> -1, 0, 1, nil
|
|
2444
|
-
# -->
|
|
2445
|
-
# Compares File::Stat objects by comparing their respective modification times.
|
|
2446
|
-
#
|
|
2447
|
-
# `nil` is returned if `other_stat` is not a File::Stat object
|
|
2448
|
-
#
|
|
2449
|
-
# f1 = File.new("f1", "w")
|
|
2450
|
-
# sleep 1
|
|
2451
|
-
# f2 = File.new("f2", "w")
|
|
2452
|
-
# f1.stat <=> f2.stat #=> -1
|
|
2453
|
-
#
|
|
2454
|
-
def <=>: (File::Stat other) -> Integer
|
|
2455
|
-
| (untyped) -> nil
|
|
2456
|
-
|
|
2457
|
-
# <!--
|
|
2458
|
-
# rdoc-file=file.c
|
|
2459
|
-
# - stat.atime -> time
|
|
2460
|
-
# -->
|
|
2461
|
-
# Returns the last access time for this file as an object of class Time.
|
|
2462
|
-
#
|
|
2463
|
-
# File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
|
|
2464
|
-
#
|
|
2465
|
-
def atime: () -> Time
|
|
2466
|
-
|
|
2467
|
-
# <!--
|
|
2468
|
-
# rdoc-file=file.c
|
|
2469
|
-
# - stat.birthtime -> time
|
|
2470
|
-
# -->
|
|
2471
|
-
# Returns the birth time for *stat*.
|
|
2472
|
-
#
|
|
2473
|
-
# If the platform doesn't have birthtime, raises NotImplementedError.
|
|
2474
|
-
#
|
|
2475
|
-
# File.write("testfile", "foo")
|
|
2476
|
-
# sleep 10
|
|
2477
|
-
# File.write("testfile", "bar")
|
|
2478
|
-
# sleep 10
|
|
2479
|
-
# File.chmod(0644, "testfile")
|
|
2480
|
-
# sleep 10
|
|
2481
|
-
# File.read("testfile")
|
|
2482
|
-
# File.stat("testfile").birthtime #=> 2014-02-24 11:19:17 +0900
|
|
2483
|
-
# File.stat("testfile").mtime #=> 2014-02-24 11:19:27 +0900
|
|
2484
|
-
# File.stat("testfile").ctime #=> 2014-02-24 11:19:37 +0900
|
|
2485
|
-
# File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900
|
|
2486
|
-
#
|
|
2487
|
-
def birthtime: () -> Time
|
|
2488
|
-
|
|
2489
|
-
# <!--
|
|
2490
|
-
# rdoc-file=file.c
|
|
2491
|
-
# - stat.blksize -> integer or nil
|
|
2492
|
-
# -->
|
|
2493
|
-
# Returns the native file system's block size. Will return `nil` on platforms
|
|
2494
|
-
# that don't support this information.
|
|
2495
|
-
#
|
|
2496
|
-
# File.stat("testfile").blksize #=> 4096
|
|
2497
|
-
#
|
|
2498
|
-
def blksize: () -> Integer?
|
|
2499
|
-
|
|
2500
|
-
# <!--
|
|
2501
|
-
# rdoc-file=file.c
|
|
2502
|
-
# - stat.blockdev? -> true or false
|
|
2503
|
-
# -->
|
|
2504
|
-
# Returns `true` if the file is a block device, `false` if it isn't or if the
|
|
2505
|
-
# operating system doesn't support this feature.
|
|
2506
|
-
#
|
|
2507
|
-
# File.stat("testfile").blockdev? #=> false
|
|
2508
|
-
# File.stat("/dev/hda1").blockdev? #=> true
|
|
2509
|
-
#
|
|
2510
|
-
def blockdev?: () -> bool
|
|
2511
|
-
|
|
2512
|
-
# <!--
|
|
2513
|
-
# rdoc-file=file.c
|
|
2514
|
-
# - stat.blocks -> integer or nil
|
|
2515
|
-
# -->
|
|
2516
|
-
# Returns the number of native file system blocks allocated for this file, or
|
|
2517
|
-
# `nil` if the operating system doesn't support this feature.
|
|
2518
|
-
#
|
|
2519
|
-
# File.stat("testfile").blocks #=> 2
|
|
2520
|
-
#
|
|
2521
|
-
def blocks: () -> Integer?
|
|
2522
|
-
|
|
2523
|
-
# <!--
|
|
2524
|
-
# rdoc-file=file.c
|
|
2525
|
-
# - stat.chardev? -> true or false
|
|
2526
|
-
# -->
|
|
2527
|
-
# Returns `true` if the file is a character device, `false` if it isn't or if
|
|
2528
|
-
# the operating system doesn't support this feature.
|
|
2529
|
-
#
|
|
2530
|
-
# File.stat("/dev/tty").chardev? #=> true
|
|
2531
|
-
#
|
|
2532
|
-
def chardev?: () -> bool
|
|
2533
|
-
|
|
2534
|
-
# <!--
|
|
2535
|
-
# rdoc-file=file.c
|
|
2536
|
-
# - stat.ctime -> time
|
|
2537
|
-
# -->
|
|
2538
|
-
# Returns the change time for *stat* (that is, the time directory information
|
|
2539
|
-
# about the file was changed, not the file itself).
|
|
2540
|
-
#
|
|
2541
|
-
# Note that on Windows (NTFS), returns creation time (birth time).
|
|
2542
|
-
#
|
|
2543
|
-
# File.stat("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003
|
|
2544
|
-
#
|
|
2545
|
-
def ctime: () -> Time
|
|
2546
|
-
|
|
2547
|
-
# <!--
|
|
2548
|
-
# rdoc-file=file.c
|
|
2549
|
-
# - stat.dev -> integer
|
|
2550
|
-
# -->
|
|
2551
|
-
# Returns an integer representing the device on which *stat* resides.
|
|
2552
|
-
#
|
|
2553
|
-
# File.stat("testfile").dev #=> 774
|
|
2554
|
-
#
|
|
2555
|
-
def dev: () -> Integer
|
|
2556
|
-
|
|
2557
|
-
# <!--
|
|
2558
|
-
# rdoc-file=file.c
|
|
2559
|
-
# - stat.dev_major -> integer
|
|
2560
|
-
# -->
|
|
2561
|
-
# Returns the major part of `File_Stat#dev` or `nil`.
|
|
2562
|
-
#
|
|
2563
|
-
# File.stat("/dev/fd1").dev_major #=> 2
|
|
2564
|
-
# File.stat("/dev/tty").dev_major #=> 5
|
|
2565
|
-
#
|
|
2566
|
-
def dev_major: () -> Integer
|
|
2567
|
-
|
|
2568
|
-
# <!--
|
|
2569
|
-
# rdoc-file=file.c
|
|
2570
|
-
# - stat.dev_minor -> integer
|
|
2571
|
-
# -->
|
|
2572
|
-
# Returns the minor part of `File_Stat#dev` or `nil`.
|
|
2573
|
-
#
|
|
2574
|
-
# File.stat("/dev/fd1").dev_minor #=> 1
|
|
2575
|
-
# File.stat("/dev/tty").dev_minor #=> 0
|
|
2576
|
-
#
|
|
2577
|
-
def dev_minor: () -> Integer
|
|
2578
|
-
|
|
2579
|
-
# <!--
|
|
2580
|
-
# rdoc-file=file.c
|
|
2581
|
-
# - stat.directory? -> true or false
|
|
2582
|
-
# -->
|
|
2583
|
-
# Returns `true` if *stat* is a directory, `false` otherwise.
|
|
2584
|
-
#
|
|
2585
|
-
# File.stat("testfile").directory? #=> false
|
|
2586
|
-
# File.stat(".").directory? #=> true
|
|
2587
|
-
#
|
|
2588
|
-
def directory?: () -> bool
|
|
2589
|
-
|
|
2590
|
-
# <!--
|
|
2591
|
-
# rdoc-file=file.c
|
|
2592
|
-
# - stat.executable? -> true or false
|
|
2593
|
-
# -->
|
|
2594
|
-
# Returns `true` if *stat* is executable or if the operating system doesn't
|
|
2595
|
-
# distinguish executable files from nonexecutable files. The tests are made
|
|
2596
|
-
# using the effective owner of the process.
|
|
2597
|
-
#
|
|
2598
|
-
# File.stat("testfile").executable? #=> false
|
|
2599
|
-
#
|
|
2600
|
-
def executable?: () -> bool
|
|
2601
|
-
|
|
2602
|
-
# <!--
|
|
2603
|
-
# rdoc-file=file.c
|
|
2604
|
-
# - stat.executable_real? -> true or false
|
|
2605
|
-
# -->
|
|
2606
|
-
# Same as `executable?`, but tests using the real owner of the process.
|
|
2607
|
-
#
|
|
2608
|
-
def executable_real?: () -> bool
|
|
2609
|
-
|
|
2610
|
-
# <!--
|
|
2611
|
-
# rdoc-file=file.c
|
|
2612
|
-
# - stat.file? -> true or false
|
|
2613
|
-
# -->
|
|
2614
|
-
# Returns `true` if *stat* is a regular file (not a device file, pipe, socket,
|
|
2615
|
-
# etc.).
|
|
2616
|
-
#
|
|
2617
|
-
# File.stat("testfile").file? #=> true
|
|
2618
|
-
#
|
|
2619
|
-
def file?: () -> bool
|
|
2620
|
-
|
|
2621
|
-
# <!--
|
|
2622
|
-
# rdoc-file=file.c
|
|
2623
|
-
# - stat.ftype -> string
|
|
2624
|
-
# -->
|
|
2625
|
-
# Identifies the type of *stat*. The return string is one of: ```file`'',
|
|
2626
|
-
# ```directory`'', ```characterSpecial`'', ```blockSpecial`'', ```fifo`'',
|
|
2627
|
-
# ```link`'', ```socket`'', or ```unknown`''.
|
|
2628
|
-
#
|
|
2629
|
-
# File.stat("/dev/tty").ftype #=> "characterSpecial"
|
|
2630
|
-
#
|
|
2631
|
-
def ftype: () -> String
|
|
2632
|
-
|
|
2633
|
-
# <!--
|
|
2634
|
-
# rdoc-file=file.c
|
|
2635
|
-
# - stat.gid -> integer
|
|
2636
|
-
# -->
|
|
2637
|
-
# Returns the numeric group id of the owner of *stat*.
|
|
2638
|
-
#
|
|
2639
|
-
# File.stat("testfile").gid #=> 500
|
|
2640
|
-
#
|
|
2641
|
-
def gid: () -> Integer
|
|
2642
|
-
|
|
2643
|
-
# <!--
|
|
2644
|
-
# rdoc-file=file.c
|
|
2645
|
-
# - stat.grpowned? -> true or false
|
|
2646
|
-
# -->
|
|
2647
|
-
# Returns true if the effective group id of the process is the same as the group
|
|
2648
|
-
# id of *stat*. On Windows, returns `false`.
|
|
2649
|
-
#
|
|
2650
|
-
# File.stat("testfile").grpowned? #=> true
|
|
2651
|
-
# File.stat("/etc/passwd").grpowned? #=> false
|
|
2652
|
-
#
|
|
2653
|
-
def grpowned?: () -> bool
|
|
2654
|
-
|
|
2655
|
-
# <!--
|
|
2656
|
-
# rdoc-file=file.c
|
|
2657
|
-
# - stat.ino -> integer
|
|
2658
|
-
# -->
|
|
2659
|
-
# Returns the inode number for *stat*.
|
|
2660
|
-
#
|
|
2661
|
-
# File.stat("testfile").ino #=> 1083669
|
|
2662
|
-
#
|
|
2663
|
-
def ino: () -> Integer
|
|
2664
|
-
|
|
2665
|
-
# <!--
|
|
2666
|
-
# rdoc-file=file.c
|
|
2667
|
-
# - stat.inspect -> string
|
|
2668
|
-
# -->
|
|
2669
|
-
# Produce a nicely formatted description of *stat*.
|
|
2670
|
-
#
|
|
2671
|
-
# File.stat("/etc/passwd").inspect
|
|
2672
|
-
# #=> "#<File::Stat dev=0xe000005, ino=1078078, mode=0100644,
|
|
2673
|
-
# # nlink=1, uid=0, gid=0, rdev=0x0, size=1374, blksize=4096,
|
|
2674
|
-
# # blocks=8, atime=Wed Dec 10 10:16:12 CST 2003,
|
|
2675
|
-
# # mtime=Fri Sep 12 15:41:41 CDT 2003,
|
|
2676
|
-
# # ctime=Mon Oct 27 11:20:27 CST 2003,
|
|
2677
|
-
# # birthtime=Mon Aug 04 08:13:49 CDT 2003>"
|
|
2678
|
-
#
|
|
2679
|
-
def inspect: () -> String
|
|
2680
|
-
|
|
2681
|
-
# <!--
|
|
2682
|
-
# rdoc-file=file.c
|
|
2683
|
-
# - stat.mode -> integer
|
|
2684
|
-
# -->
|
|
2685
|
-
# Returns an integer representing the permission bits of *stat*. The meaning of
|
|
2686
|
-
# the bits is platform dependent; on Unix systems, see `stat(2)`.
|
|
2687
|
-
#
|
|
2688
|
-
# File.chmod(0644, "testfile") #=> 1
|
|
2689
|
-
# s = File.stat("testfile")
|
|
2690
|
-
# sprintf("%o", s.mode) #=> "100644"
|
|
2691
|
-
#
|
|
2692
|
-
def mode: () -> Integer
|
|
2693
|
-
|
|
2694
|
-
# <!--
|
|
2695
|
-
# rdoc-file=file.c
|
|
2696
|
-
# - stat.mtime -> time
|
|
2697
|
-
# -->
|
|
2698
|
-
# Returns the modification time of *stat*.
|
|
2699
|
-
#
|
|
2700
|
-
# File.stat("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003
|
|
2701
|
-
#
|
|
2702
|
-
def mtime: () -> Time
|
|
2703
|
-
|
|
2704
|
-
# <!--
|
|
2705
|
-
# rdoc-file=file.c
|
|
2706
|
-
# - stat.nlink -> integer
|
|
2707
|
-
# -->
|
|
2708
|
-
# Returns the number of hard links to *stat*.
|
|
2709
|
-
#
|
|
2710
|
-
# File.stat("testfile").nlink #=> 1
|
|
2711
|
-
# File.link("testfile", "testfile.bak") #=> 0
|
|
2712
|
-
# File.stat("testfile").nlink #=> 2
|
|
2713
|
-
#
|
|
2714
|
-
def nlink: () -> Integer
|
|
2715
|
-
|
|
2716
|
-
# <!--
|
|
2717
|
-
# rdoc-file=file.c
|
|
2718
|
-
# - stat.owned? -> true or false
|
|
2719
|
-
# -->
|
|
2720
|
-
# Returns `true` if the effective user id of the process is the same as the
|
|
2721
|
-
# owner of *stat*.
|
|
2722
|
-
#
|
|
2723
|
-
# File.stat("testfile").owned? #=> true
|
|
2724
|
-
# File.stat("/etc/passwd").owned? #=> false
|
|
2725
|
-
#
|
|
2726
|
-
def owned?: () -> bool
|
|
2727
|
-
|
|
2728
|
-
# <!--
|
|
2729
|
-
# rdoc-file=file.c
|
|
2730
|
-
# - stat.pipe? -> true or false
|
|
2731
|
-
# -->
|
|
2732
|
-
# Returns `true` if the operating system supports pipes and *stat* is a pipe;
|
|
2733
|
-
# `false` otherwise.
|
|
2734
|
-
#
|
|
2735
|
-
def pipe?: () -> bool
|
|
2736
|
-
|
|
2737
|
-
# <!--
|
|
2738
|
-
# rdoc-file=file.c
|
|
2739
|
-
# - stat.rdev -> integer or nil
|
|
2740
|
-
# -->
|
|
2741
|
-
# Returns an integer representing the device type on which *stat* resides.
|
|
2742
|
-
# Returns `nil` if the operating system doesn't support this feature.
|
|
2743
|
-
#
|
|
2744
|
-
# File.stat("/dev/fd1").rdev #=> 513
|
|
2745
|
-
# File.stat("/dev/tty").rdev #=> 1280
|
|
2746
|
-
#
|
|
2747
|
-
def rdev: () -> Integer?
|
|
2748
|
-
|
|
2749
|
-
# <!--
|
|
2750
|
-
# rdoc-file=file.c
|
|
2751
|
-
# - stat.rdev_major -> integer
|
|
2752
|
-
# -->
|
|
2753
|
-
# Returns the major part of `File_Stat#rdev` or `nil`.
|
|
2754
|
-
#
|
|
2755
|
-
# File.stat("/dev/fd1").rdev_major #=> 2
|
|
2756
|
-
# File.stat("/dev/tty").rdev_major #=> 5
|
|
2757
|
-
#
|
|
2758
|
-
def rdev_major: () -> Integer
|
|
2759
|
-
|
|
2760
|
-
# <!--
|
|
2761
|
-
# rdoc-file=file.c
|
|
2762
|
-
# - stat.rdev_minor -> integer
|
|
2763
|
-
# -->
|
|
2764
|
-
# Returns the minor part of `File_Stat#rdev` or `nil`.
|
|
2765
|
-
#
|
|
2766
|
-
# File.stat("/dev/fd1").rdev_minor #=> 1
|
|
2767
|
-
# File.stat("/dev/tty").rdev_minor #=> 0
|
|
2768
|
-
#
|
|
2769
|
-
def rdev_minor: () -> Integer
|
|
2770
|
-
|
|
2771
|
-
# <!--
|
|
2772
|
-
# rdoc-file=file.c
|
|
2773
|
-
# - stat.readable? -> true or false
|
|
2774
|
-
# -->
|
|
2775
|
-
# Returns `true` if *stat* is readable by the effective user id of this process.
|
|
2776
|
-
#
|
|
2777
|
-
# File.stat("testfile").readable? #=> true
|
|
2778
|
-
#
|
|
2779
|
-
def readable?: () -> bool
|
|
2780
|
-
|
|
2781
|
-
# <!--
|
|
2782
|
-
# rdoc-file=file.c
|
|
2783
|
-
# - stat.readable_real? -> true or false
|
|
2784
|
-
# -->
|
|
2785
|
-
# Returns `true` if *stat* is readable by the real user id of this process.
|
|
2786
|
-
#
|
|
2787
|
-
# File.stat("testfile").readable_real? #=> true
|
|
2788
|
-
#
|
|
2789
|
-
def readable_real?: () -> bool
|
|
2790
|
-
|
|
2791
|
-
# <!--
|
|
2792
|
-
# rdoc-file=file.c
|
|
2793
|
-
# - stat.setgid? -> true or false
|
|
2794
|
-
# -->
|
|
2795
|
-
# Returns `true` if *stat* has the set-group-id permission bit set, `false` if
|
|
2796
|
-
# it doesn't or if the operating system doesn't support this feature.
|
|
2797
|
-
#
|
|
2798
|
-
# File.stat("/usr/sbin/lpc").setgid? #=> true
|
|
2799
|
-
#
|
|
2800
|
-
def setgid?: () -> bool
|
|
2801
|
-
|
|
2802
|
-
# <!--
|
|
2803
|
-
# rdoc-file=file.c
|
|
2804
|
-
# - stat.setuid? -> true or false
|
|
2805
|
-
# -->
|
|
2806
|
-
# Returns `true` if *stat* has the set-user-id permission bit set, `false` if it
|
|
2807
|
-
# doesn't or if the operating system doesn't support this feature.
|
|
2808
|
-
#
|
|
2809
|
-
# File.stat("/bin/su").setuid? #=> true
|
|
2810
|
-
#
|
|
2811
|
-
def setuid?: () -> bool
|
|
2812
|
-
|
|
2813
|
-
# <!--
|
|
2814
|
-
# rdoc-file=file.c
|
|
2815
|
-
# - stat.size -> integer
|
|
2816
|
-
# -->
|
|
2817
|
-
# Returns the size of *stat* in bytes.
|
|
2818
|
-
#
|
|
2819
|
-
# File.stat("testfile").size #=> 66
|
|
2820
|
-
#
|
|
2821
|
-
def size: () -> Integer
|
|
2822
|
-
|
|
2823
|
-
# <!--
|
|
2824
|
-
# rdoc-file=file.c
|
|
2825
|
-
# - stat.size? -> Integer or nil
|
|
2826
|
-
# -->
|
|
2827
|
-
# Returns `nil` if *stat* is a zero-length file, the size of the file otherwise.
|
|
2828
|
-
#
|
|
2829
|
-
# File.stat("testfile").size? #=> 66
|
|
2830
|
-
# File.stat(File::NULL).size? #=> nil
|
|
2831
|
-
#
|
|
2832
|
-
def size?: () -> Integer?
|
|
2833
|
-
|
|
2834
|
-
# <!--
|
|
2835
|
-
# rdoc-file=file.c
|
|
2836
|
-
# - stat.socket? -> true or false
|
|
2837
|
-
# -->
|
|
2838
|
-
# Returns `true` if *stat* is a socket, `false` if it isn't or if the operating
|
|
2839
|
-
# system doesn't support this feature.
|
|
2840
|
-
#
|
|
2841
|
-
# File.stat("testfile").socket? #=> false
|
|
2842
|
-
#
|
|
2843
|
-
def socket?: () -> bool
|
|
2844
|
-
|
|
2845
|
-
# <!--
|
|
2846
|
-
# rdoc-file=file.c
|
|
2847
|
-
# - stat.sticky? -> true or false
|
|
2848
|
-
# -->
|
|
2849
|
-
# Returns `true` if *stat* has its sticky bit set, `false` if it doesn't or if
|
|
2850
|
-
# the operating system doesn't support this feature.
|
|
2851
|
-
#
|
|
2852
|
-
# File.stat("testfile").sticky? #=> false
|
|
2853
|
-
#
|
|
2854
|
-
def sticky?: () -> bool
|
|
2855
|
-
|
|
2856
|
-
# <!--
|
|
2857
|
-
# rdoc-file=file.c
|
|
2858
|
-
# - stat.symlink? -> true or false
|
|
2859
|
-
# -->
|
|
2860
|
-
# Returns `true` if *stat* is a symbolic link, `false` if it isn't or if the
|
|
2861
|
-
# operating system doesn't support this feature. As File::stat automatically
|
|
2862
|
-
# follows symbolic links, #symlink? will always be `false` for an object
|
|
2863
|
-
# returned by File::stat.
|
|
2864
|
-
#
|
|
2865
|
-
# File.symlink("testfile", "alink") #=> 0
|
|
2866
|
-
# File.stat("alink").symlink? #=> false
|
|
2867
|
-
# File.lstat("alink").symlink? #=> true
|
|
2868
|
-
#
|
|
2869
|
-
def symlink?: () -> bool
|
|
2870
|
-
|
|
2871
|
-
# <!--
|
|
2872
|
-
# rdoc-file=file.c
|
|
2873
|
-
# - stat.uid -> integer
|
|
2874
|
-
# -->
|
|
2875
|
-
# Returns the numeric user id of the owner of *stat*.
|
|
2876
|
-
#
|
|
2877
|
-
# File.stat("testfile").uid #=> 501
|
|
2878
|
-
#
|
|
2879
|
-
def uid: () -> Integer
|
|
2880
|
-
|
|
2881
|
-
# <!--
|
|
2882
|
-
# rdoc-file=file.c
|
|
2883
|
-
# - stat.world_readable? -> integer or nil
|
|
2884
|
-
# -->
|
|
2885
|
-
# If *stat* is readable by others, returns an integer representing the file
|
|
2886
|
-
# permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
|
|
2887
|
-
# platform dependent; on Unix systems, see `stat(2)`.
|
|
2888
|
-
#
|
|
2889
|
-
# m = File.stat("/etc/passwd").world_readable? #=> 420
|
|
2890
|
-
# sprintf("%o", m) #=> "644"
|
|
2891
|
-
#
|
|
2892
|
-
def world_readable?: () -> Integer?
|
|
2893
|
-
|
|
2894
|
-
# <!--
|
|
2895
|
-
# rdoc-file=file.c
|
|
2896
|
-
# - stat.world_writable? -> integer or nil
|
|
2897
|
-
# -->
|
|
2898
|
-
# If *stat* is writable by others, returns an integer representing the file
|
|
2899
|
-
# permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
|
|
2900
|
-
# platform dependent; on Unix systems, see `stat(2)`.
|
|
2901
|
-
#
|
|
2902
|
-
# m = File.stat("/tmp").world_writable? #=> 511
|
|
2903
|
-
# sprintf("%o", m) #=> "777"
|
|
2904
|
-
#
|
|
2905
|
-
def world_writable?: () -> Integer?
|
|
2906
|
-
|
|
2907
|
-
# <!--
|
|
2908
|
-
# rdoc-file=file.c
|
|
2909
|
-
# - stat.writable? -> true or false
|
|
2910
|
-
# -->
|
|
2911
|
-
# Returns `true` if *stat* is writable by the effective user id of this process.
|
|
2912
|
-
#
|
|
2913
|
-
# File.stat("testfile").writable? #=> true
|
|
2914
|
-
#
|
|
2915
|
-
def writable?: () -> bool
|
|
2916
|
-
|
|
2917
|
-
# <!--
|
|
2918
|
-
# rdoc-file=file.c
|
|
2919
|
-
# - stat.writable_real? -> true or false
|
|
2920
|
-
# -->
|
|
2921
|
-
# Returns `true` if *stat* is writable by the real user id of this process.
|
|
2922
|
-
#
|
|
2923
|
-
# File.stat("testfile").writable_real? #=> true
|
|
2924
|
-
#
|
|
2925
|
-
def writable_real?: () -> bool
|
|
2926
|
-
|
|
2927
|
-
# <!--
|
|
2928
|
-
# rdoc-file=file.c
|
|
2929
|
-
# - stat.zero? -> true or false
|
|
2930
|
-
# -->
|
|
2931
|
-
# Returns `true` if *stat* is a zero-length file; `false` otherwise.
|
|
2932
|
-
#
|
|
2933
|
-
# File.stat("testfile").zero? #=> false
|
|
2934
|
-
#
|
|
2935
|
-
def zero?: () -> bool
|
|
2936
|
-
end
|