steep 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/exe/rbs +1 -1
  4. data/lib/steep/annotation_parser.rb +4 -4
  5. data/lib/steep/ast/buffer.rb +11 -7
  6. data/lib/steep/ast/builtin.rb +8 -0
  7. data/lib/steep/ast/types/factory.rb +55 -55
  8. data/lib/steep/drivers/check.rb +20 -4
  9. data/lib/steep/drivers/langserver.rb +6 -1
  10. data/lib/steep/drivers/vendor.rb +2 -2
  11. data/lib/steep/project/completion_provider.rb +5 -11
  12. data/lib/steep/project/dsl.rb +14 -0
  13. data/lib/steep/project/file.rb +42 -46
  14. data/lib/steep/project/hover_content.rb +11 -5
  15. data/lib/steep/project/options.rb +25 -3
  16. data/lib/steep/project/target.rb +10 -4
  17. data/lib/steep/signature/errors.rb +1 -1
  18. data/lib/steep/signature/validator.rb +8 -8
  19. data/lib/steep/source.rb +1 -1
  20. data/lib/steep/type_construction.rb +987 -711
  21. data/lib/steep/type_inference/constant_env.rb +1 -1
  22. data/lib/steep/type_inference/context.rb +7 -3
  23. data/lib/steep/type_inference/context_array.rb +111 -0
  24. data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
  25. data/lib/steep/type_inference/logic.rb +130 -0
  26. data/lib/steep/type_inference/type_env.rb +5 -69
  27. data/lib/steep/typing.rb +79 -22
  28. data/lib/steep/version.rb +1 -1
  29. data/lib/steep.rb +6 -1
  30. data/smoke/alias/Steepfile +1 -0
  31. data/smoke/and/Steepfile +1 -0
  32. data/smoke/array/Steepfile +1 -0
  33. data/smoke/array/b.rb +0 -2
  34. data/smoke/block/Steepfile +1 -0
  35. data/smoke/case/Steepfile +1 -0
  36. data/smoke/class/Steepfile +1 -0
  37. data/smoke/const/Steepfile +1 -0
  38. data/smoke/dstr/Steepfile +1 -0
  39. data/smoke/ensure/Steepfile +1 -0
  40. data/smoke/enumerator/Steepfile +1 -0
  41. data/smoke/extension/Steepfile +1 -0
  42. data/smoke/extension/c.rb +1 -0
  43. data/smoke/hash/Steepfile +1 -0
  44. data/smoke/hello/Steepfile +1 -0
  45. data/smoke/if/Steepfile +1 -0
  46. data/smoke/if/a.rb +1 -1
  47. data/smoke/implements/Steepfile +1 -0
  48. data/smoke/initialize/Steepfile +1 -0
  49. data/smoke/integer/Steepfile +1 -0
  50. data/smoke/interface/Steepfile +1 -0
  51. data/smoke/kwbegin/Steepfile +1 -0
  52. data/smoke/lambda/Steepfile +1 -0
  53. data/smoke/literal/Steepfile +1 -0
  54. data/smoke/map/Steepfile +1 -0
  55. data/smoke/method/Steepfile +1 -0
  56. data/smoke/module/Steepfile +1 -0
  57. data/smoke/regexp/Steepfile +1 -0
  58. data/smoke/regression/Steepfile +1 -0
  59. data/smoke/rescue/Steepfile +1 -0
  60. data/smoke/rescue/a.rb +1 -1
  61. data/smoke/self/Steepfile +1 -0
  62. data/smoke/skip/Steepfile +1 -0
  63. data/smoke/stdout/Steepfile +1 -0
  64. data/smoke/super/Steepfile +1 -0
  65. data/smoke/type_case/Steepfile +1 -0
  66. data/smoke/yield/Steepfile +1 -0
  67. data/steep.gemspec +1 -1
  68. data/vendor/ruby-signature/.gitignore +2 -2
  69. data/vendor/ruby-signature/README.md +2 -2
  70. data/vendor/ruby-signature/Rakefile +2 -2
  71. data/vendor/ruby-signature/bin/annotate-with-rdoc +14 -13
  72. data/vendor/ruby-signature/bin/console +1 -1
  73. data/vendor/ruby-signature/bin/sort +7 -6
  74. data/vendor/ruby-signature/bin/test_runner.rb +0 -1
  75. data/vendor/ruby-signature/docs/CONTRIBUTING.md +1 -1
  76. data/vendor/ruby-signature/docs/sigs.md +3 -3
  77. data/vendor/ruby-signature/docs/stdlib.md +1 -1
  78. data/vendor/ruby-signature/docs/syntax.md +9 -9
  79. data/vendor/ruby-signature/exe/rbs +5 -1
  80. data/vendor/ruby-signature/lib/rbs/ast/annotation.rb +27 -0
  81. data/vendor/ruby-signature/lib/rbs/ast/comment.rb +27 -0
  82. data/vendor/ruby-signature/lib/rbs/ast/declarations.rb +395 -0
  83. data/vendor/ruby-signature/lib/rbs/ast/members.rb +362 -0
  84. data/vendor/ruby-signature/lib/rbs/buffer.rb +50 -0
  85. data/vendor/ruby-signature/lib/rbs/builtin_names.rb +55 -0
  86. data/vendor/ruby-signature/lib/rbs/cli.rb +558 -0
  87. data/vendor/ruby-signature/lib/rbs/constant.rb +26 -0
  88. data/vendor/ruby-signature/lib/rbs/constant_table.rb +150 -0
  89. data/vendor/ruby-signature/lib/rbs/definition.rb +170 -0
  90. data/vendor/ruby-signature/lib/rbs/definition_builder.rb +919 -0
  91. data/vendor/ruby-signature/lib/rbs/environment.rb +281 -0
  92. data/vendor/ruby-signature/lib/rbs/environment_loader.rb +136 -0
  93. data/vendor/ruby-signature/lib/rbs/environment_walker.rb +124 -0
  94. data/vendor/ruby-signature/lib/rbs/errors.rb +187 -0
  95. data/vendor/ruby-signature/lib/rbs/location.rb +102 -0
  96. data/vendor/ruby-signature/lib/rbs/method_type.rb +123 -0
  97. data/vendor/ruby-signature/lib/rbs/namespace.rb +91 -0
  98. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.rb +21 -23
  99. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/parser.y +18 -18
  100. data/vendor/ruby-signature/lib/rbs/prototype/rb.rb +553 -0
  101. data/vendor/ruby-signature/lib/rbs/prototype/rbi.rb +587 -0
  102. data/vendor/ruby-signature/lib/rbs/prototype/runtime.rb +381 -0
  103. data/vendor/ruby-signature/lib/rbs/substitution.rb +46 -0
  104. data/vendor/ruby-signature/lib/rbs/test/errors.rb +61 -0
  105. data/vendor/ruby-signature/lib/rbs/test/hook.rb +294 -0
  106. data/vendor/ruby-signature/lib/{ruby/signature → rbs}/test/setup.rb +7 -7
  107. data/vendor/ruby-signature/lib/rbs/test/spy.rb +325 -0
  108. data/vendor/ruby-signature/lib/rbs/test/test_helper.rb +183 -0
  109. data/vendor/ruby-signature/lib/rbs/test/type_check.rb +254 -0
  110. data/vendor/ruby-signature/lib/rbs/test.rb +26 -0
  111. data/vendor/ruby-signature/lib/rbs/type_name.rb +70 -0
  112. data/vendor/ruby-signature/lib/rbs/types.rb +936 -0
  113. data/vendor/ruby-signature/lib/rbs/variance_calculator.rb +138 -0
  114. data/vendor/ruby-signature/lib/rbs/vendorer.rb +47 -0
  115. data/vendor/ruby-signature/lib/rbs/version.rb +3 -0
  116. data/vendor/ruby-signature/lib/rbs/writer.rb +269 -0
  117. data/vendor/ruby-signature/lib/rbs.rb +64 -0
  118. data/vendor/ruby-signature/lib/ruby/signature.rb +4 -61
  119. data/vendor/ruby-signature/{ruby-signature.gemspec → rbs.gemspec} +4 -4
  120. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +58 -1
  121. data/vendor/ruby-signature/stdlib/base64/base64.rbs +69 -13
  122. data/vendor/ruby-signature/stdlib/benchmark/benchmark.rbs +372 -0
  123. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +9 -0
  124. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +1 -7
  125. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +2 -1
  126. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +3 -2
  127. data/vendor/ruby-signature/stdlib/builtin/file.rbs +902 -302
  128. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +190 -68
  129. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +3 -6
  130. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +6 -4
  131. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +146 -120
  132. data/vendor/ruby-signature/stdlib/builtin/math.rbs +310 -7
  133. data/vendor/ruby-signature/stdlib/builtin/method.rbs +11 -8
  134. data/vendor/ruby-signature/stdlib/builtin/module.rbs +959 -103
  135. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +3 -0
  136. data/vendor/ruby-signature/stdlib/builtin/process.rbs +981 -108
  137. data/vendor/ruby-signature/stdlib/builtin/random.rbs +215 -41
  138. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +47 -0
  139. data/vendor/ruby-signature/stdlib/builtin/string.rbs +9 -2
  140. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +282 -11
  141. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +11 -13
  142. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +25 -29
  143. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +1 -1
  144. data/vendor/ruby-signature/stdlib/builtin/time.rbs +875 -567
  145. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +243 -44
  146. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +103 -109
  147. data/vendor/ruby-signature/stdlib/coverage/coverage.rbs +62 -0
  148. data/vendor/ruby-signature/stdlib/csv/csv.rbs +773 -0
  149. data/vendor/ruby-signature/stdlib/erb/erb.rbs +375 -1
  150. data/vendor/ruby-signature/stdlib/find/find.rbs +0 -4
  151. data/vendor/ruby-signature/stdlib/ipaddr/ipaddr.rbs +247 -0
  152. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +1088 -16
  153. data/vendor/ruby-signature/stdlib/set/set.rbs +251 -27
  154. metadata +49 -44
  155. data/exe/ruby-signature +0 -3
  156. data/vendor/ruby-signature/exe/ruby-signature +0 -7
  157. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
  158. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
  159. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
  160. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
  161. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
  162. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
  163. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -555
  164. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
  165. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
  166. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
  167. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
  168. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
  169. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
  170. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
  171. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
  172. data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
  173. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
  174. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
  175. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -444
  176. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
  177. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
  178. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
  179. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
  180. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
  181. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -327
  182. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
  183. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
  184. data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
  185. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
  186. data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
  187. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
  188. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
  189. data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
  190. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
@@ -1,324 +1,925 @@
1
- # A `File` is an abstraction of any file object accessible by the program
2
- # and is closely associated with class `IO` . `File` includes the methods
3
- # of module `FileTest` as class methods, allowing you to write (for
4
- # example) `File.exist?("foo")` .
5
- #
6
- # In the description of [File](File) methods,
7
- # *permission bits* are a platform-specific set of bits that indicate
8
- # permissions of a file. On Unix-based systems, permissions are viewed as
9
- # a set of three octets, for the owner, the group, and the rest of the
10
- # world. For each of these entities, permissions may be set to read,
11
- # write, or execute the file:
12
- #
13
- # The permission bits `0644` (in octal) would thus be interpreted as
14
- # read/write for owner, and read-only for group and other. Higher-order
15
- # bits may also be used to indicate the type of file (plain, directory,
16
- # pipe, socket, and so on) and various other special features. If the
17
- # permissions are for a directory, the meaning of the execute bit changes;
18
- # when set the directory can be searched.
19
- #
20
- # On non-Posix operating systems, there may be only the ability to make a
21
- # file read-only or read-write. In this case, the remaining permission
22
- # bits will be synthesized to resemble typical values. For instance, on
23
- # Windows NT the default permission bits are `0644`, which means
24
- # read/write for owner, read-only for all others. The only change that can
25
- # be made is to make the file read-only, which is reported as `0444` .
26
- #
27
- # Various constants for the methods in [File](File)
28
- # can be found in
29
- # [File::Constants](https://ruby-doc.org/core-2.6.3/File/Constants.html).
1
+ # A File is an abstraction of any file object accessible by the program and is
2
+ # closely associated with class IO. File includes the methods of module
3
+ # FileTest as class methods, allowing you to write (for example)
4
+ # `File.exist?("foo")`.
5
+ #
6
+ # In the description of File methods, *permission bits* are a platform-specific
7
+ # set of bits that indicate permissions of a file. On Unix-based systems,
8
+ # permissions are viewed as a set of three octets, for the owner, the group, and
9
+ # the rest of the world. For each of these entities, permissions may be set to
10
+ # read, write, or execute the file:
11
+ #
12
+ # The permission bits `0644` (in octal) would thus be interpreted as read/write
13
+ # for owner, and read-only for group and other. Higher-order bits may also be
14
+ # used to indicate the type of file (plain, directory, pipe, socket, and so on)
15
+ # and various other special features. If the permissions are for a directory,
16
+ # the meaning of the execute bit changes; when set the directory can be
17
+ # searched.
18
+ #
19
+ # On non-Posix operating systems, there may be only the ability to make a file
20
+ # read-only or read-write. In this case, the remaining permission bits will be
21
+ # synthesized to resemble typical values. For instance, on Windows NT the
22
+ # default permission bits are `0644`, which means read/write for owner,
23
+ # read-only for all others. The only change that can be made is to make the file
24
+ # read-only, which is reported as `0444`.
25
+ #
26
+ # Various constants for the methods in File can be found in File::Constants.
27
+ #
30
28
  class File < IO
31
- def self.absolute_path: (String file, ?String dir) -> String
32
-
33
- def self.atime: (untyped file) -> Time
34
-
35
- def self.basename: (String file, ?String suffix) -> String
36
-
37
- def self.binread: (String arg0) -> String
38
- | (String arg0, ?Integer arg1) -> String
39
- | (String arg0, ?Integer arg1, ?Integer arg2) -> String
40
-
41
- def self.birthtime: (untyped file) -> Time
42
-
43
- def self.blockdev?: (String | IO file) -> bool
44
-
45
- def self.chardev?: (String | IO file) -> bool
46
-
47
- def self.chmod: (Integer mode, *String files) -> Integer
48
-
49
- def self.chown: (Integer owner, Integer group, *String files) -> Integer
50
-
51
- def self.ctime: (untyped file) -> Time
52
-
53
- def self.delete: (*String files) -> Integer
54
-
55
- def self.directory?: (String | IO file) -> bool
56
-
57
- def self.dirname: (String file) -> String
58
-
59
- def self.executable?: (String file) -> bool
60
-
61
- def self.executable_real?: (String file) -> bool
62
-
63
- def self.exist?: (untyped file) -> bool
64
-
65
- def self.expand_path: (untyped file, ?untyped dir) -> String
66
-
67
- def self.extname: (String path) -> String
68
-
69
- def self.file?: (String | IO file) -> bool
70
-
71
- def self.fnmatch: (String pattern, String path, ?Integer flags) -> bool
72
-
73
- def self.`ftype`: (String file) -> String
74
-
75
- def self.grpowned?: (String | IO file) -> bool
76
-
77
- def self.identical?: (String | IO file_1, String | IO file_2) -> bool
78
-
79
- def self.join: (*untyped arg0) -> String
80
-
81
- def self.lchmod: (Integer mode, *String files) -> Integer
82
-
83
- def self.lchown: (Integer owner, Integer group, *String files) -> Integer
84
-
85
- def self.link: (String old, String new) -> Integer
86
-
87
- def self.lstat: (String file) -> File::Stat
88
-
89
- def self.mtime: (untyped file) -> Time
90
-
91
- def self.owned?: (String file) -> bool
92
-
93
- def self.path: (String path) -> String
94
-
95
- def self.pipe?: (String file) -> bool
96
-
97
- def self.readable?: (String file) -> bool
98
-
99
- def self.readable_real?: (String file) -> bool
100
-
101
- def self.readlink: (String link) -> String
102
-
103
- def self.realdirpath: (String pathname, ?String dir) -> String
104
-
105
- def self.realpath: (String pathname, ?String dir) -> String
106
-
107
- def self.rename: (String old, String new) -> Integer
108
-
109
- def self.setgid?: (String file) -> bool
110
-
111
- def self.setuid?: (String file) -> bool
112
-
113
- def self.size: (String | IO file) -> Integer
114
-
115
- def self.size?: (String | IO file) -> Integer?
116
-
117
- def self.socket?: (String | IO file) -> bool
118
-
119
- def self.split: (String file) -> [ String, String ]
120
-
121
- def self.stat: (untyped file) -> File::Stat
122
-
123
- def self.sticky?: (String file) -> bool
124
-
125
- def self.symlink: (String old, String new) -> Integer
126
-
127
- def self.symlink?: (String file) -> bool
128
-
129
- def self.truncate: (String file, Integer arg0) -> Integer
130
-
131
- def self.umask: (?Integer arg0) -> Integer
132
-
133
- def self.utime: (Time atime, Time mtime, *String files) -> Integer
134
-
135
- def self.world_readable?: (String | IO file) -> Integer?
136
-
137
- def self.world_writable?: (String | IO file) -> Integer?
138
-
139
- def self.writable?: (String file) -> Integer?
140
-
141
- def self.writable_real?: (String file) -> Integer?
142
-
143
- def self.zero?: (String | IO file) -> Integer?
144
-
145
- # Returns the last access time (a `Time` object) for *file* , or epoch if
146
- # *file* has not been accessed.
147
- #
148
- # ```ruby
149
- # File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
150
- # ```
29
+ # Opens the file named by `filename` according to the given `mode` and returns a
30
+ # new File object.
31
+ #
32
+ # See IO.new for a description of `mode` and `opt`.
33
+ #
34
+ # If a file is being created, permission bits may be given in `perm`. These
35
+ # mode and permission bits are platform dependent; on Unix systems, see open(2)
36
+ # and chmod(2) man pages for details.
37
+ #
38
+ # The new File object is buffered mode (or non-sync mode), unless `filename` is
39
+ # a tty. See IO#flush, IO#fsync, IO#fdatasync, and IO#sync= about sync mode.
40
+ #
41
+ # ### Examples
42
+ #
43
+ # f = File.new("testfile", "r")
44
+ # f = File.new("newfile", "w+")
45
+ # f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
46
+ #
47
+ def initialize: (string | _ToPath | int file_name, ?(string | int) mode, ?int perm) -> File
48
+
49
+ # Converts a pathname to an absolute pathname. Relative paths are referenced
50
+ # from the current working directory of the process unless *dir_string* is
51
+ # given, in which case it will be used as the starting point. If the given
52
+ # pathname starts with a ```~`'' it is NOT expanded, it is treated as a normal
53
+ # directory name.
54
+ #
55
+ # File.absolute_path("~oracle/bin") #=> "<relative_path>/~oracle/bin"
56
+ #
57
+ def self.absolute_path: (string | _ToPath file_name, ?(string | _ToPath) dir_string) -> String
58
+
59
+ # Returns `true` if `file_name` is an absolute path, and `false` otherwise.
60
+ #
61
+ # File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
62
+ #
63
+ # # arglists 💪👽🚨 << Delete this section
64
+ # File.absolute_path?(file_name) -> true or false
65
+ #
66
+ def self.absolute_path?: (string | _ToPath file_name) -> bool
67
+
68
+ # Returns the last access time for the named file as a Time object.
69
+ #
70
+ # *file_name* can be an IO object.
71
+ #
72
+ # File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003
73
+ #
74
+ def self.atime: (string | _ToPath | IO file_name) -> Time
75
+
76
+ # Returns the last component of the filename given in *file_name* (after first
77
+ # stripping trailing separators), which can be formed using both File::SEPARATOR
78
+ # and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not
79
+ # `nil`. If *suffix* is given and present at the end of *file_name*, it is
80
+ # removed. If *suffix* is ".*", any extension will be removed.
81
+ #
82
+ # File.basename("/home/gumby/work/ruby.rb") #=> "ruby.rb"
83
+ # File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
84
+ # File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby"
85
+ #
86
+ def self.basename: (string | _ToPath file_name, ?string suffix) -> String
87
+
88
+ def self.birthtime: (string | _ToPath | IO file_name) -> Time
89
+
90
+ # Returns `true` if the named file is a block device.
91
+ #
92
+ # *file_name* can be an IO object.
93
+ #
94
+ def self.blockdev?: (string | _ToPath | IO file_name) -> bool
95
+
96
+ # Returns `true` if the named file is a character device.
97
+ #
98
+ # *file_name* can be an IO object.
99
+ #
100
+ def self.chardev?: (string | _ToPath | IO file_name) -> bool
101
+
102
+ # Changes permission bits on the named file(s) to the bit pattern represented by
103
+ # *mode_int*. Actual effects are operating system dependent (see the beginning
104
+ # of this section). On Unix systems, see `chmod(2)` for details. Returns the
105
+ # number of files processed.
106
+ #
107
+ # File.chmod(0644, "testfile", "out") #=> 2
108
+ #
109
+ def self.chmod: (int mode, *(string | _ToPath) file_name) -> Integer
110
+
111
+ # Changes the owner and group of the named file(s) to the given numeric owner
112
+ # and group id's. Only a process with superuser privileges may change the owner
113
+ # of a file. The current owner of a file may change the file's group to any
114
+ # group to which the owner belongs. A `nil` or -1 owner or group id is ignored.
115
+ # Returns the number of files processed.
116
+ #
117
+ # File.chown(nil, 100, "testfile")
118
+ #
119
+ def self.chown: (int? owner, int? group, *(string | _ToPath) file_name) -> Integer
120
+
121
+ # Returns the change time for the named file (the time at which directory
122
+ # information about the file was changed, not the file itself).
123
+ #
124
+ # *file_name* can be an IO object.
125
+ #
126
+ # Note that on Windows (NTFS), returns creation time (birth time).
127
+ #
128
+ # File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
129
+ #
130
+ def self.ctime: (string | _ToPath | IO file_name) -> Time
131
+
132
+ # Deletes the named files, returning the number of names passed as arguments.
133
+ # Raises an exception on any error. Since the underlying implementation relies
134
+ # on the `unlink(2)` system call, the type of exception raised depends on its
135
+ # error type (see https://linux.die.net/man/2/unlink) and has the form of e.g.
136
+ # Errno::ENOENT.
137
+ #
138
+ # See also Dir::rmdir.
139
+ #
140
+ alias self.delete self.unlink
141
+
142
+ # Returns `true` if the named file is a directory, or a symlink that points at a
143
+ # directory, and `false` otherwise.
144
+ #
145
+ # *file_name* can be an IO object.
146
+ #
147
+ # File.directory?(".")
148
+ #
149
+ def self.directory?: (string | _ToPath | IO path) -> bool
150
+
151
+ # Returns all components of the filename given in *file_name* except the last
152
+ # one (after first stripping trailing separators). The filename can be formed
153
+ # using both File::SEPARATOR and File::ALT_SEPARATOR as the separator when
154
+ # File::ALT_SEPARATOR is not `nil`.
155
+ #
156
+ # File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work"
157
+ #
158
+ def self.dirname: (string | _ToPath file_name) -> String
159
+
160
+ # Returns `true` if the named file exists and has a zero size.
161
+ #
162
+ # *file_name* can be an IO object.
163
+ #
164
+ alias self.empty? self.zero?
165
+
166
+ # Returns `true` if the named file is executable by the effective user and group
167
+ # id of this process. See eaccess(3).
168
+ #
169
+ # Windows does not support execute permissions separately from read permissions.
170
+ # On Windows, a file is only considered executable if it ends in .bat, .cmd,
171
+ # .com, or .exe.
172
+ #
173
+ # Note that some OS-level security features may cause this to return true even
174
+ # though the file is not executable by the effective user/group.
175
+ #
176
+ def self.executable?: (string | _ToPath file_name) -> bool
177
+
178
+ # Returns `true` if the named file is executable by the real user and group id
179
+ # of this process. See access(3).
180
+ #
181
+ # Windows does not support execute permissions separately from read permissions.
182
+ # On Windows, a file is only considered executable if it ends in .bat, .cmd,
183
+ # .com, or .exe.
184
+ #
185
+ # Note that some OS-level security features may cause this to return true even
186
+ # though the file is not executable by the real user/group.
187
+ #
188
+ def self.executable_real?: (string | _ToPath file_name) -> bool
189
+
190
+ # Return `true` if the named file exists.
191
+ #
192
+ # *file_name* can be an IO object.
193
+ #
194
+ # "file exists" means that stat() or fstat() system call is successful.
195
+ #
196
+ def self.exist?: (string | _ToPath | IO file_name) -> bool
197
+
198
+ # Deprecated method. Don't use.
199
+ #
200
+ alias self.exists? self.exist?
201
+
202
+ # Converts a pathname to an absolute pathname. Relative paths are referenced
203
+ # from the current working directory of the process unless `dir_string` is
204
+ # given, in which case it will be used as the starting point. The given pathname
205
+ # may start with a ```~`'', which expands to the process owner's home directory
206
+ # (the environment variable `HOME` must be set correctly). ```~`*user*'' expands
207
+ # to the named user's home directory.
208
+ #
209
+ # File.expand_path("~oracle/bin") #=> "/home/oracle/bin"
210
+ #
211
+ # A simple example of using `dir_string` is as follows.
212
+ # File.expand_path("ruby", "/usr/bin") #=> "/usr/bin/ruby"
213
+ #
214
+ # A more complex example which also resolves parent directory is as follows.
215
+ # Suppose we are in bin/mygem and want the absolute path of lib/mygem.rb.
216
+ #
217
+ # File.expand_path("../../lib/mygem.rb", __FILE__)
218
+ # #=> ".../path/to/project/lib/mygem.rb"
219
+ #
220
+ # So first it resolves the parent of __FILE__, that is bin/, then go to the
221
+ # parent, the root of the project and appends `lib/mygem.rb`.
222
+ #
223
+ def self.expand_path: (string | _ToPath file_name, ?(string | _ToPath) dir_string) -> String
224
+
225
+ # Returns the extension (the portion of file name in `path` starting from the
226
+ # last period).
227
+ #
228
+ # If `path` is a dotfile, or starts with a period, then the starting dot is not
229
+ # dealt with the start of the extension.
230
+ #
231
+ # An empty string will also be returned when the period is the last character in
232
+ # `path`.
233
+ #
234
+ # On Windows, trailing dots are truncated.
235
+ #
236
+ # File.extname("test.rb") #=> ".rb"
237
+ # File.extname("a/b/d/test.rb") #=> ".rb"
238
+ # File.extname(".a/b/d/test.rb") #=> ".rb"
239
+ # File.extname("foo.") #=> "" on Windows
240
+ # File.extname("foo.") #=> "." on non-Windows
241
+ # File.extname("test") #=> ""
242
+ # File.extname(".profile") #=> ""
243
+ # File.extname(".profile.sh") #=> ".sh"
244
+ #
245
+ def self.extname: (string | _ToPath path) -> String
246
+
247
+ # Returns `true` if the named `file` exists and is a regular file.
248
+ #
249
+ # `file` can be an IO object.
250
+ #
251
+ # If the `file` argument is a symbolic link, it will resolve the symbolic link
252
+ # and use the file referenced by the link.
253
+ #
254
+ def self.file?: (string | _ToPath | IO file) -> bool
255
+
256
+ # Returns true if `path` matches against `pattern`. The pattern is not a
257
+ # regular expression; instead it follows rules similar to shell filename
258
+ # globbing. It may contain the following metacharacters:
259
+ #
260
+ # `*`
261
+ # : Matches any file. Can be restricted by other values in the glob.
262
+ # Equivalent to `/ .* /x` in regexp.
263
+ #
264
+ # `*`
265
+ # : Matches all files regular files
266
+ # `c*`
267
+ # : Matches all files beginning with `c`
268
+ # `*c`
269
+ # : Matches all files ending with `c`
270
+ # `*c*`
271
+ # : Matches all files that have `c` in them (including at the beginning or
272
+ # end).
273
+ #
274
+ #
275
+ # To match hidden files (that start with a `.` set the File::FNM_DOTMATCH
276
+ # flag.
277
+ #
278
+ # `**`
279
+ # : Matches directories recursively or files expansively.
280
+ #
281
+ # `?`
282
+ # : Matches any one character. Equivalent to `/.{1}/` in regexp.
283
+ #
284
+ # `[set]`
285
+ # : Matches any one character in `set`. Behaves exactly like character sets
286
+ # in Regexp, including set negation (`[^a-z]`).
287
+ #
288
+ # ` \ `
289
+ # : Escapes the next metacharacter.
290
+ #
291
+ # `{a,b}`
292
+ # : Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled.
293
+ # Behaves like a Regexp union (`(?:a|b)`).
294
+ #
295
+ #
296
+ # `flags` is a bitwise OR of the `FNM_XXX` constants. The same glob pattern and
297
+ # flags are used by Dir::glob.
298
+ #
299
+ # Examples:
300
+ #
301
+ # File.fnmatch('cat', 'cat') #=> true # match entire string
302
+ # File.fnmatch('cat', 'category') #=> false # only match partial string
303
+ #
304
+ # File.fnmatch('c{at,ub}s', 'cats') #=> false # { } isn't supported by default
305
+ # File.fnmatch('c{at,ub}s', 'cats', File::FNM_EXTGLOB) #=> true # { } is supported on FNM_EXTGLOB
306
+ #
307
+ # File.fnmatch('c?t', 'cat') #=> true # '?' match only 1 character
308
+ # File.fnmatch('c??t', 'cat') #=> false # ditto
309
+ # File.fnmatch('c*', 'cats') #=> true # '*' match 0 or more characters
310
+ # File.fnmatch('c*t', 'c/a/b/t') #=> true # ditto
311
+ # File.fnmatch('ca[a-z]', 'cat') #=> true # inclusive bracket expression
312
+ # File.fnmatch('ca[^t]', 'cat') #=> false # exclusive bracket expression ('^' or '!')
313
+ #
314
+ # File.fnmatch('cat', 'CAT') #=> false # case sensitive
315
+ # File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true # case insensitive
316
+ # File.fnmatch('cat', 'CAT', File::FNM_SYSCASE) #=> true or false # depends on the system default
317
+ #
318
+ # File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false # wildcard doesn't match '/' on FNM_PATHNAME
319
+ # File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false # ditto
320
+ # File.fnmatch('[/]', '/', File::FNM_PATHNAME) #=> false # ditto
321
+ #
322
+ # File.fnmatch('\?', '?') #=> true # escaped wildcard becomes ordinary
323
+ # File.fnmatch('\a', 'a') #=> true # escaped ordinary remains ordinary
324
+ # File.fnmatch('\a', '\a', File::FNM_NOESCAPE) #=> true # FNM_NOESCAPE makes '\' ordinary
325
+ # File.fnmatch('[\?]', '?') #=> true # can escape inside bracket expression
326
+ #
327
+ # File.fnmatch('*', '.profile') #=> false # wildcard doesn't match leading
328
+ # File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default.
329
+ # File.fnmatch('.*', '.profile') #=> true
330
+ #
331
+ # rbfiles = '**' '/' '*.rb' # you don't have to do like this. just write in single string.
332
+ # File.fnmatch(rbfiles, 'main.rb') #=> false
333
+ # File.fnmatch(rbfiles, './main.rb') #=> false
334
+ # File.fnmatch(rbfiles, 'lib/song.rb') #=> true
335
+ # File.fnmatch('**.rb', 'main.rb') #=> true
336
+ # File.fnmatch('**.rb', './main.rb') #=> false
337
+ # File.fnmatch('**.rb', 'lib/song.rb') #=> true
338
+ # File.fnmatch('*', 'dave/.profile') #=> true
339
+ #
340
+ # pattern = '*' '/' '*'
341
+ # File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false
342
+ # File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
343
+ #
344
+ # pattern = '**' '/' 'foo'
345
+ # File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME) #=> true
346
+ # File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME) #=> true
347
+ # File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true
348
+ # File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
349
+ # File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
350
+ #
351
+ def self.fnmatch: (string pattern, string | _ToPath path, ?int flags) -> bool
352
+
353
+ # Returns true if `path` matches against `pattern`. The pattern is not a
354
+ # regular expression; instead it follows rules similar to shell filename
355
+ # globbing. It may contain the following metacharacters:
356
+ #
357
+ # `*`
358
+ # : Matches any file. Can be restricted by other values in the glob.
359
+ # Equivalent to `/ .* /x` in regexp.
360
+ #
361
+ # `*`
362
+ # : Matches all files regular files
363
+ # `c*`
364
+ # : Matches all files beginning with `c`
365
+ # `*c`
366
+ # : Matches all files ending with `c`
367
+ # `*c*`
368
+ # : Matches all files that have `c` in them (including at the beginning or
369
+ # end).
370
+ #
371
+ #
372
+ # To match hidden files (that start with a `.` set the File::FNM_DOTMATCH
373
+ # flag.
374
+ #
375
+ # `**`
376
+ # : Matches directories recursively or files expansively.
377
+ #
378
+ # `?`
379
+ # : Matches any one character. Equivalent to `/.{1}/` in regexp.
380
+ #
381
+ # `[set]`
382
+ # : Matches any one character in `set`. Behaves exactly like character sets
383
+ # in Regexp, including set negation (`[^a-z]`).
384
+ #
385
+ # ` \ `
386
+ # : Escapes the next metacharacter.
387
+ #
388
+ # `{a,b}`
389
+ # : Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled.
390
+ # Behaves like a Regexp union (`(?:a|b)`).
391
+ #
392
+ #
393
+ # `flags` is a bitwise OR of the `FNM_XXX` constants. The same glob pattern and
394
+ # flags are used by Dir::glob.
395
+ #
396
+ # Examples:
397
+ #
398
+ # File.fnmatch('cat', 'cat') #=> true # match entire string
399
+ # File.fnmatch('cat', 'category') #=> false # only match partial string
400
+ #
401
+ # File.fnmatch('c{at,ub}s', 'cats') #=> false # { } isn't supported by default
402
+ # File.fnmatch('c{at,ub}s', 'cats', File::FNM_EXTGLOB) #=> true # { } is supported on FNM_EXTGLOB
403
+ #
404
+ # File.fnmatch('c?t', 'cat') #=> true # '?' match only 1 character
405
+ # File.fnmatch('c??t', 'cat') #=> false # ditto
406
+ # File.fnmatch('c*', 'cats') #=> true # '*' match 0 or more characters
407
+ # File.fnmatch('c*t', 'c/a/b/t') #=> true # ditto
408
+ # File.fnmatch('ca[a-z]', 'cat') #=> true # inclusive bracket expression
409
+ # File.fnmatch('ca[^t]', 'cat') #=> false # exclusive bracket expression ('^' or '!')
410
+ #
411
+ # File.fnmatch('cat', 'CAT') #=> false # case sensitive
412
+ # File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true # case insensitive
413
+ # File.fnmatch('cat', 'CAT', File::FNM_SYSCASE) #=> true or false # depends on the system default
414
+ #
415
+ # File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false # wildcard doesn't match '/' on FNM_PATHNAME
416
+ # File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false # ditto
417
+ # File.fnmatch('[/]', '/', File::FNM_PATHNAME) #=> false # ditto
418
+ #
419
+ # File.fnmatch('\?', '?') #=> true # escaped wildcard becomes ordinary
420
+ # File.fnmatch('\a', 'a') #=> true # escaped ordinary remains ordinary
421
+ # File.fnmatch('\a', '\a', File::FNM_NOESCAPE) #=> true # FNM_NOESCAPE makes '\' ordinary
422
+ # File.fnmatch('[\?]', '?') #=> true # can escape inside bracket expression
423
+ #
424
+ # File.fnmatch('*', '.profile') #=> false # wildcard doesn't match leading
425
+ # File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default.
426
+ # File.fnmatch('.*', '.profile') #=> true
427
+ #
428
+ # rbfiles = '**' '/' '*.rb' # you don't have to do like this. just write in single string.
429
+ # File.fnmatch(rbfiles, 'main.rb') #=> false
430
+ # File.fnmatch(rbfiles, './main.rb') #=> false
431
+ # File.fnmatch(rbfiles, 'lib/song.rb') #=> true
432
+ # File.fnmatch('**.rb', 'main.rb') #=> true
433
+ # File.fnmatch('**.rb', './main.rb') #=> false
434
+ # File.fnmatch('**.rb', 'lib/song.rb') #=> true
435
+ # File.fnmatch('*', 'dave/.profile') #=> true
436
+ #
437
+ # pattern = '*' '/' '*'
438
+ # File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false
439
+ # File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
440
+ #
441
+ # pattern = '**' '/' 'foo'
442
+ # File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME) #=> true
443
+ # File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME) #=> true
444
+ # File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true
445
+ # File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
446
+ # File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
447
+ #
448
+ alias self.fnmatch? self.fnmatch
449
+
450
+ # Identifies the type of the named file; the return string is one of ```file`'',
451
+ # ```directory`'', ```characterSpecial`'', ```blockSpecial`'', ```fifo`'',
452
+ # ```link`'', ```socket`'', or ```unknown`''.
453
+ #
454
+ # File.ftype("testfile") #=> "file"
455
+ # File.ftype("/dev/tty") #=> "characterSpecial"
456
+ # File.ftype("/tmp/.X11-unix/X0") #=> "socket"
457
+ #
458
+ def self.ftype: (string | _ToPath file_name) -> String
459
+
460
+ # Returns `true` if the named file exists and the effective group id of the
461
+ # calling process is the owner of the file. Returns `false` on Windows.
462
+ #
463
+ # *file_name* can be an IO object.
464
+ #
465
+ def self.grpowned?: (string | _ToPath | IO file_name) -> bool
466
+
467
+ # Returns `true` if the named files are identical.
468
+ #
469
+ # *file_1* and *file_2* can be an IO object.
470
+ #
471
+ # open("a", "w") {}
472
+ # p File.identical?("a", "a") #=> true
473
+ # p File.identical?("a", "./a") #=> true
474
+ # File.link("a", "b")
475
+ # p File.identical?("a", "b") #=> true
476
+ # File.symlink("a", "c")
477
+ # p File.identical?("a", "c") #=> true
478
+ # open("d", "w") {}
479
+ # p File.identical?("a", "d") #=> false
480
+ #
481
+ def self.identical?: (string | _ToPath | IO file_1, string | _ToPath | IO file_2) -> bool
482
+
483
+ # Returns a new string formed by joining the strings using `"/"`.
484
+ #
485
+ # File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
486
+ #
487
+ def self.join: (*string) -> String
488
+
489
+ # Equivalent to File::chmod, but does not follow symbolic links (so it will
490
+ # change the permissions associated with the link, not the file referenced by
491
+ # the link). Often not available.
492
+ #
493
+ def self.lchmod: (int mode, *(string | _ToPath) file_name) -> Integer
494
+
495
+ # Equivalent to File::chown, but does not follow symbolic links (so it will
496
+ # change the owner associated with the link, not the file referenced by the
497
+ # link). Often not available. Returns number of files in the argument list.
498
+ #
499
+ def self.lchown: (int? owner, int? group, *(string | _ToPath) file_name) -> Integer
500
+
501
+ # Creates a new name for an existing file using a hard link. Will not overwrite
502
+ # *new_name* if it already exists (raising a subclass of SystemCallError). Not
503
+ # available on all platforms.
504
+ #
505
+ # File.link("testfile", ".testfile") #=> 0
506
+ # IO.readlines(".testfile")[0] #=> "This is line one\n"
507
+ #
508
+ def self.link: (string | _ToPath old_name, string | _ToPath new_name) -> 0
509
+
510
+ # Same as File::stat, but does not follow the last symbolic link. Instead,
511
+ # reports on the link itself.
512
+ #
513
+ # File.symlink("testfile", "link2test") #=> 0
514
+ # File.stat("testfile").size #=> 66
515
+ # File.lstat("link2test").size #=> 8
516
+ # File.stat("link2test").size #=> 66
517
+ #
518
+ def self.lstat: (string | _ToPath file_name) -> File::Stat
519
+
520
+ # Sets the access and modification times of each named file to the first two
521
+ # arguments. If a file is a symlink, this method acts upon the link itself as
522
+ # opposed to its referent; for the inverse behavior, see File.utime. Returns the
523
+ # number of file names in the argument list.
524
+ #
525
+ def self.lutime: ((Time | Numeric) atime, (Time | Numeric) mtime, *(string | _ToPath) file_name) -> Integer
526
+
527
+ # Creates a FIFO special file with name *file_name*. *mode* specifies the
528
+ # FIFO's permissions. It is modified by the process's umask in the usual way:
529
+ # the permissions of the created file are (mode & ~umask).
530
+ #
531
+ def self.mkfifo: ((string | _ToPath) file_name, ?int mode) -> 0
532
+
533
+ # Returns the modification time for the named file as a Time object.
534
+ #
535
+ # *file_name* can be an IO object.
536
+ #
537
+ # File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
538
+ #
539
+ def self.mtime: (string | _ToPath | IO file_name) -> Time
540
+
541
+ # Returns `true` if the named file exists and the effective used id of the
542
+ # calling process is the owner of the file.
543
+ #
544
+ # *file_name* can be an IO object.
545
+ #
546
+ def self.owned?: (string | _ToPath | IO file_name) -> bool
547
+
548
+ # Returns the string representation of the path
549
+ #
550
+ # File.path("/dev/null") #=> "/dev/null"
551
+ # File.path(Pathname.new("/tmp")) #=> "/tmp"
552
+ #
553
+ def self.path: (string | _ToPath path) -> String
554
+
555
+ # Returns `true` if the named file is a pipe.
556
+ #
557
+ # *file_name* can be an IO object.
558
+ #
559
+ def self.pipe?: (string | _ToPath | IO file_name) -> bool
560
+
561
+ # Returns `true` if the named file is readable by the effective user and group
562
+ # id of this process. See eaccess(3).
563
+ #
564
+ # Note that some OS-level security features may cause this to return true even
565
+ # though the file is not readable by the effective user/group.
566
+ #
567
+ def self.readable?: (string | _ToPath file_name) -> bool
568
+
569
+ # Returns `true` if the named file is readable by the real user and group id of
570
+ # this process. See access(3).
571
+ #
572
+ # Note that some OS-level security features may cause this to return true even
573
+ # though the file is not readable by the real user/group.
574
+ #
575
+ def self.readable_real?: (string | _ToPath file_name) -> bool
576
+
577
+ # Returns the name of the file referenced by the given link. Not available on
578
+ # all platforms.
579
+ #
580
+ # File.symlink("testfile", "link2test") #=> 0
581
+ # File.readlink("link2test") #=> "testfile"
582
+ #
583
+ def self.readlink: (string | _ToPath link_name) -> String
584
+
585
+ # Returns the real (absolute) pathname of *pathname* in the actual filesystem.
586
+ # The real pathname doesn't contain symlinks or useless dots.
587
+ #
588
+ # If *dir_string* is given, it is used as a base directory for interpreting
589
+ # relative pathname instead of the current directory.
590
+ #
591
+ # The last component of the real pathname can be nonexistent.
592
+ #
593
+ def self.realdirpath: (string | _ToPath pathname, ?(string | _ToPath) dir_string) -> String
594
+
595
+ # Returns the real (absolute) pathname of *pathname* in the actual filesystem
596
+ # not containing symlinks or useless dots.
597
+ #
598
+ # If *dir_string* is given, it is used as a base directory for interpreting
599
+ # relative pathname instead of the current directory.
600
+ #
601
+ # All components of the pathname must exist when this method is called.
602
+ #
603
+ def self.realpath: (string | _ToPath pathname, ?(string | _ToPath) dir_string) -> String
604
+
605
+ # Renames the given file to the new name. Raises a SystemCallError if the file
606
+ # cannot be renamed.
607
+ #
608
+ # File.rename("afile", "afile.bak") #=> 0
609
+ #
610
+ def self.rename: (string | _ToPath old_name, string | _ToPath new_name) -> 0
611
+
612
+ # Returns `true` if the named file has the setgid bit set.
613
+ #
614
+ # *file_name* can be an IO object.
615
+ #
616
+ def self.setgid?: (string | _ToPath | IO file_name) -> bool
617
+
618
+ # Returns `true` if the named file has the setuid bit set.
619
+ #
620
+ # *file_name* can be an IO object.
621
+ #
622
+ def self.setuid?: (string | _ToPath | IO file_name) -> bool
623
+
624
+ # Returns the size of `file_name`.
625
+ #
626
+ # *file_name* can be an IO object.
627
+ #
628
+ def self.size: (string | _ToPath | IO file_name) -> Integer
629
+
630
+ # Returns `nil` if `file_name` doesn't exist or has zero size, the size of the
631
+ # file otherwise.
632
+ #
633
+ # *file_name* can be an IO object.
634
+ #
635
+ def self.size?: (string | _ToPath | IO file_name) -> Integer?
636
+
637
+ # Returns `true` if the named file is a socket.
638
+ #
639
+ # *file_name* can be an IO object.
640
+ #
641
+ def self.socket?: (string | _ToPath | IO file_name) -> bool
642
+
643
+ # Splits the given string into a directory and a file component and returns them
644
+ # in a two-element array. See also File::dirname and File::basename.
645
+ #
646
+ # File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
647
+ #
648
+ def self.split: (string | _ToPath file_name) -> [String, String]
649
+
650
+ # Returns a File::Stat object for the named file (see File::Stat).
651
+ #
652
+ # File.stat("testfile").mtime #=> Tue Apr 08 12:58:04 CDT 2003
653
+ #
654
+ def self.stat: (string | _ToPath file_name) -> File::Stat
655
+
656
+ # Returns `true` if the named file has the sticky bit set.
657
+ #
658
+ # *file_name* can be an IO object.
659
+ #
660
+ def self.sticky?: (string | _ToPath | IO file_name) -> bool
661
+
662
+ # Creates a symbolic link called *new_name* for the existing file *old_name*.
663
+ # Raises a NotImplemented exception on platforms that do not support symbolic
664
+ # links.
665
+ #
666
+ # File.symlink("testfile", "link2test") #=> 0
667
+ #
668
+ def self.symlink: (string | _ToPath old_name, string | _ToPath new_name) -> 0
669
+
670
+ # Returns `true` if the named file is a symbolic link.
671
+ #
672
+ def self.symlink?: (string | _ToPath file_name) -> bool
673
+
674
+ # Truncates the file *file_name* to be at most *integer* bytes long. Not
675
+ # available on all platforms.
676
+ #
677
+ # f = File.new("out", "w")
678
+ # f.write("1234567890") #=> 10
679
+ # f.close #=> nil
680
+ # File.truncate("out", 5) #=> 0
681
+ # File.size("out") #=> 5
682
+ #
683
+ def self.truncate: (string | _ToPath file_name, int length) -> 0
684
+
685
+ # Returns the current umask value for this process. If the optional argument is
686
+ # given, set the umask to that value and return the previous value. Umask values
687
+ # are *subtracted* from the default permissions, so a umask of `0222` would make
688
+ # a file read-only for everyone.
689
+ #
690
+ # File.umask(0006) #=> 18
691
+ # File.umask #=> 6
692
+ #
693
+ def self.umask: (?int umask) -> Integer
694
+
695
+ # Deletes the named files, returning the number of names passed as arguments.
696
+ # Raises an exception on any error. Since the underlying implementation relies
697
+ # on the `unlink(2)` system call, the type of exception raised depends on its
698
+ # error type (see https://linux.die.net/man/2/unlink) and has the form of e.g.
699
+ # Errno::ENOENT.
700
+ #
701
+ # See also Dir::rmdir.
702
+ #
703
+ def self.unlink: (*(string | _ToPath) file_name) -> Integer
704
+
705
+ # Sets the access and modification times of each named file to the first two
706
+ # arguments. If a file is a symlink, this method acts upon its referent rather
707
+ # than the link itself; for the inverse behavior see File.lutime. Returns the
708
+ # number of file names in the argument list.
709
+ #
710
+ def self.utime: ((Time | Numeric) atime, (Time | Numeric) mtime, *(string | _ToPath) file_name) -> Integer
711
+
712
+ # If *file_name* is readable by others, returns an integer representing the file
713
+ # permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
714
+ # bits is platform dependent; on Unix systems, see `stat(2)`.
715
+ #
716
+ # *file_name* can be an IO object.
717
+ #
718
+ # File.world_readable?("/etc/passwd") #=> 420
719
+ # m = File.world_readable?("/etc/passwd")
720
+ # sprintf("%o", m) #=> "644"
721
+ #
722
+ def self.world_readable?: (string | _ToPath | IO file_name) -> Integer?
723
+
724
+ # If *file_name* is writable by others, returns an integer representing the file
725
+ # permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
726
+ # bits is platform dependent; on Unix systems, see `stat(2)`.
727
+ #
728
+ # *file_name* can be an IO object.
729
+ #
730
+ # File.world_writable?("/tmp") #=> 511
731
+ # m = File.world_writable?("/tmp")
732
+ # sprintf("%o", m) #=> "777"
733
+ #
734
+ def self.world_writable?: (string | _ToPath | IO file_name) -> Integer?
735
+
736
+ # Returns `true` if the named file is writable by the effective user and group
737
+ # id of this process. See eaccess(3).
738
+ #
739
+ # Note that some OS-level security features may cause this to return true even
740
+ # though the file is not writable by the effective user/group.
741
+ #
742
+ def self.writable?: (string | _ToPath file_name) -> bool
743
+
744
+ # Returns `true` if the named file is writable by the real user and group id of
745
+ # this process. See access(3).
746
+ #
747
+ # Note that some OS-level security features may cause this to return true even
748
+ # though the file is not writable by the real user/group.
749
+ #
750
+ def self.writable_real?: (string | _ToPath file_name) -> bool
751
+
752
+ # Returns `true` if the named file exists and has a zero size.
753
+ #
754
+ # *file_name* can be an IO object.
755
+ #
756
+ def self.zero?: (string | _ToPath | IO file_name) -> bool
757
+
758
+ public
759
+
760
+ # Returns the last access time (a Time object) for *file*, or epoch if *file*
761
+ # has not been accessed.
762
+ #
763
+ # File.new("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
764
+ #
151
765
  def atime: () -> Time
152
766
 
153
- # Returns the birth time for *file* .
154
- #
155
- # ```ruby
156
- # File.new("testfile").birthtime #=> Wed Apr 09 08:53:14 CDT 2003
157
- # ```
158
- #
159
- # If the platform doesn’t have birthtime, raises
160
- # [NotImplementedError](https://ruby-doc.org/core-2.6.3/NotImplementedError.html)
161
- # .
767
+ # Returns the birth time for *file*.
768
+ #
769
+ # File.new("testfile").birthtime #=> Wed Apr 09 08:53:14 CDT 2003
770
+ #
771
+ # If the platform doesn't have birthtime, raises NotImplementedError.
772
+ #
162
773
  def birthtime: () -> Time
163
774
 
164
- def chmod: (Integer mode) -> Integer
165
-
166
- def chown: (Integer owner, Integer group) -> Integer
167
-
168
- # Returns the change time for *file* (that is, the time directory
169
- # information about the file was changed, not the file itself).
170
- #
775
+ # Changes permission bits on *file* to the bit pattern represented by
776
+ # *mode_int*. Actual effects are platform dependent; on Unix systems, see
777
+ # `chmod(2)` for details. Follows symbolic links. Also see File#lchmod.
778
+ #
779
+ # f = File.new("out", "w");
780
+ # f.chmod(0644) #=> 0
781
+ #
782
+ def chmod: (int mode) -> (0 | nil)
783
+
784
+ # Changes the owner and group of *file* to the given numeric owner and group
785
+ # id's. Only a process with superuser privileges may change the owner of a file.
786
+ # The current owner of a file may change the file's group to any group to which
787
+ # the owner belongs. A `nil` or -1 owner or group id is ignored. Follows
788
+ # symbolic links. See also File#lchown.
789
+ #
790
+ # File.new("testfile").chown(502, 1000)
791
+ #
792
+ def chown: (int? owner, int? group) -> (0 | nil)
793
+
794
+ # Returns the change time for *file* (that is, the time directory information
795
+ # about the file was changed, not the file itself).
796
+ #
171
797
  # Note that on Windows (NTFS), returns creation time (birth time).
172
- #
173
- # ```ruby
174
- # File.new("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003
175
- # ```
798
+ #
799
+ # File.new("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003
800
+ #
176
801
  def ctime: () -> Time
177
802
 
178
- def flock: (Integer arg0) -> (Integer | TrueClass | FalseClass)
179
-
180
- def initialize: (String file, ?String mode, ?String perm, ?Integer opt) -> void
181
-
182
- # Same as `IO#stat`, but does not follow the last symbolic link. Instead,
183
- # reports on the link itself.
184
- #
185
- # ```ruby
186
- # File.symlink("testfile", "link2test") #=> 0
187
- # File.stat("testfile").size #=> 66
188
- # f = File.new("link2test")
189
- # f.lstat.size #=> 8
190
- # f.stat.size #=> 66
191
- # ```
192
- def lstat: () -> File::Stat
193
-
194
- # Returns the modification time for *file* .
195
- #
196
- # ```ruby
197
- # File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003
198
- # ```
803
+ # Locks or unlocks a file according to *locking_constant* (a logical *or* of the
804
+ # values in the table below). Returns `false` if File::LOCK_NB is specified and
805
+ # the operation would otherwise have blocked. Not available on all platforms.
806
+ #
807
+ # Locking constants (in class File):
808
+ #
809
+ # LOCK_EX | Exclusive lock. Only one process may hold an
810
+ # | exclusive lock for a given file at a time.
811
+ # ----------+------------------------------------------------
812
+ # LOCK_NB | Don't block when locking. May be combined
813
+ # | with other lock options using logical or.
814
+ # ----------+------------------------------------------------
815
+ # LOCK_SH | Shared lock. Multiple processes may each hold a
816
+ # | shared lock for a given file at the same time.
817
+ # ----------+------------------------------------------------
818
+ # LOCK_UN | Unlock.
819
+ #
820
+ # Example:
821
+ #
822
+ # # update a counter using write lock
823
+ # # don't use "w" because it truncates the file before lock.
824
+ # File.open("counter", File::RDWR|File::CREAT, 0644) {|f|
825
+ # f.flock(File::LOCK_EX)
826
+ # value = f.read.to_i + 1
827
+ # f.rewind
828
+ # f.write("#{value}\n")
829
+ # f.flush
830
+ # f.truncate(f.pos)
831
+ # }
832
+ #
833
+ # # read the counter using read lock
834
+ # File.open("counter", "r") {|f|
835
+ # f.flock(File::LOCK_SH)
836
+ # p f.read
837
+ # }
838
+ #
839
+ def flock: (int locking_constant) -> (0 | false)
840
+
841
+ # Same as IO#stat, but does not follow the last symbolic link. Instead, reports
842
+ # on the link itself.
843
+ #
844
+ # File.symlink("testfile", "link2test") #=> 0
845
+ # File.stat("testfile").size #=> 66
846
+ # f = File.new("link2test")
847
+ # f.lstat.size #=> 8
848
+ # f.stat.size #=> 66
849
+ #
850
+ def lstat: () -> (File::Stat | nil)
851
+
852
+ # Returns the modification time for *file*.
853
+ #
854
+ # File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003
855
+ #
199
856
  def mtime: () -> Time
200
857
 
201
- # Returns the pathname used to create *file* as a string. Does not
202
- # normalize the name.
203
- #
204
- # The pathname may not point to the file corresponding to *file* . For
205
- # instance, the pathname becomes void when the file has been moved or
206
- # deleted.
207
- #
208
- # This method raises `IOError` for a *file* created using
209
- # `File::Constants::TMPFILE` because they don’t have a pathname.
210
- #
211
- # ```ruby
212
- # File.new("testfile").path #=> "testfile"
213
- # File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx"
214
- # ```
858
+ # Returns the pathname used to create *file* as a string. Does not normalize the
859
+ # name.
860
+ #
861
+ # The pathname may not point to the file corresponding to *file*. For instance,
862
+ # the pathname becomes void when the file has been moved or deleted.
863
+ #
864
+ # This method raises IOError for a *file* created using File::Constants::TMPFILE
865
+ # because they don't have a pathname.
866
+ #
867
+ # File.new("testfile").path #=> "testfile"
868
+ # File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx"
869
+ #
215
870
  def path: () -> String
216
871
 
217
872
  # Returns the size of *file* in bytes.
218
- #
219
- # ```ruby
220
- # File.new("testfile").size #=> 66
221
- # ```
873
+ #
874
+ # File.new("testfile").size #=> 66
875
+ #
222
876
  def size: () -> Integer
223
877
 
224
- def truncate: (Integer arg0) -> Integer
225
-
226
- def self.fnmatch?: (String pattern, String path, ?Integer flags) -> bool
227
-
228
- def self.unlink: (*String files) -> Integer
229
-
230
- # Returns the pathname used to create *file* as a string. Does not
231
- # normalize the name.
232
- #
233
- # The pathname may not point to the file corresponding to *file* . For
234
- # instance, the pathname becomes void when the file has been moved or
235
- # deleted.
236
- #
237
- # This method raises `IOError` for a *file* created using
238
- # `File::Constants::TMPFILE` because they don’t have a pathname.
239
- #
240
- # ```ruby
241
- # File.new("testfile").path #=> "testfile"
242
- # File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx"
243
- # ```
244
- def to_path: () -> String
878
+ # Returns the pathname used to create *file* as a string. Does not normalize the
879
+ # name.
880
+ #
881
+ # The pathname may not point to the file corresponding to *file*. For instance,
882
+ # the pathname becomes void when the file has been moved or deleted.
883
+ #
884
+ # This method raises IOError for a *file* created using File::Constants::TMPFILE
885
+ # because they don't have a pathname.
886
+ #
887
+ # File.new("testfile").path #=> "testfile"
888
+ # File.new("/tmp/../tmp/xxx", "w").path #=> "/tmp/../tmp/xxx"
889
+ #
890
+ alias to_path path
891
+
892
+ # Truncates *file* to at most *integer* bytes. The file must be opened for
893
+ # writing. Not available on all platforms.
894
+ #
895
+ # f = File.new("out", "w")
896
+ # f.syswrite("1234567890") #=> 10
897
+ # f.truncate(5) #=> 0
898
+ # f.close() #=> nil
899
+ # File.size("out") #=> 5
900
+ #
901
+ def truncate: (int length) -> 0
245
902
  end
246
903
 
247
- File::ALT_SEPARATOR: NilClass
248
-
249
- File::APPEND: Integer
250
-
251
- File::BINARY: Integer
252
-
253
- File::CREAT: Integer
254
-
255
- File::DIRECT: Integer
256
-
257
- File::DSYNC: Integer
258
-
259
- File::EXCL: Integer
260
-
261
- File::FNM_CASEFOLD: Integer
262
-
263
- File::FNM_DOTMATCH: Integer
264
-
265
- File::FNM_EXTGLOB: Integer
266
-
267
- File::FNM_NOESCAPE: Integer
268
-
269
- File::FNM_PATHNAME: Integer
270
-
271
- File::FNM_SHORTNAME: Integer
272
-
273
- File::FNM_SYSCASE: Integer
274
-
275
- File::LOCK_EX: Integer
276
-
277
- File::LOCK_NB: Integer
278
-
279
- File::LOCK_SH: Integer
280
-
281
- File::LOCK_UN: Integer
282
-
283
- File::NOATIME: Integer
284
-
285
- File::NOCTTY: Integer
286
-
287
- File::NOFOLLOW: Integer
288
-
289
- File::NONBLOCK: Integer
290
-
291
- File::NULL: String
904
+ # platform specific alternative separator
905
+ #
906
+ #
907
+ File::ALT_SEPARATOR: String?
292
908
 
909
+ # path list separator
910
+ #
911
+ #
293
912
  File::PATH_SEPARATOR: String
294
913
 
295
- File::RDONLY: Integer
296
-
297
- File::RDWR: Integer
298
-
299
- File::RSYNC: Integer
300
-
301
- File::SEEK_CUR: Integer
302
-
303
- File::SEEK_DATA: Integer
304
-
305
- File::SEEK_END: Integer
306
-
307
- File::SEEK_HOLE: Integer
308
-
309
- File::SEEK_SET: Integer
310
-
914
+ # separates directory parts in path
915
+ #
916
+ #
311
917
  File::SEPARATOR: String
312
918
 
313
- File::SHARE_DELETE: Integer
314
-
315
- File::SYNC: Integer
316
-
317
- File::TMPFILE: Integer
318
-
319
- File::TRUNC: Integer
320
-
321
- File::WRONLY: Integer
919
+ # separates directory parts in path
920
+ #
921
+ #
922
+ File::Separator: String
322
923
 
323
924
  module File::Constants
324
925
  end
@@ -386,6 +987,7 @@ File::Constants::WRONLY: Integer
386
987
  class File::Stat < Object
387
988
  include Comparable
388
989
 
990
+ def initialize: (String file) -> Object
389
991
  def <=>: (File::Stat other) -> Integer?
390
992
 
391
993
  def atime: () -> Time
@@ -416,14 +1018,12 @@ class File::Stat < Object
416
1018
 
417
1019
  def file?: () -> bool
418
1020
 
419
- def `ftype`: () -> String
1021
+ def ftype: () -> String
420
1022
 
421
1023
  def gid: () -> Integer
422
1024
 
423
1025
  def grpowned?: () -> bool
424
1026
 
425
- def initialize: (String file) -> Object
426
-
427
1027
  def ino: () -> Integer
428
1028
 
429
1029
  def inspect: () -> String