Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby32/share/ruby
File: pathname.rb
# frozen_string_literal: true
[0] Fix | Delete
#
[1] Fix | Delete
# = pathname.rb
[2] Fix | Delete
#
[3] Fix | Delete
# Object-Oriented Pathname Class
[4] Fix | Delete
#
[5] Fix | Delete
# Author:: Tanaka Akira <akr@m17n.org>
[6] Fix | Delete
# Documentation:: Author and Gavin Sinclair
[7] Fix | Delete
#
[8] Fix | Delete
# For documentation, see class Pathname.
[9] Fix | Delete
#
[10] Fix | Delete
[11] Fix | Delete
require 'pathname.so'
[12] Fix | Delete
[13] Fix | Delete
class Pathname
[14] Fix | Delete
[15] Fix | Delete
# :stopdoc:
[16] Fix | Delete
[17] Fix | Delete
# to_path is implemented so Pathname objects are usable with File.open, etc.
[18] Fix | Delete
TO_PATH = :to_path
[19] Fix | Delete
[20] Fix | Delete
SAME_PATHS = if File::FNM_SYSCASE.nonzero?
[21] Fix | Delete
# Avoid #zero? here because #casecmp can return nil.
[22] Fix | Delete
proc {|a, b| a.casecmp(b) == 0}
[23] Fix | Delete
else
[24] Fix | Delete
proc {|a, b| a == b}
[25] Fix | Delete
end
[26] Fix | Delete
[27] Fix | Delete
[28] Fix | Delete
if File::ALT_SEPARATOR
[29] Fix | Delete
SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}#{Regexp.quote File::SEPARATOR}"
[30] Fix | Delete
SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/
[31] Fix | Delete
else
[32] Fix | Delete
SEPARATOR_LIST = "#{Regexp.quote File::SEPARATOR}"
[33] Fix | Delete
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/
[34] Fix | Delete
end
[35] Fix | Delete
[36] Fix | Delete
if File.dirname('A:') == 'A:.' # DOSish drive letter
[37] Fix | Delete
ABSOLUTE_PATH = /\A(?:[A-Za-z]:|#{SEPARATOR_PAT})/o
[38] Fix | Delete
else
[39] Fix | Delete
ABSOLUTE_PATH = /\A#{SEPARATOR_PAT}/o
[40] Fix | Delete
end
[41] Fix | Delete
private_constant :ABSOLUTE_PATH
[42] Fix | Delete
[43] Fix | Delete
# :startdoc:
[44] Fix | Delete
[45] Fix | Delete
# chop_basename(path) -> [pre-basename, basename] or nil
[46] Fix | Delete
def chop_basename(path) # :nodoc:
[47] Fix | Delete
base = File.basename(path)
[48] Fix | Delete
if /\A#{SEPARATOR_PAT}?\z/o.match?(base)
[49] Fix | Delete
return nil
[50] Fix | Delete
else
[51] Fix | Delete
return path[0, path.rindex(base)], base
[52] Fix | Delete
end
[53] Fix | Delete
end
[54] Fix | Delete
private :chop_basename
[55] Fix | Delete
[56] Fix | Delete
# split_names(path) -> prefix, [name, ...]
[57] Fix | Delete
def split_names(path) # :nodoc:
[58] Fix | Delete
names = []
[59] Fix | Delete
while r = chop_basename(path)
[60] Fix | Delete
path, basename = r
[61] Fix | Delete
names.unshift basename
[62] Fix | Delete
end
[63] Fix | Delete
return path, names
[64] Fix | Delete
end
[65] Fix | Delete
private :split_names
[66] Fix | Delete
[67] Fix | Delete
def prepend_prefix(prefix, relpath) # :nodoc:
[68] Fix | Delete
if relpath.empty?
[69] Fix | Delete
File.dirname(prefix)
[70] Fix | Delete
elsif /#{SEPARATOR_PAT}/o.match?(prefix)
[71] Fix | Delete
prefix = File.dirname(prefix)
[72] Fix | Delete
prefix = File.join(prefix, "") if File.basename(prefix + 'a') != 'a'
[73] Fix | Delete
prefix + relpath
[74] Fix | Delete
else
[75] Fix | Delete
prefix + relpath
[76] Fix | Delete
end
[77] Fix | Delete
end
[78] Fix | Delete
private :prepend_prefix
[79] Fix | Delete
[80] Fix | Delete
# Returns clean pathname of +self+ with consecutive slashes and useless dots
[81] Fix | Delete
# removed. The filesystem is not accessed.
[82] Fix | Delete
#
[83] Fix | Delete
# If +consider_symlink+ is +true+, then a more conservative algorithm is used
[84] Fix | Delete
# to avoid breaking symbolic linkages. This may retain more +..+
[85] Fix | Delete
# entries than absolutely necessary, but without accessing the filesystem,
[86] Fix | Delete
# this can't be avoided.
[87] Fix | Delete
#
[88] Fix | Delete
# See Pathname#realpath.
[89] Fix | Delete
#
[90] Fix | Delete
def cleanpath(consider_symlink=false)
[91] Fix | Delete
if consider_symlink
[92] Fix | Delete
cleanpath_conservative
[93] Fix | Delete
else
[94] Fix | Delete
cleanpath_aggressive
[95] Fix | Delete
end
[96] Fix | Delete
end
[97] Fix | Delete
[98] Fix | Delete
#
[99] Fix | Delete
# Clean the path simply by resolving and removing excess +.+ and +..+ entries.
[100] Fix | Delete
# Nothing more, nothing less.
[101] Fix | Delete
#
[102] Fix | Delete
def cleanpath_aggressive # :nodoc:
[103] Fix | Delete
path = @path
[104] Fix | Delete
names = []
[105] Fix | Delete
pre = path
[106] Fix | Delete
while r = chop_basename(pre)
[107] Fix | Delete
pre, base = r
[108] Fix | Delete
case base
[109] Fix | Delete
when '.'
[110] Fix | Delete
when '..'
[111] Fix | Delete
names.unshift base
[112] Fix | Delete
else
[113] Fix | Delete
if names[0] == '..'
[114] Fix | Delete
names.shift
[115] Fix | Delete
else
[116] Fix | Delete
names.unshift base
[117] Fix | Delete
end
[118] Fix | Delete
end
[119] Fix | Delete
end
[120] Fix | Delete
pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
[121] Fix | Delete
if /#{SEPARATOR_PAT}/o.match?(File.basename(pre))
[122] Fix | Delete
names.shift while names[0] == '..'
[123] Fix | Delete
end
[124] Fix | Delete
self.class.new(prepend_prefix(pre, File.join(*names)))
[125] Fix | Delete
end
[126] Fix | Delete
private :cleanpath_aggressive
[127] Fix | Delete
[128] Fix | Delete
# has_trailing_separator?(path) -> bool
[129] Fix | Delete
def has_trailing_separator?(path) # :nodoc:
[130] Fix | Delete
if r = chop_basename(path)
[131] Fix | Delete
pre, basename = r
[132] Fix | Delete
pre.length + basename.length < path.length
[133] Fix | Delete
else
[134] Fix | Delete
false
[135] Fix | Delete
end
[136] Fix | Delete
end
[137] Fix | Delete
private :has_trailing_separator?
[138] Fix | Delete
[139] Fix | Delete
# add_trailing_separator(path) -> path
[140] Fix | Delete
def add_trailing_separator(path) # :nodoc:
[141] Fix | Delete
if File.basename(path + 'a') == 'a'
[142] Fix | Delete
path
[143] Fix | Delete
else
[144] Fix | Delete
File.join(path, "") # xxx: Is File.join is appropriate to add separator?
[145] Fix | Delete
end
[146] Fix | Delete
end
[147] Fix | Delete
private :add_trailing_separator
[148] Fix | Delete
[149] Fix | Delete
def del_trailing_separator(path) # :nodoc:
[150] Fix | Delete
if r = chop_basename(path)
[151] Fix | Delete
pre, basename = r
[152] Fix | Delete
pre + basename
[153] Fix | Delete
elsif /#{SEPARATOR_PAT}+\z/o =~ path
[154] Fix | Delete
$` + File.dirname(path)[/#{SEPARATOR_PAT}*\z/o]
[155] Fix | Delete
else
[156] Fix | Delete
path
[157] Fix | Delete
end
[158] Fix | Delete
end
[159] Fix | Delete
private :del_trailing_separator
[160] Fix | Delete
[161] Fix | Delete
def cleanpath_conservative # :nodoc:
[162] Fix | Delete
path = @path
[163] Fix | Delete
names = []
[164] Fix | Delete
pre = path
[165] Fix | Delete
while r = chop_basename(pre)
[166] Fix | Delete
pre, base = r
[167] Fix | Delete
names.unshift base if base != '.'
[168] Fix | Delete
end
[169] Fix | Delete
pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
[170] Fix | Delete
if /#{SEPARATOR_PAT}/o.match?(File.basename(pre))
[171] Fix | Delete
names.shift while names[0] == '..'
[172] Fix | Delete
end
[173] Fix | Delete
if names.empty?
[174] Fix | Delete
self.class.new(File.dirname(pre))
[175] Fix | Delete
else
[176] Fix | Delete
if names.last != '..' && File.basename(path) == '.'
[177] Fix | Delete
names << '.'
[178] Fix | Delete
end
[179] Fix | Delete
result = prepend_prefix(pre, File.join(*names))
[180] Fix | Delete
if /\A(?:\.|\.\.)\z/ !~ names.last && has_trailing_separator?(path)
[181] Fix | Delete
self.class.new(add_trailing_separator(result))
[182] Fix | Delete
else
[183] Fix | Delete
self.class.new(result)
[184] Fix | Delete
end
[185] Fix | Delete
end
[186] Fix | Delete
end
[187] Fix | Delete
private :cleanpath_conservative
[188] Fix | Delete
[189] Fix | Delete
# Returns the parent directory.
[190] Fix | Delete
#
[191] Fix | Delete
# This is same as <code>self + '..'</code>.
[192] Fix | Delete
def parent
[193] Fix | Delete
self + '..'
[194] Fix | Delete
end
[195] Fix | Delete
[196] Fix | Delete
# Returns +true+ if +self+ points to a mountpoint.
[197] Fix | Delete
def mountpoint?
[198] Fix | Delete
begin
[199] Fix | Delete
stat1 = self.lstat
[200] Fix | Delete
stat2 = self.parent.lstat
[201] Fix | Delete
stat1.dev != stat2.dev || stat1.ino == stat2.ino
[202] Fix | Delete
rescue Errno::ENOENT
[203] Fix | Delete
false
[204] Fix | Delete
end
[205] Fix | Delete
end
[206] Fix | Delete
[207] Fix | Delete
#
[208] Fix | Delete
# Predicate method for root directories. Returns +true+ if the
[209] Fix | Delete
# pathname consists of consecutive slashes.
[210] Fix | Delete
#
[211] Fix | Delete
# It doesn't access the filesystem. So it may return +false+ for some
[212] Fix | Delete
# pathnames which points to roots such as <tt>/usr/..</tt>.
[213] Fix | Delete
#
[214] Fix | Delete
def root?
[215] Fix | Delete
chop_basename(@path) == nil && /#{SEPARATOR_PAT}/o.match?(@path)
[216] Fix | Delete
end
[217] Fix | Delete
[218] Fix | Delete
# Predicate method for testing whether a path is absolute.
[219] Fix | Delete
#
[220] Fix | Delete
# It returns +true+ if the pathname begins with a slash.
[221] Fix | Delete
#
[222] Fix | Delete
# p = Pathname.new('/im/sure')
[223] Fix | Delete
# p.absolute?
[224] Fix | Delete
# #=> true
[225] Fix | Delete
#
[226] Fix | Delete
# p = Pathname.new('not/so/sure')
[227] Fix | Delete
# p.absolute?
[228] Fix | Delete
# #=> false
[229] Fix | Delete
def absolute?
[230] Fix | Delete
ABSOLUTE_PATH.match? @path
[231] Fix | Delete
end
[232] Fix | Delete
[233] Fix | Delete
# The opposite of Pathname#absolute?
[234] Fix | Delete
#
[235] Fix | Delete
# It returns +false+ if the pathname begins with a slash.
[236] Fix | Delete
#
[237] Fix | Delete
# p = Pathname.new('/im/sure')
[238] Fix | Delete
# p.relative?
[239] Fix | Delete
# #=> false
[240] Fix | Delete
#
[241] Fix | Delete
# p = Pathname.new('not/so/sure')
[242] Fix | Delete
# p.relative?
[243] Fix | Delete
# #=> true
[244] Fix | Delete
def relative?
[245] Fix | Delete
!absolute?
[246] Fix | Delete
end
[247] Fix | Delete
[248] Fix | Delete
#
[249] Fix | Delete
# Iterates over each component of the path.
[250] Fix | Delete
#
[251] Fix | Delete
# Pathname.new("/usr/bin/ruby").each_filename {|filename| ... }
[252] Fix | Delete
# # yields "usr", "bin", and "ruby".
[253] Fix | Delete
#
[254] Fix | Delete
# Returns an Enumerator if no block was given.
[255] Fix | Delete
#
[256] Fix | Delete
# enum = Pathname.new("/usr/bin/ruby").each_filename
[257] Fix | Delete
# # ... do stuff ...
[258] Fix | Delete
# enum.each { |e| ... }
[259] Fix | Delete
# # yields "usr", "bin", and "ruby".
[260] Fix | Delete
#
[261] Fix | Delete
def each_filename # :yield: filename
[262] Fix | Delete
return to_enum(__method__) unless block_given?
[263] Fix | Delete
_, names = split_names(@path)
[264] Fix | Delete
names.each {|filename| yield filename }
[265] Fix | Delete
nil
[266] Fix | Delete
end
[267] Fix | Delete
[268] Fix | Delete
# Iterates over and yields a new Pathname object
[269] Fix | Delete
# for each element in the given path in descending order.
[270] Fix | Delete
#
[271] Fix | Delete
# Pathname.new('/path/to/some/file.rb').descend {|v| p v}
[272] Fix | Delete
# #<Pathname:/>
[273] Fix | Delete
# #<Pathname:/path>
[274] Fix | Delete
# #<Pathname:/path/to>
[275] Fix | Delete
# #<Pathname:/path/to/some>
[276] Fix | Delete
# #<Pathname:/path/to/some/file.rb>
[277] Fix | Delete
#
[278] Fix | Delete
# Pathname.new('path/to/some/file.rb').descend {|v| p v}
[279] Fix | Delete
# #<Pathname:path>
[280] Fix | Delete
# #<Pathname:path/to>
[281] Fix | Delete
# #<Pathname:path/to/some>
[282] Fix | Delete
# #<Pathname:path/to/some/file.rb>
[283] Fix | Delete
#
[284] Fix | Delete
# Returns an Enumerator if no block was given.
[285] Fix | Delete
#
[286] Fix | Delete
# enum = Pathname.new("/usr/bin/ruby").descend
[287] Fix | Delete
# # ... do stuff ...
[288] Fix | Delete
# enum.each { |e| ... }
[289] Fix | Delete
# # yields Pathnames /, /usr, /usr/bin, and /usr/bin/ruby.
[290] Fix | Delete
#
[291] Fix | Delete
# It doesn't access the filesystem.
[292] Fix | Delete
#
[293] Fix | Delete
def descend
[294] Fix | Delete
return to_enum(__method__) unless block_given?
[295] Fix | Delete
vs = []
[296] Fix | Delete
ascend {|v| vs << v }
[297] Fix | Delete
vs.reverse_each {|v| yield v }
[298] Fix | Delete
nil
[299] Fix | Delete
end
[300] Fix | Delete
[301] Fix | Delete
# Iterates over and yields a new Pathname object
[302] Fix | Delete
# for each element in the given path in ascending order.
[303] Fix | Delete
#
[304] Fix | Delete
# Pathname.new('/path/to/some/file.rb').ascend {|v| p v}
[305] Fix | Delete
# #<Pathname:/path/to/some/file.rb>
[306] Fix | Delete
# #<Pathname:/path/to/some>
[307] Fix | Delete
# #<Pathname:/path/to>
[308] Fix | Delete
# #<Pathname:/path>
[309] Fix | Delete
# #<Pathname:/>
[310] Fix | Delete
#
[311] Fix | Delete
# Pathname.new('path/to/some/file.rb').ascend {|v| p v}
[312] Fix | Delete
# #<Pathname:path/to/some/file.rb>
[313] Fix | Delete
# #<Pathname:path/to/some>
[314] Fix | Delete
# #<Pathname:path/to>
[315] Fix | Delete
# #<Pathname:path>
[316] Fix | Delete
#
[317] Fix | Delete
# Returns an Enumerator if no block was given.
[318] Fix | Delete
#
[319] Fix | Delete
# enum = Pathname.new("/usr/bin/ruby").ascend
[320] Fix | Delete
# # ... do stuff ...
[321] Fix | Delete
# enum.each { |e| ... }
[322] Fix | Delete
# # yields Pathnames /usr/bin/ruby, /usr/bin, /usr, and /.
[323] Fix | Delete
#
[324] Fix | Delete
# It doesn't access the filesystem.
[325] Fix | Delete
#
[326] Fix | Delete
def ascend
[327] Fix | Delete
return to_enum(__method__) unless block_given?
[328] Fix | Delete
path = @path
[329] Fix | Delete
yield self
[330] Fix | Delete
while r = chop_basename(path)
[331] Fix | Delete
path, = r
[332] Fix | Delete
break if path.empty?
[333] Fix | Delete
yield self.class.new(del_trailing_separator(path))
[334] Fix | Delete
end
[335] Fix | Delete
end
[336] Fix | Delete
[337] Fix | Delete
#
[338] Fix | Delete
# Appends a pathname fragment to +self+ to produce a new Pathname object.
[339] Fix | Delete
# Since +other+ is considered as a path relative to +self+, if +other+ is
[340] Fix | Delete
# an absolute path, the new Pathname object is created from just +other+.
[341] Fix | Delete
#
[342] Fix | Delete
# p1 = Pathname.new("/usr") # Pathname:/usr
[343] Fix | Delete
# p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
[344] Fix | Delete
# p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
[345] Fix | Delete
#
[346] Fix | Delete
# # / is aliased to +.
[347] Fix | Delete
# p4 = p1 / "bin/ruby" # Pathname:/usr/bin/ruby
[348] Fix | Delete
# p5 = p1 / "/etc/passwd" # Pathname:/etc/passwd
[349] Fix | Delete
#
[350] Fix | Delete
# This method doesn't access the file system; it is pure string manipulation.
[351] Fix | Delete
#
[352] Fix | Delete
def +(other)
[353] Fix | Delete
other = Pathname.new(other) unless Pathname === other
[354] Fix | Delete
Pathname.new(plus(@path, other.to_s))
[355] Fix | Delete
end
[356] Fix | Delete
alias / +
[357] Fix | Delete
[358] Fix | Delete
def plus(path1, path2) # -> path # :nodoc:
[359] Fix | Delete
prefix2 = path2
[360] Fix | Delete
index_list2 = []
[361] Fix | Delete
basename_list2 = []
[362] Fix | Delete
while r2 = chop_basename(prefix2)
[363] Fix | Delete
prefix2, basename2 = r2
[364] Fix | Delete
index_list2.unshift prefix2.length
[365] Fix | Delete
basename_list2.unshift basename2
[366] Fix | Delete
end
[367] Fix | Delete
return path2 if prefix2 != ''
[368] Fix | Delete
prefix1 = path1
[369] Fix | Delete
while true
[370] Fix | Delete
while !basename_list2.empty? && basename_list2.first == '.'
[371] Fix | Delete
index_list2.shift
[372] Fix | Delete
basename_list2.shift
[373] Fix | Delete
end
[374] Fix | Delete
break unless r1 = chop_basename(prefix1)
[375] Fix | Delete
prefix1, basename1 = r1
[376] Fix | Delete
next if basename1 == '.'
[377] Fix | Delete
if basename1 == '..' || basename_list2.empty? || basename_list2.first != '..'
[378] Fix | Delete
prefix1 = prefix1 + basename1
[379] Fix | Delete
break
[380] Fix | Delete
end
[381] Fix | Delete
index_list2.shift
[382] Fix | Delete
basename_list2.shift
[383] Fix | Delete
end
[384] Fix | Delete
r1 = chop_basename(prefix1)
[385] Fix | Delete
if !r1 && (r1 = /#{SEPARATOR_PAT}/o.match?(File.basename(prefix1)))
[386] Fix | Delete
while !basename_list2.empty? && basename_list2.first == '..'
[387] Fix | Delete
index_list2.shift
[388] Fix | Delete
basename_list2.shift
[389] Fix | Delete
end
[390] Fix | Delete
end
[391] Fix | Delete
if !basename_list2.empty?
[392] Fix | Delete
suffix2 = path2[index_list2.first..-1]
[393] Fix | Delete
r1 ? File.join(prefix1, suffix2) : prefix1 + suffix2
[394] Fix | Delete
else
[395] Fix | Delete
r1 ? prefix1 : File.dirname(prefix1)
[396] Fix | Delete
end
[397] Fix | Delete
end
[398] Fix | Delete
private :plus
[399] Fix | Delete
[400] Fix | Delete
#
[401] Fix | Delete
# Joins the given pathnames onto +self+ to create a new Pathname object.
[402] Fix | Delete
# This is effectively the same as using Pathname#+ to append +self+ and
[403] Fix | Delete
# all arguments sequentially.
[404] Fix | Delete
#
[405] Fix | Delete
# path0 = Pathname.new("/usr") # Pathname:/usr
[406] Fix | Delete
# path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
[407] Fix | Delete
# # is the same as
[408] Fix | Delete
# path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
[409] Fix | Delete
# path0 == path1
[410] Fix | Delete
# #=> true
[411] Fix | Delete
#
[412] Fix | Delete
def join(*args)
[413] Fix | Delete
return self if args.empty?
[414] Fix | Delete
result = args.pop
[415] Fix | Delete
result = Pathname.new(result) unless Pathname === result
[416] Fix | Delete
return result if result.absolute?
[417] Fix | Delete
args.reverse_each {|arg|
[418] Fix | Delete
arg = Pathname.new(arg) unless Pathname === arg
[419] Fix | Delete
result = arg + result
[420] Fix | Delete
return result if result.absolute?
[421] Fix | Delete
}
[422] Fix | Delete
self + result
[423] Fix | Delete
end
[424] Fix | Delete
[425] Fix | Delete
#
[426] Fix | Delete
# Returns the children of the directory (files and subdirectories, not
[427] Fix | Delete
# recursive) as an array of Pathname objects.
[428] Fix | Delete
#
[429] Fix | Delete
# By default, the returned pathnames will have enough information to access
[430] Fix | Delete
# the files. If you set +with_directory+ to +false+, then the returned
[431] Fix | Delete
# pathnames will contain the filename only.
[432] Fix | Delete
#
[433] Fix | Delete
# For example:
[434] Fix | Delete
# pn = Pathname("/usr/lib/ruby/1.8")
[435] Fix | Delete
# pn.children
[436] Fix | Delete
# # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
[437] Fix | Delete
# Pathname:/usr/lib/ruby/1.8/Env.rb,
[438] Fix | Delete
# Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
[439] Fix | Delete
# pn.children(false)
[440] Fix | Delete
# # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
[441] Fix | Delete
#
[442] Fix | Delete
# Note that the results never contain the entries +.+ and +..+ in
[443] Fix | Delete
# the directory because they are not children.
[444] Fix | Delete
#
[445] Fix | Delete
def children(with_directory=true)
[446] Fix | Delete
with_directory = false if @path == '.'
[447] Fix | Delete
result = []
[448] Fix | Delete
Dir.foreach(@path) {|e|
[449] Fix | Delete
next if e == '.' || e == '..'
[450] Fix | Delete
if with_directory
[451] Fix | Delete
result << self.class.new(File.join(@path, e))
[452] Fix | Delete
else
[453] Fix | Delete
result << self.class.new(e)
[454] Fix | Delete
end
[455] Fix | Delete
}
[456] Fix | Delete
result
[457] Fix | Delete
end
[458] Fix | Delete
[459] Fix | Delete
# Iterates over the children of the directory
[460] Fix | Delete
# (files and subdirectories, not recursive).
[461] Fix | Delete
#
[462] Fix | Delete
# It yields Pathname object for each child.
[463] Fix | Delete
#
[464] Fix | Delete
# By default, the yielded pathnames will have enough information to access
[465] Fix | Delete
# the files.
[466] Fix | Delete
#
[467] Fix | Delete
# If you set +with_directory+ to +false+, then the returned pathnames will
[468] Fix | Delete
# contain the filename only.
[469] Fix | Delete
#
[470] Fix | Delete
# Pathname("/usr/local").each_child {|f| p f }
[471] Fix | Delete
# #=> #<Pathname:/usr/local/share>
[472] Fix | Delete
# # #<Pathname:/usr/local/bin>
[473] Fix | Delete
# # #<Pathname:/usr/local/games>
[474] Fix | Delete
# # #<Pathname:/usr/local/lib>
[475] Fix | Delete
# # #<Pathname:/usr/local/include>
[476] Fix | Delete
# # #<Pathname:/usr/local/sbin>
[477] Fix | Delete
# # #<Pathname:/usr/local/src>
[478] Fix | Delete
# # #<Pathname:/usr/local/man>
[479] Fix | Delete
#
[480] Fix | Delete
# Pathname("/usr/local").each_child(false) {|f| p f }
[481] Fix | Delete
# #=> #<Pathname:share>
[482] Fix | Delete
# # #<Pathname:bin>
[483] Fix | Delete
# # #<Pathname:games>
[484] Fix | Delete
# # #<Pathname:lib>
[485] Fix | Delete
# # #<Pathname:include>
[486] Fix | Delete
# # #<Pathname:sbin>
[487] Fix | Delete
# # #<Pathname:src>
[488] Fix | Delete
# # #<Pathname:man>
[489] Fix | Delete
#
[490] Fix | Delete
# Note that the results never contain the entries +.+ and +..+ in
[491] Fix | Delete
# the directory because they are not children.
[492] Fix | Delete
#
[493] Fix | Delete
# See Pathname#children
[494] Fix | Delete
#
[495] Fix | Delete
def each_child(with_directory=true, &b)
[496] Fix | Delete
children(with_directory).each(&b)
[497] Fix | Delete
end
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function