rbs 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -0
- data/CHANGELOG.md +23 -0
- data/README.md +6 -1
- data/core/array.rbs +2866 -1086
- data/core/basic_object.rbs +150 -30
- data/core/binding.rbs +33 -0
- data/core/builtin.rbs +4 -4
- data/core/class.rbs +43 -5
- data/core/comparable.rbs +57 -0
- data/core/complex.rbs +170 -4
- data/core/constants.rbs +51 -0
- data/core/deprecated.rbs +7 -0
- data/core/dir.rbs +305 -20
- data/core/encoding.rbs +472 -77
- data/core/enumerable.rbs +2173 -234
- data/core/enumerator.rbs +448 -182
- data/core/env.rbs +448 -1
- data/core/errno.rbs +1 -10
- data/core/errors.rbs +152 -2
- data/core/exception.rbs +201 -127
- data/core/false_class.rbs +27 -0
- data/core/fiber.rbs +118 -37
- data/core/fiber_error.rbs +8 -9
- data/core/file.rbs +1059 -139
- data/core/file_test.rbs +287 -32
- data/core/float.rbs +776 -300
- data/core/gc.rbs +185 -34
- data/core/global_variables.rbs +5 -1
- data/core/hash.rbs +1582 -649
- data/core/integer.rbs +974 -204
- data/core/io/buffer.rbs +710 -0
- data/core/io/wait.rbs +29 -8
- data/core/io.rbs +2438 -417
- data/core/kernel.rbs +2315 -316
- data/core/marshal.rbs +37 -2
- data/core/match_data.rbs +123 -6
- data/core/math.rbs +126 -6
- data/core/method.rbs +226 -102
- data/core/module.rbs +421 -45
- data/core/nil_class.rbs +64 -0
- data/core/numeric.rbs +620 -142
- data/core/object.rbs +453 -81
- data/core/object_space.rbs +92 -2
- data/core/proc.rbs +482 -285
- data/core/process.rbs +443 -34
- data/core/ractor.rbs +232 -9
- data/core/random.rbs +151 -52
- data/core/range.rbs +885 -160
- data/core/rational.rbs +122 -6
- data/core/rb_config.rbs +14 -4
- data/core/refinement.rbs +44 -0
- data/core/regexp.rbs +156 -14
- data/core/ruby_vm.rbs +42 -3
- data/core/signal.rbs +78 -39
- data/core/string.rbs +2123 -567
- data/core/string_io.rbs +204 -0
- data/core/struct.rbs +283 -28
- data/core/symbol.rbs +304 -30
- data/core/thread.rbs +1288 -688
- data/core/thread_group.rbs +66 -10
- data/core/time.rbs +643 -217
- data/core/trace_point.rbs +100 -12
- data/core/true_class.rbs +24 -0
- data/core/unbound_method.rbs +73 -7
- data/core/warning.rbs +37 -12
- data/docs/CONTRIBUTING.md +40 -34
- data/docs/stdlib.md +3 -102
- data/lib/rbs/annotate/annotations.rb +197 -0
- data/lib/rbs/annotate/formatter.rb +80 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
- data/lib/rbs/annotate/rdoc_source.rb +120 -0
- data/lib/rbs/annotate.rb +6 -0
- data/lib/rbs/cli.rb +45 -1
- data/lib/rbs/definition_builder.rb +5 -1
- data/lib/rbs/location_aux.rb +12 -0
- data/lib/rbs/prototype/rb.rb +12 -0
- data/lib/rbs/version.rb +1 -1
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/cli.rbs +2 -0
- data/sig/collection/{collections.rbs → sources.rbs} +0 -0
- data/sig/location.rbs +6 -0
- data/sig/method_types.rbs +5 -1
- data/sig/polyfill.rbs +78 -0
- data/stdlib/abbrev/0/abbrev.rbs +6 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +31 -0
- data/stdlib/benchmark/0/benchmark.rbs +74 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
- data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
- data/stdlib/cgi/0/core.rbs +59 -0
- data/stdlib/coverage/0/coverage.rbs +164 -2
- data/stdlib/csv/0/csv.rbs +2862 -398
- data/stdlib/date/0/date.rbs +483 -25
- data/stdlib/date/0/date_time.rbs +187 -12
- data/stdlib/dbm/0/dbm.rbs +152 -17
- data/stdlib/digest/0/digest.rbs +146 -0
- data/stdlib/erb/0/erb.rbs +65 -245
- data/stdlib/fiber/0/fiber.rbs +73 -91
- data/stdlib/fileutils/0/fileutils.rbs +301 -1
- data/stdlib/find/0/find.rbs +9 -0
- data/stdlib/forwardable/0/forwardable.rbs +65 -1
- data/stdlib/io-console/0/io-console.rbs +227 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
- data/stdlib/json/0/json.rbs +1146 -144
- data/stdlib/logger/0/formatter.rbs +24 -0
- data/stdlib/logger/0/log_device.rbs +64 -0
- data/stdlib/logger/0/logger.rbs +165 -13
- data/stdlib/logger/0/period.rbs +10 -0
- data/stdlib/logger/0/severity.rbs +26 -0
- data/stdlib/monitor/0/monitor.rbs +163 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
- data/stdlib/net-http/0/net-http.rbs +1492 -683
- data/stdlib/nkf/0/nkf.rbs +372 -0
- data/stdlib/objspace/0/objspace.rbs +149 -90
- data/stdlib/openssl/0/openssl.rbs +8108 -71
- data/stdlib/optparse/0/optparse.rbs +487 -19
- data/stdlib/pathname/0/pathname.rbs +425 -124
- data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
- data/stdlib/prime/0/integer-extension.rbs +20 -2
- data/stdlib/prime/0/prime.rbs +88 -21
- data/stdlib/pstore/0/pstore.rbs +102 -0
- data/stdlib/pty/0/pty.rbs +64 -14
- data/stdlib/resolv/0/resolv.rbs +420 -31
- data/stdlib/rubygems/0/basic_specification.rbs +4 -1
- data/stdlib/rubygems/0/config_file.rbs +33 -1
- data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
- data/stdlib/rubygems/0/installer.rbs +13 -1
- data/stdlib/rubygems/0/path_support.rbs +4 -1
- data/stdlib/rubygems/0/platform.rbs +5 -1
- data/stdlib/rubygems/0/request_set.rbs +44 -2
- data/stdlib/rubygems/0/requirement.rbs +65 -2
- data/stdlib/rubygems/0/rubygems.rbs +407 -0
- data/stdlib/rubygems/0/source_list.rbs +13 -0
- data/stdlib/rubygems/0/specification.rbs +21 -1
- data/stdlib/rubygems/0/stream_ui.rbs +3 -1
- data/stdlib/rubygems/0/uninstaller.rbs +8 -1
- data/stdlib/rubygems/0/version.rbs +60 -157
- data/stdlib/securerandom/0/securerandom.rbs +44 -0
- data/stdlib/set/0/set.rbs +420 -106
- data/stdlib/shellwords/0/shellwords.rbs +55 -77
- data/stdlib/singleton/0/singleton.rbs +20 -0
- data/stdlib/socket/0/addrinfo.rbs +210 -9
- data/stdlib/socket/0/basic_socket.rbs +103 -11
- data/stdlib/socket/0/ip_socket.rbs +31 -9
- data/stdlib/socket/0/socket.rbs +586 -38
- data/stdlib/socket/0/tcp_server.rbs +22 -2
- data/stdlib/socket/0/tcp_socket.rbs +12 -1
- data/stdlib/socket/0/udp_socket.rbs +25 -2
- data/stdlib/socket/0/unix_server.rbs +22 -2
- data/stdlib/socket/0/unix_socket.rbs +45 -5
- data/stdlib/strscan/0/string_scanner.rbs +210 -9
- data/stdlib/tempfile/0/tempfile.rbs +58 -10
- data/stdlib/time/0/time.rbs +208 -116
- data/stdlib/timeout/0/timeout.rbs +10 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
- data/stdlib/tsort/0/cyclic.rbs +1 -0
- data/stdlib/tsort/0/interfaces.rbs +1 -0
- data/stdlib/tsort/0/tsort.rbs +42 -0
- data/stdlib/uri/0/common.rbs +57 -8
- data/stdlib/uri/0/file.rbs +55 -109
- data/stdlib/uri/0/ftp.rbs +6 -3
- data/stdlib/uri/0/generic.rbs +556 -327
- data/stdlib/uri/0/http.rbs +26 -115
- data/stdlib/uri/0/https.rbs +8 -102
- data/stdlib/uri/0/ldap.rbs +143 -137
- data/stdlib/uri/0/ldaps.rbs +8 -102
- data/stdlib/uri/0/mailto.rbs +3 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
- data/stdlib/uri/0/ws.rbs +6 -3
- data/stdlib/uri/0/wss.rbs +5 -3
- data/stdlib/yaml/0/dbm.rbs +151 -87
- data/stdlib/yaml/0/store.rbs +6 -0
- data/stdlib/zlib/0/zlib.rbs +90 -31
- metadata +17 -5
- data/lib/rbs/location.rb +0 -221
data/core/file.rbs
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# <!-- rdoc-file=file.c -->
|
1
2
|
# A File is an abstraction of any file object accessible by the program and is
|
2
3
|
# closely associated with class IO. File includes the methods of module
|
3
4
|
# FileTest as class methods, allowing you to write (for example)
|
@@ -25,7 +26,286 @@
|
|
25
26
|
#
|
26
27
|
# Various constants for the methods in File can be found in File::Constants.
|
27
28
|
#
|
29
|
+
# ## What's Here
|
30
|
+
#
|
31
|
+
# First, what's elsewhere. Class File:
|
32
|
+
#
|
33
|
+
# * Inherits from [class IO](IO.html#class-IO-label-What-27s+Here), in
|
34
|
+
# particular, methods for creating, reading, and writing files
|
35
|
+
# * Includes [module
|
36
|
+
# FileTest](FileTest.html#module-FileTest-label-What-27s+Here). which
|
37
|
+
# provides dozens of additional methods.
|
38
|
+
#
|
39
|
+
#
|
40
|
+
# Here, class File provides methods that are useful for:
|
41
|
+
#
|
42
|
+
# * [Creating](#class-File-label-Creating)
|
43
|
+
# * [Querying](#class-File-label-Querying)
|
44
|
+
# * [Settings](#class-File-label-Settings)
|
45
|
+
# * [Other](#class-File-label-Other)
|
46
|
+
#
|
47
|
+
#
|
48
|
+
# ### Creating
|
49
|
+
#
|
50
|
+
# ::new
|
51
|
+
# : Opens the file at the given path; returns the file.
|
52
|
+
#
|
53
|
+
# ::open
|
54
|
+
# : Same as ::new, but when given a block will yield the file to the
|
55
|
+
# block, and close the file upon exiting the block.
|
56
|
+
#
|
57
|
+
# ::link
|
58
|
+
# : Creates a new name for an existing file using a hard link.
|
59
|
+
#
|
60
|
+
# ::mkfifo
|
61
|
+
# : Returns the FIFO file created at the given path.
|
62
|
+
#
|
63
|
+
# ::symlink
|
64
|
+
# : Creates a symbolic link for the given file path.
|
65
|
+
#
|
66
|
+
#
|
67
|
+
#
|
68
|
+
# ### Querying
|
69
|
+
#
|
70
|
+
# *Paths*
|
71
|
+
#
|
72
|
+
# ::absolute_path
|
73
|
+
# : Returns the absolute file path for the given path.
|
74
|
+
#
|
75
|
+
# ::absolute_path?
|
76
|
+
# : Returns whether the given path is the absolute file path.
|
77
|
+
#
|
78
|
+
# ::basename
|
79
|
+
# : Returns the last component of the given file path.
|
80
|
+
#
|
81
|
+
# ::dirname
|
82
|
+
# : Returns all but the last component of the given file path.
|
83
|
+
#
|
84
|
+
# ::expand_path
|
85
|
+
# : Returns the absolute file path for the given path, expanding `~` for a
|
86
|
+
# home directory.
|
87
|
+
#
|
88
|
+
# ::extname
|
89
|
+
# : Returns the file extension for the given file path.
|
90
|
+
#
|
91
|
+
# ::fnmatch? (aliased as ::fnmatch)
|
92
|
+
# : Returns whether the given file path matches the given pattern.
|
93
|
+
#
|
94
|
+
# ::join
|
95
|
+
# : Joins path components into a single path string.
|
96
|
+
#
|
97
|
+
# ::path
|
98
|
+
# : Returns the string representation of the given path.
|
99
|
+
#
|
100
|
+
# ::readlink
|
101
|
+
# : Returns the path to the file at the given symbolic link.
|
102
|
+
#
|
103
|
+
# ::realdirpath
|
104
|
+
# : Returns the real path for the given file path, where the last
|
105
|
+
# component need not exist.
|
106
|
+
#
|
107
|
+
# ::realpath
|
108
|
+
# : Returns the real path for the given file path, where all components
|
109
|
+
# must exist.
|
110
|
+
#
|
111
|
+
# ::split
|
112
|
+
# : Returns an array of two strings: the directory name and basename of
|
113
|
+
# the file at the given path.
|
114
|
+
#
|
115
|
+
# #path (aliased as #to_path)
|
116
|
+
# : Returns the string representation of the given path.
|
117
|
+
#
|
118
|
+
#
|
119
|
+
#
|
120
|
+
# *Times*
|
121
|
+
#
|
122
|
+
# ::atime
|
123
|
+
# : Returns a Time for the most recent access to the given file.
|
124
|
+
#
|
125
|
+
# ::birthtime
|
126
|
+
# : Returns a Time for the creation of the given file.
|
127
|
+
#
|
128
|
+
# ::ctime
|
129
|
+
# : Returns a Time for the metadata change of the given file.
|
130
|
+
#
|
131
|
+
# ::mtime
|
132
|
+
# : Returns a Time for the most recent data modification to the content of
|
133
|
+
# the given file.
|
134
|
+
#
|
135
|
+
# #atime
|
136
|
+
# : Returns a Time for the most recent access to `self`.
|
137
|
+
#
|
138
|
+
# #birthtime
|
139
|
+
# : Returns a Time the creation for `self`.
|
140
|
+
#
|
141
|
+
# #ctime
|
142
|
+
# : Returns a Time for the metadata change of `self`.
|
143
|
+
#
|
144
|
+
# #mtime
|
145
|
+
# : Returns a Time for the most recent data modification to the content of
|
146
|
+
# `self`.
|
147
|
+
#
|
148
|
+
#
|
149
|
+
#
|
150
|
+
# *Types*
|
151
|
+
#
|
152
|
+
# ::blockdev?
|
153
|
+
# : Returns whether the file at the given path is a block device.
|
154
|
+
#
|
155
|
+
# ::chardev?
|
156
|
+
# : Returns whether the file at the given path is a character device.
|
157
|
+
#
|
158
|
+
# ::directory?
|
159
|
+
# : Returns whether the file at the given path is a diretory.
|
160
|
+
#
|
161
|
+
# ::executable?
|
162
|
+
# : Returns whether the file at the given path is executable by the
|
163
|
+
# effective user and group of the current process.
|
164
|
+
#
|
165
|
+
# ::executable_real?
|
166
|
+
# : Returns whether the file at the given path is executable by the real
|
167
|
+
# user and group of the current process.
|
168
|
+
#
|
169
|
+
# ::exist?
|
170
|
+
# : Returns whether the file at the given path exists.
|
171
|
+
#
|
172
|
+
# ::file?
|
173
|
+
# : Returns whether the file at the given path is a regular file.
|
174
|
+
#
|
175
|
+
# ::ftype
|
176
|
+
# : Returns a string giving the type of the file at the given path.
|
177
|
+
#
|
178
|
+
# ::grpowned?
|
179
|
+
# : Returns whether the effective group of the current process owns the
|
180
|
+
# file at the given path.
|
181
|
+
#
|
182
|
+
# ::identical?
|
183
|
+
# : Returns whether the files at two given paths are identical.
|
184
|
+
#
|
185
|
+
# ::lstat
|
186
|
+
# : Returns the File::Stat object for the last symbolic link in the given
|
187
|
+
# path.
|
188
|
+
#
|
189
|
+
# ::owned?
|
190
|
+
# : Returns whether the effective user of the current process owns the
|
191
|
+
# file at the given path.
|
192
|
+
#
|
193
|
+
# ::pipe?
|
194
|
+
# : Returns whether the file at the given path is a pipe.
|
195
|
+
#
|
196
|
+
# ::readable?
|
197
|
+
# : Returns whether the file at the given path is readable by the
|
198
|
+
# effective user and group of the current process.
|
199
|
+
#
|
200
|
+
# ::readable_real?
|
201
|
+
# : Returns whether the file at the given path is readable by the real
|
202
|
+
# user and group of the current process.
|
203
|
+
#
|
204
|
+
# ::setgid?
|
205
|
+
# : Returns whether the setgid bit is set for the file at the given path.
|
206
|
+
#
|
207
|
+
# ::setuid?
|
208
|
+
# : Returns whether the setuid bit is set for the file at the given path.
|
209
|
+
#
|
210
|
+
# ::socket?
|
211
|
+
# : Returns whether the file at the given path is a socket.
|
212
|
+
#
|
213
|
+
# ::stat
|
214
|
+
# : Returns the File::Stat object for the file at the given path.
|
215
|
+
#
|
216
|
+
# ::sticky?
|
217
|
+
# : Returns whether the file at the given path has its sticky bit set.
|
218
|
+
#
|
219
|
+
# ::symlink?
|
220
|
+
# : Returns whether the file at the given path is a symbolic link.
|
221
|
+
#
|
222
|
+
# ::umask
|
223
|
+
# : Returns the umask value for the current process.
|
224
|
+
#
|
225
|
+
# ::world_readable?
|
226
|
+
# : Returns whether the file at the given path is readable by others.
|
227
|
+
#
|
228
|
+
# ::world_writable?
|
229
|
+
# : Returns whether the file at the given path is writable by others.
|
230
|
+
#
|
231
|
+
# ::writable?
|
232
|
+
# : Returns whether the file at the given path is writable by the
|
233
|
+
# effective user and group of the current process.
|
234
|
+
#
|
235
|
+
# ::writable_real?
|
236
|
+
# : Returns whether the file at the given path is writable by the real
|
237
|
+
# user and group of the current process.
|
238
|
+
#
|
239
|
+
# #lstat
|
240
|
+
# : Returns the File::Stat object for the last symbolic link in the path
|
241
|
+
# for `self`.
|
242
|
+
#
|
243
|
+
#
|
244
|
+
#
|
245
|
+
# *Contents*
|
246
|
+
#
|
247
|
+
# ::empty? (aliased as ::zero?)
|
248
|
+
# : Returns whether the file at the given path exists and is empty.
|
249
|
+
#
|
250
|
+
# ::size
|
251
|
+
# : Returns the size (bytes) of the file at the given path.
|
252
|
+
#
|
253
|
+
# ::size?
|
254
|
+
# : Returns `nil` if there is no file at the given path, or if that file
|
255
|
+
# is empty; otherwise returns the file size (bytes).
|
256
|
+
#
|
257
|
+
# #size
|
258
|
+
# : Returns the size (bytes) of `self`.
|
259
|
+
#
|
260
|
+
#
|
261
|
+
#
|
262
|
+
# ### Settings
|
263
|
+
#
|
264
|
+
# ::chmod
|
265
|
+
# : Changes permissions of the file at the given path.
|
266
|
+
#
|
267
|
+
# ::chown
|
268
|
+
# : Change ownership of the file at the given path.
|
269
|
+
#
|
270
|
+
# ::lchmod
|
271
|
+
# : Changes permissions of the last symbolic link in the given path.
|
272
|
+
#
|
273
|
+
# ::lchown
|
274
|
+
# : Change ownership of the last symbolic in the given path.
|
275
|
+
#
|
276
|
+
# ::lutime
|
277
|
+
# : For each given file path, sets the access time and modification time
|
278
|
+
# of the last symbolic link in the path.
|
279
|
+
#
|
280
|
+
# ::rename
|
281
|
+
# : Moves the file at one given path to another given path.
|
282
|
+
#
|
283
|
+
# ::utime
|
284
|
+
# : Sets the access time and modification time of each file at the given
|
285
|
+
# paths.
|
286
|
+
#
|
287
|
+
# #flock
|
288
|
+
# : Locks or unlocks `self`.
|
289
|
+
#
|
290
|
+
#
|
291
|
+
#
|
292
|
+
# ### Other
|
293
|
+
#
|
294
|
+
# ::truncate
|
295
|
+
# : Truncates the file at the given file path to the given size.
|
296
|
+
#
|
297
|
+
# ::unlink (aliased as ::delete)
|
298
|
+
# : Deletes the file for each given file path.
|
299
|
+
#
|
300
|
+
# #truncate
|
301
|
+
# : Truncates `self` to the given size.
|
302
|
+
#
|
28
303
|
class File < IO
|
304
|
+
# <!--
|
305
|
+
# rdoc-file=io.c
|
306
|
+
# - File.new(filename, mode="r" [, opt]) -> file
|
307
|
+
# - File.new(filename [, mode [, perm]] [, opt]) -> file
|
308
|
+
# -->
|
29
309
|
# Opens the file named by `filename` according to the given `mode` and returns a
|
30
310
|
# new File object.
|
31
311
|
#
|
@@ -44,8 +324,12 @@ class File < IO
|
|
44
324
|
# f = File.new("newfile", "w+")
|
45
325
|
# f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
|
46
326
|
#
|
47
|
-
def initialize: (string | _ToPath | int file_name, ?
|
327
|
+
def initialize: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> File
|
48
328
|
|
329
|
+
# <!--
|
330
|
+
# rdoc-file=file.c
|
331
|
+
# - File.absolute_path(file_name [, dir_string] ) -> abs_file_name
|
332
|
+
# -->
|
49
333
|
# Converts a pathname to an absolute pathname. Relative paths are referenced
|
50
334
|
# from the current working directory of the process unless *dir_string* is
|
51
335
|
# given, in which case it will be used as the starting point. If the given
|
@@ -54,14 +338,22 @@ class File < IO
|
|
54
338
|
#
|
55
339
|
# File.absolute_path("~oracle/bin") #=> "<relative_path>/~oracle/bin"
|
56
340
|
#
|
57
|
-
def self.absolute_path: (string | _ToPath file_name, ?
|
341
|
+
def self.absolute_path: (string | _ToPath file_name, ?string | _ToPath dir_string) -> String
|
58
342
|
|
343
|
+
# <!--
|
344
|
+
# rdoc-file=file.c
|
345
|
+
# - File.absolute_path?(file_name) -> true or false
|
346
|
+
# -->
|
59
347
|
# Returns `true` if `file_name` is an absolute path, and `false` otherwise.
|
60
348
|
#
|
61
349
|
# File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
|
62
350
|
#
|
63
351
|
def self.absolute_path?: (string | _ToPath file_name) -> bool
|
64
352
|
|
353
|
+
# <!--
|
354
|
+
# rdoc-file=file.c
|
355
|
+
# - File.atime(file_name) -> time
|
356
|
+
# -->
|
65
357
|
# Returns the last access time for the named file as a Time object.
|
66
358
|
#
|
67
359
|
# *file_name* can be an IO object.
|
@@ -70,6 +362,10 @@ class File < IO
|
|
70
362
|
#
|
71
363
|
def self.atime: (string | _ToPath | IO file_name) -> Time
|
72
364
|
|
365
|
+
# <!--
|
366
|
+
# rdoc-file=file.c
|
367
|
+
# - File.basename(file_name [, suffix] ) -> base_name
|
368
|
+
# -->
|
73
369
|
# Returns the last component of the filename given in *file_name* (after first
|
74
370
|
# stripping trailing separators), which can be formed using both File::SEPARATOR
|
75
371
|
# and File::ALT_SEPARATOR as the separator when File::ALT_SEPARATOR is not
|
@@ -82,20 +378,37 @@ class File < IO
|
|
82
378
|
#
|
83
379
|
def self.basename: (string | _ToPath file_name, ?string suffix) -> String
|
84
380
|
|
381
|
+
# <!--
|
382
|
+
# rdoc-file=file.c
|
383
|
+
# - birthtime(p1)
|
384
|
+
# -->
|
385
|
+
#
|
85
386
|
def self.birthtime: (string | _ToPath | IO file_name) -> Time
|
86
387
|
|
388
|
+
# <!--
|
389
|
+
# rdoc-file=file.c
|
390
|
+
# - File.blockdev?(file_name) -> true or false
|
391
|
+
# -->
|
87
392
|
# Returns `true` if the named file is a block device.
|
88
393
|
#
|
89
394
|
# *file_name* can be an IO object.
|
90
395
|
#
|
91
396
|
def self.blockdev?: (string | _ToPath | IO file_name) -> bool
|
92
397
|
|
398
|
+
# <!--
|
399
|
+
# rdoc-file=file.c
|
400
|
+
# - File.chardev?(file_name) -> true or false
|
401
|
+
# -->
|
93
402
|
# Returns `true` if the named file is a character device.
|
94
403
|
#
|
95
404
|
# *file_name* can be an IO object.
|
96
405
|
#
|
97
406
|
def self.chardev?: (string | _ToPath | IO file_name) -> bool
|
98
407
|
|
408
|
+
# <!--
|
409
|
+
# rdoc-file=file.c
|
410
|
+
# - File.chmod(mode_int, file_name, ... ) -> integer
|
411
|
+
# -->
|
99
412
|
# Changes permission bits on the named file(s) to the bit pattern represented by
|
100
413
|
# *mode_int*. Actual effects are operating system dependent (see the beginning
|
101
414
|
# of this section). On Unix systems, see `chmod(2)` for details. Returns the
|
@@ -103,8 +416,12 @@ class File < IO
|
|
103
416
|
#
|
104
417
|
# File.chmod(0644, "testfile", "out") #=> 2
|
105
418
|
#
|
106
|
-
def self.chmod: (int mode, *
|
419
|
+
def self.chmod: (int mode, *string | _ToPath file_name) -> Integer
|
107
420
|
|
421
|
+
# <!--
|
422
|
+
# rdoc-file=file.c
|
423
|
+
# - File.chown(owner_int, group_int, file_name, ...) -> integer
|
424
|
+
# -->
|
108
425
|
# Changes the owner and group of the named file(s) to the given numeric owner
|
109
426
|
# and group id's. Only a process with superuser privileges may change the owner
|
110
427
|
# of a file. The current owner of a file may change the file's group to any
|
@@ -113,8 +430,12 @@ class File < IO
|
|
113
430
|
#
|
114
431
|
# File.chown(nil, 100, "testfile")
|
115
432
|
#
|
116
|
-
def self.chown: (int? owner, int? group, *
|
433
|
+
def self.chown: (int? owner, int? group, *string | _ToPath file_name) -> Integer
|
117
434
|
|
435
|
+
# <!--
|
436
|
+
# rdoc-file=file.c
|
437
|
+
# - File.ctime(file_name) -> time
|
438
|
+
# -->
|
118
439
|
# Returns the change time for the named file (the time at which directory
|
119
440
|
# information about the file was changed, not the file itself).
|
120
441
|
#
|
@@ -126,6 +447,11 @@ class File < IO
|
|
126
447
|
#
|
127
448
|
def self.ctime: (string | _ToPath | IO file_name) -> Time
|
128
449
|
|
450
|
+
# <!--
|
451
|
+
# rdoc-file=file.c
|
452
|
+
# - File.delete(file_name, ...) -> integer
|
453
|
+
# - File.unlink(file_name, ...) -> integer
|
454
|
+
# -->
|
129
455
|
# Deletes the named files, returning the number of names passed as arguments.
|
130
456
|
# Raises an exception on any error. Since the underlying implementation relies
|
131
457
|
# on the `unlink(2)` system call, the type of exception raised depends on its
|
@@ -136,6 +462,10 @@ class File < IO
|
|
136
462
|
#
|
137
463
|
alias self.delete self.unlink
|
138
464
|
|
465
|
+
# <!--
|
466
|
+
# rdoc-file=file.c
|
467
|
+
# - File.directory?(file_name) -> true or false
|
468
|
+
# -->
|
139
469
|
# Returns `true` if the named file is a directory, or a symlink that points at a
|
140
470
|
# directory, and `false` otherwise.
|
141
471
|
#
|
@@ -145,6 +475,10 @@ class File < IO
|
|
145
475
|
#
|
146
476
|
def self.directory?: (string | _ToPath | IO path) -> bool
|
147
477
|
|
478
|
+
# <!--
|
479
|
+
# rdoc-file=file.c
|
480
|
+
# - File.dirname(file_name, level = 1) -> dir_name
|
481
|
+
# -->
|
148
482
|
# Returns all components of the filename given in *file_name* except the last
|
149
483
|
# one (after first stripping trailing separators). The filename can be formed
|
150
484
|
# using both File::SEPARATOR and File::ALT_SEPARATOR as the separator when
|
@@ -152,14 +486,27 @@ class File < IO
|
|
152
486
|
#
|
153
487
|
# File.dirname("/home/gumby/work/ruby.rb") #=> "/home/gumby/work"
|
154
488
|
#
|
155
|
-
|
489
|
+
# If `level` is given, removes the last `level` components, not only one.
|
490
|
+
#
|
491
|
+
# File.dirname("/home/gumby/work/ruby.rb", 2) #=> "/home/gumby"
|
492
|
+
# File.dirname("/home/gumby/work/ruby.rb", 4) #=> "/"
|
493
|
+
#
|
494
|
+
def self.dirname: (string | _ToPath file_name, ?Integer level) -> String
|
156
495
|
|
496
|
+
# <!--
|
497
|
+
# rdoc-file=file.c
|
498
|
+
# - File.zero?(file_name) -> true or false
|
499
|
+
# -->
|
157
500
|
# Returns `true` if the named file exists and has a zero size.
|
158
501
|
#
|
159
502
|
# *file_name* can be an IO object.
|
160
503
|
#
|
161
504
|
alias self.empty? self.zero?
|
162
505
|
|
506
|
+
# <!--
|
507
|
+
# rdoc-file=file.c
|
508
|
+
# - File.executable?(file_name) -> true or false
|
509
|
+
# -->
|
163
510
|
# Returns `true` if the named file is executable by the effective user and group
|
164
511
|
# id of this process. See eaccess(3).
|
165
512
|
#
|
@@ -172,6 +519,10 @@ class File < IO
|
|
172
519
|
#
|
173
520
|
def self.executable?: (string | _ToPath file_name) -> bool
|
174
521
|
|
522
|
+
# <!--
|
523
|
+
# rdoc-file=file.c
|
524
|
+
# - File.executable_real?(file_name) -> true or false
|
525
|
+
# -->
|
175
526
|
# Returns `true` if the named file is executable by the real user and group id
|
176
527
|
# of this process. See access(3).
|
177
528
|
#
|
@@ -184,6 +535,10 @@ class File < IO
|
|
184
535
|
#
|
185
536
|
def self.executable_real?: (string | _ToPath file_name) -> bool
|
186
537
|
|
538
|
+
# <!--
|
539
|
+
# rdoc-file=file.c
|
540
|
+
# - File.exist?(file_name) -> true or false
|
541
|
+
# -->
|
187
542
|
# Return `true` if the named file exists.
|
188
543
|
#
|
189
544
|
# *file_name* can be an IO object.
|
@@ -192,6 +547,10 @@ class File < IO
|
|
192
547
|
#
|
193
548
|
def self.exist?: (string | _ToPath | IO file_name) -> bool
|
194
549
|
|
550
|
+
# <!--
|
551
|
+
# rdoc-file=file.c
|
552
|
+
# - File.expand_path(file_name [, dir_string] ) -> abs_file_name
|
553
|
+
# -->
|
195
554
|
# Converts a pathname to an absolute pathname. Relative paths are referenced
|
196
555
|
# from the current working directory of the process unless `dir_string` is
|
197
556
|
# given, in which case it will be used as the starting point. The given pathname
|
@@ -213,8 +572,12 @@ class File < IO
|
|
213
572
|
# So first it resolves the parent of __FILE__, that is bin/, then go to the
|
214
573
|
# parent, the root of the project and appends `lib/mygem.rb`.
|
215
574
|
#
|
216
|
-
def self.expand_path: (string | _ToPath file_name, ?
|
575
|
+
def self.expand_path: (string | _ToPath file_name, ?string | _ToPath dir_string) -> String
|
217
576
|
|
577
|
+
# <!--
|
578
|
+
# rdoc-file=file.c
|
579
|
+
# - File.extname(path) -> string
|
580
|
+
# -->
|
218
581
|
# Returns the extension (the portion of file name in `path` starting from the
|
219
582
|
# last period).
|
220
583
|
#
|
@@ -237,6 +600,10 @@ class File < IO
|
|
237
600
|
#
|
238
601
|
def self.extname: (string | _ToPath path) -> String
|
239
602
|
|
603
|
+
# <!--
|
604
|
+
# rdoc-file=file.c
|
605
|
+
# - File.file?(file) -> true or false
|
606
|
+
# -->
|
240
607
|
# Returns `true` if the named `file` exists and is a regular file.
|
241
608
|
#
|
242
609
|
# `file` can be an IO object.
|
@@ -246,16 +613,21 @@ class File < IO
|
|
246
613
|
#
|
247
614
|
def self.file?: (string | _ToPath | IO file) -> bool
|
248
615
|
|
616
|
+
# <!--
|
617
|
+
# rdoc-file=dir.rb
|
618
|
+
# - File.fnmatch( pattern, path, [flags] ) -> (true or false)
|
619
|
+
# - File.fnmatch?( pattern, path, [flags] ) -> (true or false)
|
620
|
+
# -->
|
249
621
|
# Returns true if `path` matches against `pattern`. The pattern is not a
|
250
622
|
# regular expression; instead it follows rules similar to shell filename
|
251
623
|
# globbing. It may contain the following metacharacters:
|
252
624
|
#
|
253
625
|
# `*`
|
254
626
|
# : Matches any file. Can be restricted by other values in the glob.
|
255
|
-
# Equivalent to
|
627
|
+
# Equivalent to `/.*/x` in regexp.
|
256
628
|
#
|
257
629
|
# `*`
|
258
|
-
# : Matches all
|
630
|
+
# : Matches all regular files
|
259
631
|
# `c*`
|
260
632
|
# : Matches all files beginning with `c`
|
261
633
|
# `*c`
|
@@ -265,7 +637,7 @@ class File < IO
|
|
265
637
|
# end).
|
266
638
|
#
|
267
639
|
#
|
268
|
-
# To match hidden files (that start with a `.` set the File::FNM_DOTMATCH
|
640
|
+
# To match hidden files (that start with a `.`) set the File::FNM_DOTMATCH
|
269
641
|
# flag.
|
270
642
|
#
|
271
643
|
# `**`
|
@@ -278,7 +650,7 @@ class File < IO
|
|
278
650
|
# : Matches any one character in `set`. Behaves exactly like character sets
|
279
651
|
# in Regexp, including set negation (`[^a-z]`).
|
280
652
|
#
|
281
|
-
#
|
653
|
+
# `\`
|
282
654
|
# : Escapes the next metacharacter.
|
283
655
|
#
|
284
656
|
# `{a,b}`
|
@@ -321,125 +693,33 @@ class File < IO
|
|
321
693
|
# File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default.
|
322
694
|
# File.fnmatch('.*', '.profile') #=> true
|
323
695
|
#
|
324
|
-
#
|
325
|
-
# File.fnmatch(
|
326
|
-
# File.fnmatch(
|
327
|
-
# File.fnmatch(rbfiles, 'lib/song.rb') #=> true
|
696
|
+
# File.fnmatch('**/*.rb', 'main.rb') #=> false
|
697
|
+
# File.fnmatch('**/*.rb', './main.rb') #=> false
|
698
|
+
# File.fnmatch('**/*.rb', 'lib/song.rb') #=> true
|
328
699
|
# File.fnmatch('**.rb', 'main.rb') #=> true
|
329
700
|
# File.fnmatch('**.rb', './main.rb') #=> false
|
330
701
|
# File.fnmatch('**.rb', 'lib/song.rb') #=> true
|
331
|
-
# File.fnmatch('*',
|
332
|
-
#
|
333
|
-
# pattern = '*' '/' '*'
|
334
|
-
# File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false
|
335
|
-
# File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
|
702
|
+
# File.fnmatch('*', 'dave/.profile') #=> true
|
336
703
|
#
|
337
|
-
#
|
338
|
-
# File.fnmatch(
|
339
|
-
# File.fnmatch(
|
340
|
-
# File.fnmatch(
|
341
|
-
# File.fnmatch(
|
342
|
-
# File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
|
704
|
+
# File.fnmatch('**/foo', 'a/b/c/foo', File::FNM_PATHNAME) #=> true
|
705
|
+
# File.fnmatch('**/foo', '/a/b/c/foo', File::FNM_PATHNAME) #=> true
|
706
|
+
# File.fnmatch('**/foo', 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true
|
707
|
+
# File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
|
708
|
+
# File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
|
343
709
|
#
|
344
710
|
def self.fnmatch: (string pattern, string | _ToPath path, ?int flags) -> bool
|
345
711
|
|
346
|
-
#
|
347
|
-
#
|
348
|
-
#
|
349
|
-
#
|
350
|
-
# `*`
|
351
|
-
# : Matches any file. Can be restricted by other values in the glob.
|
352
|
-
# Equivalent to `/ .* /x` in regexp.
|
353
|
-
#
|
354
|
-
# `*`
|
355
|
-
# : Matches all files regular files
|
356
|
-
# `c*`
|
357
|
-
# : Matches all files beginning with `c`
|
358
|
-
# `*c`
|
359
|
-
# : Matches all files ending with `c`
|
360
|
-
# `*c*`
|
361
|
-
# : Matches all files that have `c` in them (including at the beginning or
|
362
|
-
# end).
|
363
|
-
#
|
364
|
-
#
|
365
|
-
# To match hidden files (that start with a `.` set the File::FNM_DOTMATCH
|
366
|
-
# flag.
|
367
|
-
#
|
368
|
-
# `**`
|
369
|
-
# : Matches directories recursively or files expansively.
|
370
|
-
#
|
371
|
-
# `?`
|
372
|
-
# : Matches any one character. Equivalent to `/.{1}/` in regexp.
|
373
|
-
#
|
374
|
-
# `[set]`
|
375
|
-
# : Matches any one character in `set`. Behaves exactly like character sets
|
376
|
-
# in Regexp, including set negation (`[^a-z]`).
|
377
|
-
#
|
378
|
-
# ` \ `
|
379
|
-
# : Escapes the next metacharacter.
|
380
|
-
#
|
381
|
-
# `{a,b}`
|
382
|
-
# : Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled.
|
383
|
-
# Behaves like a Regexp union (`(?:a|b)`).
|
384
|
-
#
|
385
|
-
#
|
386
|
-
# `flags` is a bitwise OR of the `FNM_XXX` constants. The same glob pattern and
|
387
|
-
# flags are used by Dir::glob.
|
388
|
-
#
|
389
|
-
# Examples:
|
390
|
-
#
|
391
|
-
# File.fnmatch('cat', 'cat') #=> true # match entire string
|
392
|
-
# File.fnmatch('cat', 'category') #=> false # only match partial string
|
393
|
-
#
|
394
|
-
# File.fnmatch('c{at,ub}s', 'cats') #=> false # { } isn't supported by default
|
395
|
-
# File.fnmatch('c{at,ub}s', 'cats', File::FNM_EXTGLOB) #=> true # { } is supported on FNM_EXTGLOB
|
396
|
-
#
|
397
|
-
# File.fnmatch('c?t', 'cat') #=> true # '?' match only 1 character
|
398
|
-
# File.fnmatch('c??t', 'cat') #=> false # ditto
|
399
|
-
# File.fnmatch('c*', 'cats') #=> true # '*' match 0 or more characters
|
400
|
-
# File.fnmatch('c*t', 'c/a/b/t') #=> true # ditto
|
401
|
-
# File.fnmatch('ca[a-z]', 'cat') #=> true # inclusive bracket expression
|
402
|
-
# File.fnmatch('ca[^t]', 'cat') #=> false # exclusive bracket expression ('^' or '!')
|
403
|
-
#
|
404
|
-
# File.fnmatch('cat', 'CAT') #=> false # case sensitive
|
405
|
-
# File.fnmatch('cat', 'CAT', File::FNM_CASEFOLD) #=> true # case insensitive
|
406
|
-
# File.fnmatch('cat', 'CAT', File::FNM_SYSCASE) #=> true or false # depends on the system default
|
407
|
-
#
|
408
|
-
# File.fnmatch('?', '/', File::FNM_PATHNAME) #=> false # wildcard doesn't match '/' on FNM_PATHNAME
|
409
|
-
# File.fnmatch('*', '/', File::FNM_PATHNAME) #=> false # ditto
|
410
|
-
# File.fnmatch('[/]', '/', File::FNM_PATHNAME) #=> false # ditto
|
411
|
-
#
|
412
|
-
# File.fnmatch('\?', '?') #=> true # escaped wildcard becomes ordinary
|
413
|
-
# File.fnmatch('\a', 'a') #=> true # escaped ordinary remains ordinary
|
414
|
-
# File.fnmatch('\a', '\a', File::FNM_NOESCAPE) #=> true # FNM_NOESCAPE makes '\' ordinary
|
415
|
-
# File.fnmatch('[\?]', '?') #=> true # can escape inside bracket expression
|
416
|
-
#
|
417
|
-
# File.fnmatch('*', '.profile') #=> false # wildcard doesn't match leading
|
418
|
-
# File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default.
|
419
|
-
# File.fnmatch('.*', '.profile') #=> true
|
420
|
-
#
|
421
|
-
# rbfiles = '**' '/' '*.rb' # you don't have to do like this. just write in single string.
|
422
|
-
# File.fnmatch(rbfiles, 'main.rb') #=> false
|
423
|
-
# File.fnmatch(rbfiles, './main.rb') #=> false
|
424
|
-
# File.fnmatch(rbfiles, 'lib/song.rb') #=> true
|
425
|
-
# File.fnmatch('**.rb', 'main.rb') #=> true
|
426
|
-
# File.fnmatch('**.rb', './main.rb') #=> false
|
427
|
-
# File.fnmatch('**.rb', 'lib/song.rb') #=> true
|
428
|
-
# File.fnmatch('*', 'dave/.profile') #=> true
|
429
|
-
#
|
430
|
-
# pattern = '*' '/' '*'
|
431
|
-
# File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false
|
432
|
-
# File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
|
433
|
-
#
|
434
|
-
# pattern = '**' '/' 'foo'
|
435
|
-
# File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME) #=> true
|
436
|
-
# File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME) #=> true
|
437
|
-
# File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true
|
438
|
-
# File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
|
439
|
-
# File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
|
712
|
+
# <!--
|
713
|
+
# rdoc-file=dir.rb
|
714
|
+
# - fnmatch?(pattern, path, flags = 0)
|
715
|
+
# -->
|
440
716
|
#
|
441
717
|
alias self.fnmatch? self.fnmatch
|
442
718
|
|
719
|
+
# <!--
|
720
|
+
# rdoc-file=file.c
|
721
|
+
# - File.ftype(file_name) -> string
|
722
|
+
# -->
|
443
723
|
# Identifies the type of the named file; the return string is one of ```file`'',
|
444
724
|
# ```directory`'', ```characterSpecial`'', ```blockSpecial`'', ```fifo`'',
|
445
725
|
# ```link`'', ```socket`'', or ```unknown`''.
|
@@ -450,6 +730,10 @@ class File < IO
|
|
450
730
|
#
|
451
731
|
def self.ftype: (string | _ToPath file_name) -> String
|
452
732
|
|
733
|
+
# <!--
|
734
|
+
# rdoc-file=file.c
|
735
|
+
# - File.grpowned?(file_name) -> true or false
|
736
|
+
# -->
|
453
737
|
# Returns `true` if the named file exists and the effective group id of the
|
454
738
|
# calling process is the owner of the file. Returns `false` on Windows.
|
455
739
|
#
|
@@ -457,6 +741,10 @@ class File < IO
|
|
457
741
|
#
|
458
742
|
def self.grpowned?: (string | _ToPath | IO file_name) -> bool
|
459
743
|
|
744
|
+
# <!--
|
745
|
+
# rdoc-file=file.c
|
746
|
+
# - File.identical?(file_1, file_2) -> true or false
|
747
|
+
# -->
|
460
748
|
# Returns `true` if the named files are identical.
|
461
749
|
#
|
462
750
|
# *file_1* and *file_2* can be an IO object.
|
@@ -473,24 +761,40 @@ class File < IO
|
|
473
761
|
#
|
474
762
|
def self.identical?: (string | _ToPath | IO file_1, string | _ToPath | IO file_2) -> bool
|
475
763
|
|
764
|
+
# <!--
|
765
|
+
# rdoc-file=file.c
|
766
|
+
# - File.join(string, ...) -> string
|
767
|
+
# -->
|
476
768
|
# Returns a new string formed by joining the strings using `"/"`.
|
477
769
|
#
|
478
770
|
# File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
|
479
771
|
#
|
480
772
|
def self.join: (*string) -> String
|
481
773
|
|
774
|
+
# <!--
|
775
|
+
# rdoc-file=file.c
|
776
|
+
# - File.lchmod(mode_int, file_name, ...) -> integer
|
777
|
+
# -->
|
482
778
|
# Equivalent to File::chmod, but does not follow symbolic links (so it will
|
483
779
|
# change the permissions associated with the link, not the file referenced by
|
484
780
|
# the link). Often not available.
|
485
781
|
#
|
486
|
-
def self.lchmod: (int mode, *
|
782
|
+
def self.lchmod: (int mode, *string | _ToPath file_name) -> Integer
|
487
783
|
|
784
|
+
# <!--
|
785
|
+
# rdoc-file=file.c
|
786
|
+
# - File.lchown(owner_int, group_int, file_name,..) -> integer
|
787
|
+
# -->
|
488
788
|
# Equivalent to File::chown, but does not follow symbolic links (so it will
|
489
789
|
# change the owner associated with the link, not the file referenced by the
|
490
790
|
# link). Often not available. Returns number of files in the argument list.
|
491
791
|
#
|
492
|
-
def self.lchown: (int? owner, int? group, *
|
792
|
+
def self.lchown: (int? owner, int? group, *string | _ToPath file_name) -> Integer
|
493
793
|
|
794
|
+
# <!--
|
795
|
+
# rdoc-file=file.c
|
796
|
+
# - File.link(old_name, new_name) -> 0
|
797
|
+
# -->
|
494
798
|
# Creates a new name for an existing file using a hard link. Will not overwrite
|
495
799
|
# *new_name* if it already exists (raising a subclass of SystemCallError). Not
|
496
800
|
# available on all platforms.
|
@@ -500,6 +804,10 @@ class File < IO
|
|
500
804
|
#
|
501
805
|
def self.link: (string | _ToPath old_name, string | _ToPath new_name) -> 0
|
502
806
|
|
807
|
+
# <!--
|
808
|
+
# rdoc-file=file.c
|
809
|
+
# - File.lstat(file_name) -> stat
|
810
|
+
# -->
|
503
811
|
# Same as File::stat, but does not follow the last symbolic link. Instead,
|
504
812
|
# reports on the link itself.
|
505
813
|
#
|
@@ -510,19 +818,31 @@ class File < IO
|
|
510
818
|
#
|
511
819
|
def self.lstat: (string | _ToPath file_name) -> File::Stat
|
512
820
|
|
821
|
+
# <!--
|
822
|
+
# rdoc-file=file.c
|
823
|
+
# - File.lutime(atime, mtime, file_name, ...) -> integer
|
824
|
+
# -->
|
513
825
|
# Sets the access and modification times of each named file to the first two
|
514
826
|
# arguments. If a file is a symlink, this method acts upon the link itself as
|
515
827
|
# opposed to its referent; for the inverse behavior, see File.utime. Returns the
|
516
828
|
# number of file names in the argument list.
|
517
829
|
#
|
518
|
-
def self.lutime: (
|
830
|
+
def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *string | _ToPath file_name) -> Integer
|
519
831
|
|
832
|
+
# <!--
|
833
|
+
# rdoc-file=file.c
|
834
|
+
# - File.mkfifo(file_name, mode=0666) => 0
|
835
|
+
# -->
|
520
836
|
# Creates a FIFO special file with name *file_name*. *mode* specifies the
|
521
837
|
# FIFO's permissions. It is modified by the process's umask in the usual way:
|
522
838
|
# the permissions of the created file are (mode & ~umask).
|
523
839
|
#
|
524
|
-
def self.mkfifo: (
|
840
|
+
def self.mkfifo: (string | _ToPath file_name, ?int mode) -> 0
|
525
841
|
|
842
|
+
# <!--
|
843
|
+
# rdoc-file=file.c
|
844
|
+
# - File.mtime(file_name) -> time
|
845
|
+
# -->
|
526
846
|
# Returns the modification time for the named file as a Time object.
|
527
847
|
#
|
528
848
|
# *file_name* can be an IO object.
|
@@ -531,10 +851,30 @@ class File < IO
|
|
531
851
|
#
|
532
852
|
def self.mtime: (string | _ToPath | IO file_name) -> Time
|
533
853
|
|
534
|
-
#
|
535
|
-
|
536
|
-
|
537
|
-
|
854
|
+
# <!--
|
855
|
+
# rdoc-file=io.c
|
856
|
+
# - File.open(filename, mode="r" [, opt]) -> file
|
857
|
+
# - File.open(filename [, mode [, perm]] [, opt]) -> file
|
858
|
+
# - File.open(filename, mode="r" [, opt]) {|file| block } -> obj
|
859
|
+
# - File.open(filename [, mode [, perm]] [, opt]) {|file| block } -> obj
|
860
|
+
# -->
|
861
|
+
# With no associated block, File.open is a synonym for File.new. If the optional
|
862
|
+
# code block is given, it will be passed the opened `file` as an argument and
|
863
|
+
# the File object will automatically be closed when the block terminates. The
|
864
|
+
# value of the block will be returned from File.open.
|
865
|
+
#
|
866
|
+
# If a file is being created, its initial permissions may be set using the
|
867
|
+
# `perm` parameter. See File.new for further discussion.
|
868
|
+
#
|
869
|
+
# See IO.new for a description of the `mode` and `opt` parameters.
|
870
|
+
#
|
871
|
+
def self.open: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> instance
|
872
|
+
| [T] (string | _ToPath | int file_name, ?string | int mode, ?int perm) { (File) -> T } -> T
|
873
|
+
|
874
|
+
# <!--
|
875
|
+
# rdoc-file=file.c
|
876
|
+
# - File.owned?(file_name) -> true or false
|
877
|
+
# -->
|
538
878
|
# Returns `true` if the named file exists and the effective used id of the
|
539
879
|
# calling process is the owner of the file.
|
540
880
|
#
|
@@ -542,6 +882,10 @@ class File < IO
|
|
542
882
|
#
|
543
883
|
def self.owned?: (string | _ToPath | IO file_name) -> bool
|
544
884
|
|
885
|
+
# <!--
|
886
|
+
# rdoc-file=file.c
|
887
|
+
# - File.path(path) -> string
|
888
|
+
# -->
|
545
889
|
# Returns the string representation of the path
|
546
890
|
#
|
547
891
|
# File.path("/dev/null") #=> "/dev/null"
|
@@ -549,12 +893,20 @@ class File < IO
|
|
549
893
|
#
|
550
894
|
def self.path: (string | _ToPath path) -> String
|
551
895
|
|
896
|
+
# <!--
|
897
|
+
# rdoc-file=file.c
|
898
|
+
# - File.pipe?(file_name) -> true or false
|
899
|
+
# -->
|
552
900
|
# Returns `true` if the named file is a pipe.
|
553
901
|
#
|
554
902
|
# *file_name* can be an IO object.
|
555
903
|
#
|
556
904
|
def self.pipe?: (string | _ToPath | IO file_name) -> bool
|
557
905
|
|
906
|
+
# <!--
|
907
|
+
# rdoc-file=file.c
|
908
|
+
# - File.readable?(file_name) -> true or false
|
909
|
+
# -->
|
558
910
|
# Returns `true` if the named file is readable by the effective user and group
|
559
911
|
# id of this process. See eaccess(3).
|
560
912
|
#
|
@@ -563,6 +915,10 @@ class File < IO
|
|
563
915
|
#
|
564
916
|
def self.readable?: (string | _ToPath file_name) -> bool
|
565
917
|
|
918
|
+
# <!--
|
919
|
+
# rdoc-file=file.c
|
920
|
+
# - File.readable_real?(file_name) -> true or false
|
921
|
+
# -->
|
566
922
|
# Returns `true` if the named file is readable by the real user and group id of
|
567
923
|
# this process. See access(3).
|
568
924
|
#
|
@@ -571,6 +927,10 @@ class File < IO
|
|
571
927
|
#
|
572
928
|
def self.readable_real?: (string | _ToPath file_name) -> bool
|
573
929
|
|
930
|
+
# <!--
|
931
|
+
# rdoc-file=file.c
|
932
|
+
# - File.readlink(link_name) -> file_name
|
933
|
+
# -->
|
574
934
|
# Returns the name of the file referenced by the given link. Not available on
|
575
935
|
# all platforms.
|
576
936
|
#
|
@@ -579,6 +939,10 @@ class File < IO
|
|
579
939
|
#
|
580
940
|
def self.readlink: (string | _ToPath link_name) -> String
|
581
941
|
|
942
|
+
# <!--
|
943
|
+
# rdoc-file=file.c
|
944
|
+
# - File.realdirpath(pathname [, dir_string]) -> real_pathname
|
945
|
+
# -->
|
582
946
|
# Returns the real (absolute) pathname of *pathname* in the actual filesystem.
|
583
947
|
# The real pathname doesn't contain symlinks or useless dots.
|
584
948
|
#
|
@@ -587,8 +951,12 @@ class File < IO
|
|
587
951
|
#
|
588
952
|
# The last component of the real pathname can be nonexistent.
|
589
953
|
#
|
590
|
-
def self.realdirpath: (string | _ToPath pathname, ?
|
954
|
+
def self.realdirpath: (string | _ToPath pathname, ?string | _ToPath dir_string) -> String
|
591
955
|
|
956
|
+
# <!--
|
957
|
+
# rdoc-file=file.c
|
958
|
+
# - File.realpath(pathname [, dir_string]) -> real_pathname
|
959
|
+
# -->
|
592
960
|
# Returns the real (absolute) pathname of *pathname* in the actual filesystem
|
593
961
|
# not containing symlinks or useless dots.
|
594
962
|
#
|
@@ -597,8 +965,12 @@ class File < IO
|
|
597
965
|
#
|
598
966
|
# All components of the pathname must exist when this method is called.
|
599
967
|
#
|
600
|
-
def self.realpath: (string | _ToPath pathname, ?
|
968
|
+
def self.realpath: (string | _ToPath pathname, ?string | _ToPath dir_string) -> String
|
601
969
|
|
970
|
+
# <!--
|
971
|
+
# rdoc-file=file.c
|
972
|
+
# - File.rename(old_name, new_name) -> 0
|
973
|
+
# -->
|
602
974
|
# Renames the given file to the new name. Raises a SystemCallError if the file
|
603
975
|
# cannot be renamed.
|
604
976
|
#
|
@@ -606,24 +978,40 @@ class File < IO
|
|
606
978
|
#
|
607
979
|
def self.rename: (string | _ToPath old_name, string | _ToPath new_name) -> 0
|
608
980
|
|
981
|
+
# <!--
|
982
|
+
# rdoc-file=file.c
|
983
|
+
# - File.setgid?(file_name) -> true or false
|
984
|
+
# -->
|
609
985
|
# Returns `true` if the named file has the setgid bit set.
|
610
986
|
#
|
611
987
|
# *file_name* can be an IO object.
|
612
988
|
#
|
613
989
|
def self.setgid?: (string | _ToPath | IO file_name) -> bool
|
614
990
|
|
991
|
+
# <!--
|
992
|
+
# rdoc-file=file.c
|
993
|
+
# - File.setuid?(file_name) -> true or false
|
994
|
+
# -->
|
615
995
|
# Returns `true` if the named file has the setuid bit set.
|
616
996
|
#
|
617
997
|
# *file_name* can be an IO object.
|
618
998
|
#
|
619
999
|
def self.setuid?: (string | _ToPath | IO file_name) -> bool
|
620
1000
|
|
1001
|
+
# <!--
|
1002
|
+
# rdoc-file=file.c
|
1003
|
+
# - File.size(file_name) -> integer
|
1004
|
+
# -->
|
621
1005
|
# Returns the size of `file_name`.
|
622
1006
|
#
|
623
1007
|
# *file_name* can be an IO object.
|
624
1008
|
#
|
625
1009
|
def self.size: (string | _ToPath | IO file_name) -> Integer
|
626
1010
|
|
1011
|
+
# <!--
|
1012
|
+
# rdoc-file=file.c
|
1013
|
+
# - File.size?(file_name) -> Integer or nil
|
1014
|
+
# -->
|
627
1015
|
# Returns `nil` if `file_name` doesn't exist or has zero size, the size of the
|
628
1016
|
# file otherwise.
|
629
1017
|
#
|
@@ -631,31 +1019,51 @@ class File < IO
|
|
631
1019
|
#
|
632
1020
|
def self.size?: (string | _ToPath | IO file_name) -> Integer?
|
633
1021
|
|
1022
|
+
# <!--
|
1023
|
+
# rdoc-file=file.c
|
1024
|
+
# - File.socket?(file_name) -> true or false
|
1025
|
+
# -->
|
634
1026
|
# Returns `true` if the named file is a socket.
|
635
1027
|
#
|
636
1028
|
# *file_name* can be an IO object.
|
637
1029
|
#
|
638
1030
|
def self.socket?: (string | _ToPath | IO file_name) -> bool
|
639
1031
|
|
1032
|
+
# <!--
|
1033
|
+
# rdoc-file=file.c
|
1034
|
+
# - File.split(file_name) -> array
|
1035
|
+
# -->
|
640
1036
|
# Splits the given string into a directory and a file component and returns them
|
641
1037
|
# in a two-element array. See also File::dirname and File::basename.
|
642
1038
|
#
|
643
1039
|
# File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
|
644
1040
|
#
|
645
|
-
def self.split: (string | _ToPath file_name) -> [String, String]
|
1041
|
+
def self.split: (string | _ToPath file_name) -> [ String, String ]
|
646
1042
|
|
1043
|
+
# <!--
|
1044
|
+
# rdoc-file=file.c
|
1045
|
+
# - File.stat(file_name) -> stat
|
1046
|
+
# -->
|
647
1047
|
# Returns a File::Stat object for the named file (see File::Stat).
|
648
1048
|
#
|
649
1049
|
# File.stat("testfile").mtime #=> Tue Apr 08 12:58:04 CDT 2003
|
650
1050
|
#
|
651
1051
|
def self.stat: (string | _ToPath file_name) -> File::Stat
|
652
1052
|
|
1053
|
+
# <!--
|
1054
|
+
# rdoc-file=file.c
|
1055
|
+
# - File.sticky?(file_name) -> true or false
|
1056
|
+
# -->
|
653
1057
|
# Returns `true` if the named file has the sticky bit set.
|
654
1058
|
#
|
655
1059
|
# *file_name* can be an IO object.
|
656
1060
|
#
|
657
1061
|
def self.sticky?: (string | _ToPath | IO file_name) -> bool
|
658
1062
|
|
1063
|
+
# <!--
|
1064
|
+
# rdoc-file=file.c
|
1065
|
+
# - File.symlink(old_name, new_name) -> 0
|
1066
|
+
# -->
|
659
1067
|
# Creates a symbolic link called *new_name* for the existing file *old_name*.
|
660
1068
|
# Raises a NotImplemented exception on platforms that do not support symbolic
|
661
1069
|
# links.
|
@@ -664,10 +1072,18 @@ class File < IO
|
|
664
1072
|
#
|
665
1073
|
def self.symlink: (string | _ToPath old_name, string | _ToPath new_name) -> 0
|
666
1074
|
|
1075
|
+
# <!--
|
1076
|
+
# rdoc-file=file.c
|
1077
|
+
# - File.symlink?(file_name) -> true or false
|
1078
|
+
# -->
|
667
1079
|
# Returns `true` if the named file is a symbolic link.
|
668
1080
|
#
|
669
1081
|
def self.symlink?: (string | _ToPath file_name) -> bool
|
670
1082
|
|
1083
|
+
# <!--
|
1084
|
+
# rdoc-file=file.c
|
1085
|
+
# - File.truncate(file_name, integer) -> 0
|
1086
|
+
# -->
|
671
1087
|
# Truncates the file *file_name* to be at most *integer* bytes long. Not
|
672
1088
|
# available on all platforms.
|
673
1089
|
#
|
@@ -679,6 +1095,11 @@ class File < IO
|
|
679
1095
|
#
|
680
1096
|
def self.truncate: (string | _ToPath file_name, int length) -> 0
|
681
1097
|
|
1098
|
+
# <!--
|
1099
|
+
# rdoc-file=file.c
|
1100
|
+
# - File.umask() -> integer
|
1101
|
+
# - File.umask(integer) -> integer
|
1102
|
+
# -->
|
682
1103
|
# Returns the current umask value for this process. If the optional argument is
|
683
1104
|
# given, set the umask to that value and return the previous value. Umask values
|
684
1105
|
# are *subtracted* from the default permissions, so a umask of `0222` would make
|
@@ -689,6 +1110,11 @@ class File < IO
|
|
689
1110
|
#
|
690
1111
|
def self.umask: (?int umask) -> Integer
|
691
1112
|
|
1113
|
+
# <!--
|
1114
|
+
# rdoc-file=file.c
|
1115
|
+
# - File.delete(file_name, ...) -> integer
|
1116
|
+
# - File.unlink(file_name, ...) -> integer
|
1117
|
+
# -->
|
692
1118
|
# Deletes the named files, returning the number of names passed as arguments.
|
693
1119
|
# Raises an exception on any error. Since the underlying implementation relies
|
694
1120
|
# on the `unlink(2)` system call, the type of exception raised depends on its
|
@@ -697,15 +1123,23 @@ class File < IO
|
|
697
1123
|
#
|
698
1124
|
# See also Dir::rmdir.
|
699
1125
|
#
|
700
|
-
def self.unlink: (*
|
1126
|
+
def self.unlink: (*string | _ToPath file_name) -> Integer
|
701
1127
|
|
1128
|
+
# <!--
|
1129
|
+
# rdoc-file=file.c
|
1130
|
+
# - File.utime(atime, mtime, file_name, ...) -> integer
|
1131
|
+
# -->
|
702
1132
|
# Sets the access and modification times of each named file to the first two
|
703
1133
|
# arguments. If a file is a symlink, this method acts upon its referent rather
|
704
1134
|
# than the link itself; for the inverse behavior see File.lutime. Returns the
|
705
1135
|
# number of file names in the argument list.
|
706
1136
|
#
|
707
|
-
def self.utime: (
|
1137
|
+
def self.utime: (Time | Numeric atime, Time | Numeric mtime, *string | _ToPath file_name) -> Integer
|
708
1138
|
|
1139
|
+
# <!--
|
1140
|
+
# rdoc-file=file.c
|
1141
|
+
# - File.world_readable?(file_name) -> integer or nil
|
1142
|
+
# -->
|
709
1143
|
# If *file_name* is readable by others, returns an integer representing the file
|
710
1144
|
# permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
|
711
1145
|
# bits is platform dependent; on Unix systems, see `stat(2)`.
|
@@ -718,6 +1152,10 @@ class File < IO
|
|
718
1152
|
#
|
719
1153
|
def self.world_readable?: (string | _ToPath | IO file_name) -> Integer?
|
720
1154
|
|
1155
|
+
# <!--
|
1156
|
+
# rdoc-file=file.c
|
1157
|
+
# - File.world_writable?(file_name) -> integer or nil
|
1158
|
+
# -->
|
721
1159
|
# If *file_name* is writable by others, returns an integer representing the file
|
722
1160
|
# permission bits of *file_name*. Returns `nil` otherwise. The meaning of the
|
723
1161
|
# bits is platform dependent; on Unix systems, see `stat(2)`.
|
@@ -730,6 +1168,10 @@ class File < IO
|
|
730
1168
|
#
|
731
1169
|
def self.world_writable?: (string | _ToPath | IO file_name) -> Integer?
|
732
1170
|
|
1171
|
+
# <!--
|
1172
|
+
# rdoc-file=file.c
|
1173
|
+
# - File.writable?(file_name) -> true or false
|
1174
|
+
# -->
|
733
1175
|
# Returns `true` if the named file is writable by the effective user and group
|
734
1176
|
# id of this process. See eaccess(3).
|
735
1177
|
#
|
@@ -738,6 +1180,10 @@ class File < IO
|
|
738
1180
|
#
|
739
1181
|
def self.writable?: (string | _ToPath file_name) -> bool
|
740
1182
|
|
1183
|
+
# <!--
|
1184
|
+
# rdoc-file=file.c
|
1185
|
+
# - File.writable_real?(file_name) -> true or false
|
1186
|
+
# -->
|
741
1187
|
# Returns `true` if the named file is writable by the real user and group id of
|
742
1188
|
# this process. See access(3).
|
743
1189
|
#
|
@@ -746,6 +1192,10 @@ class File < IO
|
|
746
1192
|
#
|
747
1193
|
def self.writable_real?: (string | _ToPath file_name) -> bool
|
748
1194
|
|
1195
|
+
# <!--
|
1196
|
+
# rdoc-file=file.c
|
1197
|
+
# - File.zero?(file_name) -> true or false
|
1198
|
+
# -->
|
749
1199
|
# Returns `true` if the named file exists and has a zero size.
|
750
1200
|
#
|
751
1201
|
# *file_name* can be an IO object.
|
@@ -754,6 +1204,10 @@ class File < IO
|
|
754
1204
|
|
755
1205
|
public
|
756
1206
|
|
1207
|
+
# <!--
|
1208
|
+
# rdoc-file=file.c
|
1209
|
+
# - file.atime -> time
|
1210
|
+
# -->
|
757
1211
|
# Returns the last access time (a Time object) for *file*, or epoch if *file*
|
758
1212
|
# has not been accessed.
|
759
1213
|
#
|
@@ -761,6 +1215,10 @@ class File < IO
|
|
761
1215
|
#
|
762
1216
|
def atime: () -> Time
|
763
1217
|
|
1218
|
+
# <!--
|
1219
|
+
# rdoc-file=file.c
|
1220
|
+
# - file.birthtime -> time
|
1221
|
+
# -->
|
764
1222
|
# Returns the birth time for *file*.
|
765
1223
|
#
|
766
1224
|
# File.new("testfile").birthtime #=> Wed Apr 09 08:53:14 CDT 2003
|
@@ -769,6 +1227,10 @@ class File < IO
|
|
769
1227
|
#
|
770
1228
|
def birthtime: () -> Time
|
771
1229
|
|
1230
|
+
# <!--
|
1231
|
+
# rdoc-file=file.c
|
1232
|
+
# - file.chmod(mode_int) -> 0
|
1233
|
+
# -->
|
772
1234
|
# Changes permission bits on *file* to the bit pattern represented by
|
773
1235
|
# *mode_int*. Actual effects are platform dependent; on Unix systems, see
|
774
1236
|
# `chmod(2)` for details. Follows symbolic links. Also see File#lchmod.
|
@@ -778,6 +1240,10 @@ class File < IO
|
|
778
1240
|
#
|
779
1241
|
def chmod: (int mode) -> (0 | nil)
|
780
1242
|
|
1243
|
+
# <!--
|
1244
|
+
# rdoc-file=file.c
|
1245
|
+
# - file.chown(owner_int, group_int ) -> 0
|
1246
|
+
# -->
|
781
1247
|
# Changes the owner and group of *file* to the given numeric owner and group
|
782
1248
|
# id's. Only a process with superuser privileges may change the owner of a file.
|
783
1249
|
# The current owner of a file may change the file's group to any group to which
|
@@ -788,6 +1254,10 @@ class File < IO
|
|
788
1254
|
#
|
789
1255
|
def chown: (int? owner, int? group) -> (0 | nil)
|
790
1256
|
|
1257
|
+
# <!--
|
1258
|
+
# rdoc-file=file.c
|
1259
|
+
# - file.ctime -> time
|
1260
|
+
# -->
|
791
1261
|
# Returns the change time for *file* (that is, the time directory information
|
792
1262
|
# about the file was changed, not the file itself).
|
793
1263
|
#
|
@@ -797,6 +1267,10 @@ class File < IO
|
|
797
1267
|
#
|
798
1268
|
def ctime: () -> Time
|
799
1269
|
|
1270
|
+
# <!--
|
1271
|
+
# rdoc-file=file.c
|
1272
|
+
# - file.flock(locking_constant) -> 0 or false
|
1273
|
+
# -->
|
800
1274
|
# Locks or unlocks a file according to *locking_constant* (a logical *or* of the
|
801
1275
|
# values in the table below). Returns `false` if File::LOCK_NB is specified and
|
802
1276
|
# the operation would otherwise have blocked. Not available on all platforms.
|
@@ -835,6 +1309,10 @@ class File < IO
|
|
835
1309
|
#
|
836
1310
|
def flock: (int locking_constant) -> (0 | false)
|
837
1311
|
|
1312
|
+
# <!--
|
1313
|
+
# rdoc-file=file.c
|
1314
|
+
# - file.lstat -> stat
|
1315
|
+
# -->
|
838
1316
|
# Same as IO#stat, but does not follow the last symbolic link. Instead, reports
|
839
1317
|
# on the link itself.
|
840
1318
|
#
|
@@ -846,12 +1324,21 @@ class File < IO
|
|
846
1324
|
#
|
847
1325
|
def lstat: () -> (File::Stat | nil)
|
848
1326
|
|
1327
|
+
# <!--
|
1328
|
+
# rdoc-file=file.c
|
1329
|
+
# - file.mtime -> time
|
1330
|
+
# -->
|
849
1331
|
# Returns the modification time for *file*.
|
850
1332
|
#
|
851
1333
|
# File.new("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003
|
852
1334
|
#
|
853
1335
|
def mtime: () -> Time
|
854
1336
|
|
1337
|
+
# <!--
|
1338
|
+
# rdoc-file=file.c
|
1339
|
+
# - file.path -> filename
|
1340
|
+
# - file.to_path -> filename
|
1341
|
+
# -->
|
855
1342
|
# Returns the pathname used to create *file* as a string. Does not normalize the
|
856
1343
|
# name.
|
857
1344
|
#
|
@@ -866,12 +1353,14 @@ class File < IO
|
|
866
1353
|
#
|
867
1354
|
def path: () -> String
|
868
1355
|
|
869
|
-
#
|
870
|
-
#
|
871
|
-
#
|
1356
|
+
# <!--
|
1357
|
+
# rdoc-file=file.c
|
1358
|
+
# - size()
|
1359
|
+
# -->
|
872
1360
|
#
|
873
1361
|
def size: () -> Integer
|
874
1362
|
|
1363
|
+
# <!-- rdoc-file=file.c -->
|
875
1364
|
# Returns the pathname used to create *file* as a string. Does not normalize the
|
876
1365
|
# name.
|
877
1366
|
#
|
@@ -886,6 +1375,10 @@ class File < IO
|
|
886
1375
|
#
|
887
1376
|
alias to_path path
|
888
1377
|
|
1378
|
+
# <!--
|
1379
|
+
# rdoc-file=file.c
|
1380
|
+
# - file.truncate(integer) -> 0
|
1381
|
+
# -->
|
889
1382
|
# Truncates *file* to at most *integer* bytes. The file must be opened for
|
890
1383
|
# writing. Not available on all platforms.
|
891
1384
|
#
|
@@ -898,24 +1391,24 @@ class File < IO
|
|
898
1391
|
def truncate: (int length) -> 0
|
899
1392
|
end
|
900
1393
|
|
1394
|
+
# <!-- rdoc-file=file.c -->
|
901
1395
|
# platform specific alternative separator
|
902
1396
|
#
|
903
|
-
#
|
904
1397
|
File::ALT_SEPARATOR: String?
|
905
1398
|
|
1399
|
+
# <!-- rdoc-file=file.c -->
|
906
1400
|
# path list separator
|
907
1401
|
#
|
908
|
-
#
|
909
1402
|
File::PATH_SEPARATOR: String
|
910
1403
|
|
1404
|
+
# <!-- rdoc-file=file.c -->
|
911
1405
|
# separates directory parts in path
|
912
1406
|
#
|
913
|
-
#
|
914
1407
|
File::SEPARATOR: String
|
915
1408
|
|
1409
|
+
# <!-- rdoc-file=file.c -->
|
916
1410
|
# separates directory parts in path
|
917
1411
|
#
|
918
|
-
#
|
919
1412
|
File::Separator: String
|
920
1413
|
|
921
1414
|
module File::Constants
|
@@ -981,96 +1474,523 @@ File::Constants::TRUNC: Integer
|
|
981
1474
|
|
982
1475
|
File::Constants::WRONLY: Integer
|
983
1476
|
|
1477
|
+
# <!-- rdoc-file=file.c -->
|
1478
|
+
# Objects of class File::Stat encapsulate common status information for File
|
1479
|
+
# objects. The information is recorded at the moment the File::Stat object is
|
1480
|
+
# created; changes made to the file after that point will not be reflected.
|
1481
|
+
# File::Stat objects are returned by IO#stat, File::stat, File#lstat, and
|
1482
|
+
# File::lstat. Many of these methods return platform-specific values, and not
|
1483
|
+
# all values are meaningful on all systems. See also Kernel#test.
|
1484
|
+
#
|
984
1485
|
class File::Stat < Object
|
985
1486
|
include Comparable
|
986
1487
|
|
1488
|
+
# <!--
|
1489
|
+
# rdoc-file=file.c
|
1490
|
+
# - File::Stat.new(file_name) -> stat
|
1491
|
+
# -->
|
1492
|
+
# Create a File::Stat object for the given file name (raising an exception if
|
1493
|
+
# the file doesn't exist).
|
1494
|
+
#
|
987
1495
|
def initialize: (String file) -> Object
|
1496
|
+
|
1497
|
+
# <!--
|
1498
|
+
# rdoc-file=file.c
|
1499
|
+
# - stat <=> other_stat -> -1, 0, 1, nil
|
1500
|
+
# -->
|
1501
|
+
# Compares File::Stat objects by comparing their respective modification times.
|
1502
|
+
#
|
1503
|
+
# `nil` is returned if `other_stat` is not a File::Stat object
|
1504
|
+
#
|
1505
|
+
# f1 = File.new("f1", "w")
|
1506
|
+
# sleep 1
|
1507
|
+
# f2 = File.new("f2", "w")
|
1508
|
+
# f1.stat <=> f2.stat #=> -1
|
1509
|
+
#
|
988
1510
|
def <=>: (File::Stat other) -> Integer
|
989
1511
|
| (untyped) -> nil
|
990
1512
|
|
1513
|
+
# <!--
|
1514
|
+
# rdoc-file=file.c
|
1515
|
+
# - stat.atime -> time
|
1516
|
+
# -->
|
1517
|
+
# Returns the last access time for this file as an object of class Time.
|
1518
|
+
#
|
1519
|
+
# File.stat("testfile").atime #=> Wed Dec 31 18:00:00 CST 1969
|
1520
|
+
#
|
991
1521
|
def atime: () -> Time
|
992
1522
|
|
1523
|
+
# <!--
|
1524
|
+
# rdoc-file=file.c
|
1525
|
+
# - stat.birthtime -> aTime
|
1526
|
+
# -->
|
1527
|
+
# Returns the birth time for *stat*.
|
1528
|
+
#
|
1529
|
+
# If the platform doesn't have birthtime, raises NotImplementedError.
|
1530
|
+
#
|
1531
|
+
# File.write("testfile", "foo")
|
1532
|
+
# sleep 10
|
1533
|
+
# File.write("testfile", "bar")
|
1534
|
+
# sleep 10
|
1535
|
+
# File.chmod(0644, "testfile")
|
1536
|
+
# sleep 10
|
1537
|
+
# File.read("testfile")
|
1538
|
+
# File.stat("testfile").birthtime #=> 2014-02-24 11:19:17 +0900
|
1539
|
+
# File.stat("testfile").mtime #=> 2014-02-24 11:19:27 +0900
|
1540
|
+
# File.stat("testfile").ctime #=> 2014-02-24 11:19:37 +0900
|
1541
|
+
# File.stat("testfile").atime #=> 2014-02-24 11:19:47 +0900
|
1542
|
+
#
|
993
1543
|
def birthtime: () -> Time
|
994
1544
|
|
1545
|
+
# <!--
|
1546
|
+
# rdoc-file=file.c
|
1547
|
+
# - stat.blksize -> integer or nil
|
1548
|
+
# -->
|
1549
|
+
# Returns the native file system's block size. Will return `nil` on platforms
|
1550
|
+
# that don't support this information.
|
1551
|
+
#
|
1552
|
+
# File.stat("testfile").blksize #=> 4096
|
1553
|
+
#
|
995
1554
|
def blksize: () -> Integer?
|
996
1555
|
|
1556
|
+
# <!--
|
1557
|
+
# rdoc-file=file.c
|
1558
|
+
# - stat.blockdev? -> true or false
|
1559
|
+
# -->
|
1560
|
+
# Returns `true` if the file is a block device, `false` if it isn't or if the
|
1561
|
+
# operating system doesn't support this feature.
|
1562
|
+
#
|
1563
|
+
# File.stat("testfile").blockdev? #=> false
|
1564
|
+
# File.stat("/dev/hda1").blockdev? #=> true
|
1565
|
+
#
|
997
1566
|
def blockdev?: () -> bool
|
998
1567
|
|
1568
|
+
# <!--
|
1569
|
+
# rdoc-file=file.c
|
1570
|
+
# - stat.blocks -> integer or nil
|
1571
|
+
# -->
|
1572
|
+
# Returns the number of native file system blocks allocated for this file, or
|
1573
|
+
# `nil` if the operating system doesn't support this feature.
|
1574
|
+
#
|
1575
|
+
# File.stat("testfile").blocks #=> 2
|
1576
|
+
#
|
999
1577
|
def blocks: () -> Integer?
|
1000
1578
|
|
1579
|
+
# <!--
|
1580
|
+
# rdoc-file=file.c
|
1581
|
+
# - stat.chardev? -> true or false
|
1582
|
+
# -->
|
1583
|
+
# Returns `true` if the file is a character device, `false` if it isn't or if
|
1584
|
+
# the operating system doesn't support this feature.
|
1585
|
+
#
|
1586
|
+
# File.stat("/dev/tty").chardev? #=> true
|
1587
|
+
#
|
1001
1588
|
def chardev?: () -> bool
|
1002
1589
|
|
1590
|
+
# <!--
|
1591
|
+
# rdoc-file=file.c
|
1592
|
+
# - stat.ctime -> aTime
|
1593
|
+
# -->
|
1594
|
+
# Returns the change time for *stat* (that is, the time directory information
|
1595
|
+
# about the file was changed, not the file itself).
|
1596
|
+
#
|
1597
|
+
# Note that on Windows (NTFS), returns creation time (birth time).
|
1598
|
+
#
|
1599
|
+
# File.stat("testfile").ctime #=> Wed Apr 09 08:53:14 CDT 2003
|
1600
|
+
#
|
1003
1601
|
def ctime: () -> Time
|
1004
1602
|
|
1603
|
+
# <!--
|
1604
|
+
# rdoc-file=file.c
|
1605
|
+
# - stat.dev -> integer
|
1606
|
+
# -->
|
1607
|
+
# Returns an integer representing the device on which *stat* resides.
|
1608
|
+
#
|
1609
|
+
# File.stat("testfile").dev #=> 774
|
1610
|
+
#
|
1005
1611
|
def dev: () -> Integer
|
1006
1612
|
|
1613
|
+
# <!--
|
1614
|
+
# rdoc-file=file.c
|
1615
|
+
# - stat.dev_major -> integer
|
1616
|
+
# -->
|
1617
|
+
# Returns the major part of `File_Stat#dev` or `nil`.
|
1618
|
+
#
|
1619
|
+
# File.stat("/dev/fd1").dev_major #=> 2
|
1620
|
+
# File.stat("/dev/tty").dev_major #=> 5
|
1621
|
+
#
|
1007
1622
|
def dev_major: () -> Integer
|
1008
1623
|
|
1624
|
+
# <!--
|
1625
|
+
# rdoc-file=file.c
|
1626
|
+
# - stat.dev_minor -> integer
|
1627
|
+
# -->
|
1628
|
+
# Returns the minor part of `File_Stat#dev` or `nil`.
|
1629
|
+
#
|
1630
|
+
# File.stat("/dev/fd1").dev_minor #=> 1
|
1631
|
+
# File.stat("/dev/tty").dev_minor #=> 0
|
1632
|
+
#
|
1009
1633
|
def dev_minor: () -> Integer
|
1010
1634
|
|
1635
|
+
# <!--
|
1636
|
+
# rdoc-file=file.c
|
1637
|
+
# - File.directory?(file_name) -> true or false
|
1638
|
+
# -->
|
1639
|
+
# Returns `true` if the named file is a directory, or a symlink that points at a
|
1640
|
+
# directory, and `false` otherwise.
|
1641
|
+
#
|
1642
|
+
# *file_name* can be an IO object.
|
1643
|
+
#
|
1644
|
+
# File.directory?(".")
|
1645
|
+
#
|
1011
1646
|
def directory?: () -> bool
|
1012
1647
|
|
1648
|
+
# <!--
|
1649
|
+
# rdoc-file=file.c
|
1650
|
+
# - stat.executable? -> true or false
|
1651
|
+
# -->
|
1652
|
+
# Returns `true` if *stat* is executable or if the operating system doesn't
|
1653
|
+
# distinguish executable files from nonexecutable files. The tests are made
|
1654
|
+
# using the effective owner of the process.
|
1655
|
+
#
|
1656
|
+
# File.stat("testfile").executable? #=> false
|
1657
|
+
#
|
1013
1658
|
def executable?: () -> bool
|
1014
1659
|
|
1660
|
+
# <!--
|
1661
|
+
# rdoc-file=file.c
|
1662
|
+
# - stat.executable_real? -> true or false
|
1663
|
+
# -->
|
1664
|
+
# Same as `executable?`, but tests using the real owner of the process.
|
1665
|
+
#
|
1015
1666
|
def executable_real?: () -> bool
|
1016
1667
|
|
1668
|
+
# <!--
|
1669
|
+
# rdoc-file=file.c
|
1670
|
+
# - stat.file? -> true or false
|
1671
|
+
# -->
|
1672
|
+
# Returns `true` if *stat* is a regular file (not a device file, pipe, socket,
|
1673
|
+
# etc.).
|
1674
|
+
#
|
1675
|
+
# File.stat("testfile").file? #=> true
|
1676
|
+
#
|
1017
1677
|
def file?: () -> bool
|
1018
1678
|
|
1679
|
+
# <!--
|
1680
|
+
# rdoc-file=file.c
|
1681
|
+
# - stat.ftype -> string
|
1682
|
+
# -->
|
1683
|
+
# Identifies the type of *stat*. The return string is one of: ```file`'',
|
1684
|
+
# ```directory`'', ```characterSpecial`'', ```blockSpecial`'', ```fifo`'',
|
1685
|
+
# ```link`'', ```socket`'', or ```unknown`''.
|
1686
|
+
#
|
1687
|
+
# File.stat("/dev/tty").ftype #=> "characterSpecial"
|
1688
|
+
#
|
1019
1689
|
def ftype: () -> String
|
1020
1690
|
|
1691
|
+
# <!--
|
1692
|
+
# rdoc-file=file.c
|
1693
|
+
# - stat.gid -> integer
|
1694
|
+
# -->
|
1695
|
+
# Returns the numeric group id of the owner of *stat*.
|
1696
|
+
#
|
1697
|
+
# File.stat("testfile").gid #=> 500
|
1698
|
+
#
|
1021
1699
|
def gid: () -> Integer
|
1022
1700
|
|
1701
|
+
# <!--
|
1702
|
+
# rdoc-file=file.c
|
1703
|
+
# - stat.grpowned? -> true or false
|
1704
|
+
# -->
|
1705
|
+
# Returns true if the effective group id of the process is the same as the group
|
1706
|
+
# id of *stat*. On Windows NT, returns `false`.
|
1707
|
+
#
|
1708
|
+
# File.stat("testfile").grpowned? #=> true
|
1709
|
+
# File.stat("/etc/passwd").grpowned? #=> false
|
1710
|
+
#
|
1023
1711
|
def grpowned?: () -> bool
|
1024
1712
|
|
1713
|
+
# <!--
|
1714
|
+
# rdoc-file=file.c
|
1715
|
+
# - stat.ino -> integer
|
1716
|
+
# -->
|
1717
|
+
# Returns the inode number for *stat*.
|
1718
|
+
#
|
1719
|
+
# File.stat("testfile").ino #=> 1083669
|
1720
|
+
#
|
1025
1721
|
def ino: () -> Integer
|
1026
1722
|
|
1723
|
+
# <!--
|
1724
|
+
# rdoc-file=file.c
|
1725
|
+
# - stat.inspect -> string
|
1726
|
+
# -->
|
1727
|
+
# Produce a nicely formatted description of *stat*.
|
1728
|
+
#
|
1729
|
+
# File.stat("/etc/passwd").inspect
|
1730
|
+
# #=> "#<File::Stat dev=0xe000005, ino=1078078, mode=0100644,
|
1731
|
+
# # nlink=1, uid=0, gid=0, rdev=0x0, size=1374, blksize=4096,
|
1732
|
+
# # blocks=8, atime=Wed Dec 10 10:16:12 CST 2003,
|
1733
|
+
# # mtime=Fri Sep 12 15:41:41 CDT 2003,
|
1734
|
+
# # ctime=Mon Oct 27 11:20:27 CST 2003,
|
1735
|
+
# # birthtime=Mon Aug 04 08:13:49 CDT 2003>"
|
1736
|
+
#
|
1027
1737
|
def inspect: () -> String
|
1028
1738
|
|
1739
|
+
# <!--
|
1740
|
+
# rdoc-file=file.c
|
1741
|
+
# - stat.mode -> integer
|
1742
|
+
# -->
|
1743
|
+
# Returns an integer representing the permission bits of *stat*. The meaning of
|
1744
|
+
# the bits is platform dependent; on Unix systems, see `stat(2)`.
|
1745
|
+
#
|
1746
|
+
# File.chmod(0644, "testfile") #=> 1
|
1747
|
+
# s = File.stat("testfile")
|
1748
|
+
# sprintf("%o", s.mode) #=> "100644"
|
1749
|
+
#
|
1029
1750
|
def mode: () -> Integer
|
1030
1751
|
|
1752
|
+
# <!--
|
1753
|
+
# rdoc-file=file.c
|
1754
|
+
# - stat.mtime -> aTime
|
1755
|
+
# -->
|
1756
|
+
# Returns the modification time of *stat*.
|
1757
|
+
#
|
1758
|
+
# File.stat("testfile").mtime #=> Wed Apr 09 08:53:14 CDT 2003
|
1759
|
+
#
|
1031
1760
|
def mtime: () -> Time
|
1032
1761
|
|
1762
|
+
# <!--
|
1763
|
+
# rdoc-file=file.c
|
1764
|
+
# - stat.nlink -> integer
|
1765
|
+
# -->
|
1766
|
+
# Returns the number of hard links to *stat*.
|
1767
|
+
#
|
1768
|
+
# File.stat("testfile").nlink #=> 1
|
1769
|
+
# File.link("testfile", "testfile.bak") #=> 0
|
1770
|
+
# File.stat("testfile").nlink #=> 2
|
1771
|
+
#
|
1033
1772
|
def nlink: () -> Integer
|
1034
1773
|
|
1774
|
+
# <!--
|
1775
|
+
# rdoc-file=file.c
|
1776
|
+
# - stat.owned? -> true or false
|
1777
|
+
# -->
|
1778
|
+
# Returns `true` if the effective user id of the process is the same as the
|
1779
|
+
# owner of *stat*.
|
1780
|
+
#
|
1781
|
+
# File.stat("testfile").owned? #=> true
|
1782
|
+
# File.stat("/etc/passwd").owned? #=> false
|
1783
|
+
#
|
1035
1784
|
def owned?: () -> bool
|
1036
1785
|
|
1786
|
+
# <!--
|
1787
|
+
# rdoc-file=file.c
|
1788
|
+
# - stat.pipe? -> true or false
|
1789
|
+
# -->
|
1790
|
+
# Returns `true` if the operating system supports pipes and *stat* is a pipe;
|
1791
|
+
# `false` otherwise.
|
1792
|
+
#
|
1037
1793
|
def pipe?: () -> bool
|
1038
1794
|
|
1795
|
+
# <!--
|
1796
|
+
# rdoc-file=file.c
|
1797
|
+
# - stat.rdev -> integer or nil
|
1798
|
+
# -->
|
1799
|
+
# Returns an integer representing the device type on which *stat* resides.
|
1800
|
+
# Returns `nil` if the operating system doesn't support this feature.
|
1801
|
+
#
|
1802
|
+
# File.stat("/dev/fd1").rdev #=> 513
|
1803
|
+
# File.stat("/dev/tty").rdev #=> 1280
|
1804
|
+
#
|
1039
1805
|
def rdev: () -> Integer?
|
1040
1806
|
|
1807
|
+
# <!--
|
1808
|
+
# rdoc-file=file.c
|
1809
|
+
# - stat.rdev_major -> integer
|
1810
|
+
# -->
|
1811
|
+
# Returns the major part of `File_Stat#rdev` or `nil`.
|
1812
|
+
#
|
1813
|
+
# File.stat("/dev/fd1").rdev_major #=> 2
|
1814
|
+
# File.stat("/dev/tty").rdev_major #=> 5
|
1815
|
+
#
|
1041
1816
|
def rdev_major: () -> Integer
|
1042
1817
|
|
1818
|
+
# <!--
|
1819
|
+
# rdoc-file=file.c
|
1820
|
+
# - stat.rdev_minor -> integer
|
1821
|
+
# -->
|
1822
|
+
# Returns the minor part of `File_Stat#rdev` or `nil`.
|
1823
|
+
#
|
1824
|
+
# File.stat("/dev/fd1").rdev_minor #=> 1
|
1825
|
+
# File.stat("/dev/tty").rdev_minor #=> 0
|
1826
|
+
#
|
1043
1827
|
def rdev_minor: () -> Integer
|
1044
1828
|
|
1045
1829
|
def read: (?int? length, ?string outbuf) -> String?
|
1046
1830
|
|
1831
|
+
# <!--
|
1832
|
+
# rdoc-file=file.c
|
1833
|
+
# - stat.readable? -> true or false
|
1834
|
+
# -->
|
1835
|
+
# Returns `true` if *stat* is readable by the effective user id of this process.
|
1836
|
+
#
|
1837
|
+
# File.stat("testfile").readable? #=> true
|
1838
|
+
#
|
1047
1839
|
def readable?: () -> bool
|
1048
1840
|
|
1841
|
+
# <!--
|
1842
|
+
# rdoc-file=file.c
|
1843
|
+
# - stat.readable_real? -> true or false
|
1844
|
+
# -->
|
1845
|
+
# Returns `true` if *stat* is readable by the real user id of this process.
|
1846
|
+
#
|
1847
|
+
# File.stat("testfile").readable_real? #=> true
|
1848
|
+
#
|
1049
1849
|
def readable_real?: () -> bool
|
1050
1850
|
|
1851
|
+
# <!--
|
1852
|
+
# rdoc-file=file.c
|
1853
|
+
# - stat.setgid? -> true or false
|
1854
|
+
# -->
|
1855
|
+
# Returns `true` if *stat* has the set-group-id permission bit set, `false` if
|
1856
|
+
# it doesn't or if the operating system doesn't support this feature.
|
1857
|
+
#
|
1858
|
+
# File.stat("/usr/sbin/lpc").setgid? #=> true
|
1859
|
+
#
|
1051
1860
|
def setgid?: () -> bool
|
1052
1861
|
|
1862
|
+
# <!--
|
1863
|
+
# rdoc-file=file.c
|
1864
|
+
# - stat.setuid? -> true or false
|
1865
|
+
# -->
|
1866
|
+
# Returns `true` if *stat* has the set-user-id permission bit set, `false` if it
|
1867
|
+
# doesn't or if the operating system doesn't support this feature.
|
1868
|
+
#
|
1869
|
+
# File.stat("/bin/su").setuid? #=> true
|
1870
|
+
#
|
1053
1871
|
def setuid?: () -> bool
|
1054
1872
|
|
1873
|
+
# <!--
|
1874
|
+
# rdoc-file=file.c
|
1875
|
+
# - stat.size -> integer
|
1876
|
+
# -->
|
1877
|
+
# Returns the size of *stat* in bytes.
|
1878
|
+
#
|
1879
|
+
# File.stat("testfile").size #=> 66
|
1880
|
+
#
|
1055
1881
|
def size: () -> Integer
|
1056
1882
|
|
1883
|
+
# <!--
|
1884
|
+
# rdoc-file=file.c
|
1885
|
+
# - stat.size? -> Integer or nil
|
1886
|
+
# -->
|
1887
|
+
# Returns `nil` if *stat* is a zero-length file, the size of the file otherwise.
|
1888
|
+
#
|
1889
|
+
# File.stat("testfile").size? #=> 66
|
1890
|
+
# File.stat("/dev/null").size? #=> nil
|
1891
|
+
#
|
1057
1892
|
def size?: () -> Integer?
|
1058
1893
|
|
1894
|
+
# <!--
|
1895
|
+
# rdoc-file=file.c
|
1896
|
+
# - stat.socket? -> true or false
|
1897
|
+
# -->
|
1898
|
+
# Returns `true` if *stat* is a socket, `false` if it isn't or if the operating
|
1899
|
+
# system doesn't support this feature.
|
1900
|
+
#
|
1901
|
+
# File.stat("testfile").socket? #=> false
|
1902
|
+
#
|
1059
1903
|
def socket?: () -> bool
|
1060
1904
|
|
1905
|
+
# <!--
|
1906
|
+
# rdoc-file=file.c
|
1907
|
+
# - stat.sticky? -> true or false
|
1908
|
+
# -->
|
1909
|
+
# Returns `true` if *stat* has its sticky bit set, `false` if it doesn't or if
|
1910
|
+
# the operating system doesn't support this feature.
|
1911
|
+
#
|
1912
|
+
# File.stat("testfile").sticky? #=> false
|
1913
|
+
#
|
1061
1914
|
def sticky?: () -> bool
|
1062
1915
|
|
1916
|
+
# <!--
|
1917
|
+
# rdoc-file=file.c
|
1918
|
+
# - stat.symlink? -> true or false
|
1919
|
+
# -->
|
1920
|
+
# Returns `true` if *stat* is a symbolic link, `false` if it isn't or if the
|
1921
|
+
# operating system doesn't support this feature. As File::stat automatically
|
1922
|
+
# follows symbolic links, #symlink? will always be `false` for an object
|
1923
|
+
# returned by File::stat.
|
1924
|
+
#
|
1925
|
+
# File.symlink("testfile", "alink") #=> 0
|
1926
|
+
# File.stat("alink").symlink? #=> false
|
1927
|
+
# File.lstat("alink").symlink? #=> true
|
1928
|
+
#
|
1063
1929
|
def symlink?: () -> bool
|
1064
1930
|
|
1931
|
+
# <!--
|
1932
|
+
# rdoc-file=file.c
|
1933
|
+
# - stat.uid -> integer
|
1934
|
+
# -->
|
1935
|
+
# Returns the numeric user id of the owner of *stat*.
|
1936
|
+
#
|
1937
|
+
# File.stat("testfile").uid #=> 501
|
1938
|
+
#
|
1065
1939
|
def uid: () -> Integer
|
1066
1940
|
|
1941
|
+
# <!--
|
1942
|
+
# rdoc-file=file.c
|
1943
|
+
# - stat.world_readable? -> integer or nil
|
1944
|
+
# -->
|
1945
|
+
# If *stat* is readable by others, returns an integer representing the file
|
1946
|
+
# permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
|
1947
|
+
# platform dependent; on Unix systems, see `stat(2)`.
|
1948
|
+
#
|
1949
|
+
# m = File.stat("/etc/passwd").world_readable? #=> 420
|
1950
|
+
# sprintf("%o", m) #=> "644"
|
1951
|
+
#
|
1067
1952
|
def world_readable?: () -> Integer?
|
1068
1953
|
|
1954
|
+
# <!--
|
1955
|
+
# rdoc-file=file.c
|
1956
|
+
# - stat.world_writable? -> integer or nil
|
1957
|
+
# -->
|
1958
|
+
# If *stat* is writable by others, returns an integer representing the file
|
1959
|
+
# permission bits of *stat*. Returns `nil` otherwise. The meaning of the bits is
|
1960
|
+
# platform dependent; on Unix systems, see `stat(2)`.
|
1961
|
+
#
|
1962
|
+
# m = File.stat("/tmp").world_writable? #=> 511
|
1963
|
+
# sprintf("%o", m) #=> "777"
|
1964
|
+
#
|
1069
1965
|
def world_writable?: () -> Integer?
|
1070
1966
|
|
1967
|
+
# <!--
|
1968
|
+
# rdoc-file=file.c
|
1969
|
+
# - stat.writable? -> true or false
|
1970
|
+
# -->
|
1971
|
+
# Returns `true` if *stat* is writable by the effective user id of this process.
|
1972
|
+
#
|
1973
|
+
# File.stat("testfile").writable? #=> true
|
1974
|
+
#
|
1071
1975
|
def writable?: () -> bool
|
1072
1976
|
|
1977
|
+
# <!--
|
1978
|
+
# rdoc-file=file.c
|
1979
|
+
# - stat.writable_real? -> true or false
|
1980
|
+
# -->
|
1981
|
+
# Returns `true` if *stat* is writable by the real user id of this process.
|
1982
|
+
#
|
1983
|
+
# File.stat("testfile").writable_real? #=> true
|
1984
|
+
#
|
1073
1985
|
def writable_real?: () -> bool
|
1074
1986
|
|
1987
|
+
# <!--
|
1988
|
+
# rdoc-file=file.c
|
1989
|
+
# - stat.zero? -> true or false
|
1990
|
+
# -->
|
1991
|
+
# Returns `true` if *stat* is a zero-length file; `false` otherwise.
|
1992
|
+
#
|
1993
|
+
# File.stat("testfile").zero? #=> false
|
1994
|
+
#
|
1075
1995
|
def zero?: () -> bool
|
1076
1996
|
end
|