Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby30/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
#
[340] Fix | Delete
# p1 = Pathname.new("/usr") # Pathname:/usr
[341] Fix | Delete
# p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
[342] Fix | Delete
# p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
[343] Fix | Delete
#
[344] Fix | Delete
# # / is aliased to +.
[345] Fix | Delete
# p4 = p1 / "bin/ruby" # Pathname:/usr/bin/ruby
[346] Fix | Delete
# p5 = p1 / "/etc/passwd" # Pathname:/etc/passwd
[347] Fix | Delete
#
[348] Fix | Delete
# This method doesn't access the file system; it is pure string manipulation.
[349] Fix | Delete
#
[350] Fix | Delete
def +(other)
[351] Fix | Delete
other = Pathname.new(other) unless Pathname === other
[352] Fix | Delete
Pathname.new(plus(@path, other.to_s))
[353] Fix | Delete
end
[354] Fix | Delete
alias / +
[355] Fix | Delete
[356] Fix | Delete
def plus(path1, path2) # -> path # :nodoc:
[357] Fix | Delete
prefix2 = path2
[358] Fix | Delete
index_list2 = []
[359] Fix | Delete
basename_list2 = []
[360] Fix | Delete
while r2 = chop_basename(prefix2)
[361] Fix | Delete
prefix2, basename2 = r2
[362] Fix | Delete
index_list2.unshift prefix2.length
[363] Fix | Delete
basename_list2.unshift basename2
[364] Fix | Delete
end
[365] Fix | Delete
return path2 if prefix2 != ''
[366] Fix | Delete
prefix1 = path1
[367] Fix | Delete
while true
[368] Fix | Delete
while !basename_list2.empty? && basename_list2.first == '.'
[369] Fix | Delete
index_list2.shift
[370] Fix | Delete
basename_list2.shift
[371] Fix | Delete
end
[372] Fix | Delete
break unless r1 = chop_basename(prefix1)
[373] Fix | Delete
prefix1, basename1 = r1
[374] Fix | Delete
next if basename1 == '.'
[375] Fix | Delete
if basename1 == '..' || basename_list2.empty? || basename_list2.first != '..'
[376] Fix | Delete
prefix1 = prefix1 + basename1
[377] Fix | Delete
break
[378] Fix | Delete
end
[379] Fix | Delete
index_list2.shift
[380] Fix | Delete
basename_list2.shift
[381] Fix | Delete
end
[382] Fix | Delete
r1 = chop_basename(prefix1)
[383] Fix | Delete
if !r1 && (r1 = /#{SEPARATOR_PAT}/o.match?(File.basename(prefix1)))
[384] Fix | Delete
while !basename_list2.empty? && basename_list2.first == '..'
[385] Fix | Delete
index_list2.shift
[386] Fix | Delete
basename_list2.shift
[387] Fix | Delete
end
[388] Fix | Delete
end
[389] Fix | Delete
if !basename_list2.empty?
[390] Fix | Delete
suffix2 = path2[index_list2.first..-1]
[391] Fix | Delete
r1 ? File.join(prefix1, suffix2) : prefix1 + suffix2
[392] Fix | Delete
else
[393] Fix | Delete
r1 ? prefix1 : File.dirname(prefix1)
[394] Fix | Delete
end
[395] Fix | Delete
end
[396] Fix | Delete
private :plus
[397] Fix | Delete
[398] Fix | Delete
#
[399] Fix | Delete
# Joins the given pathnames onto +self+ to create a new Pathname object.
[400] Fix | Delete
#
[401] Fix | Delete
# path0 = Pathname.new("/usr") # Pathname:/usr
[402] Fix | Delete
# path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
[403] Fix | Delete
# # is the same as
[404] Fix | Delete
# path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
[405] Fix | Delete
# path0 == path1
[406] Fix | Delete
# #=> true
[407] Fix | Delete
#
[408] Fix | Delete
def join(*args)
[409] Fix | Delete
return self if args.empty?
[410] Fix | Delete
result = args.pop
[411] Fix | Delete
result = Pathname.new(result) unless Pathname === result
[412] Fix | Delete
return result if result.absolute?
[413] Fix | Delete
args.reverse_each {|arg|
[414] Fix | Delete
arg = Pathname.new(arg) unless Pathname === arg
[415] Fix | Delete
result = arg + result
[416] Fix | Delete
return result if result.absolute?
[417] Fix | Delete
}
[418] Fix | Delete
self + result
[419] Fix | Delete
end
[420] Fix | Delete
[421] Fix | Delete
#
[422] Fix | Delete
# Returns the children of the directory (files and subdirectories, not
[423] Fix | Delete
# recursive) as an array of Pathname objects.
[424] Fix | Delete
#
[425] Fix | Delete
# By default, the returned pathnames will have enough information to access
[426] Fix | Delete
# the files. If you set +with_directory+ to +false+, then the returned
[427] Fix | Delete
# pathnames will contain the filename only.
[428] Fix | Delete
#
[429] Fix | Delete
# For example:
[430] Fix | Delete
# pn = Pathname("/usr/lib/ruby/1.8")
[431] Fix | Delete
# pn.children
[432] Fix | Delete
# # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
[433] Fix | Delete
# Pathname:/usr/lib/ruby/1.8/Env.rb,
[434] Fix | Delete
# Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
[435] Fix | Delete
# pn.children(false)
[436] Fix | Delete
# # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
[437] Fix | Delete
#
[438] Fix | Delete
# Note that the results never contain the entries +.+ and +..+ in
[439] Fix | Delete
# the directory because they are not children.
[440] Fix | Delete
#
[441] Fix | Delete
def children(with_directory=true)
[442] Fix | Delete
with_directory = false if @path == '.'
[443] Fix | Delete
result = []
[444] Fix | Delete
Dir.foreach(@path) {|e|
[445] Fix | Delete
next if e == '.' || e == '..'
[446] Fix | Delete
if with_directory
[447] Fix | Delete
result << self.class.new(File.join(@path, e))
[448] Fix | Delete
else
[449] Fix | Delete
result << self.class.new(e)
[450] Fix | Delete
end
[451] Fix | Delete
}
[452] Fix | Delete
result
[453] Fix | Delete
end
[454] Fix | Delete
[455] Fix | Delete
# Iterates over the children of the directory
[456] Fix | Delete
# (files and subdirectories, not recursive).
[457] Fix | Delete
#
[458] Fix | Delete
# It yields Pathname object for each child.
[459] Fix | Delete
#
[460] Fix | Delete
# By default, the yielded pathnames will have enough information to access
[461] Fix | Delete
# the files.
[462] Fix | Delete
#
[463] Fix | Delete
# If you set +with_directory+ to +false+, then the returned pathnames will
[464] Fix | Delete
# contain the filename only.
[465] Fix | Delete
#
[466] Fix | Delete
# Pathname("/usr/local").each_child {|f| p f }
[467] Fix | Delete
# #=> #<Pathname:/usr/local/share>
[468] Fix | Delete
# # #<Pathname:/usr/local/bin>
[469] Fix | Delete
# # #<Pathname:/usr/local/games>
[470] Fix | Delete
# # #<Pathname:/usr/local/lib>
[471] Fix | Delete
# # #<Pathname:/usr/local/include>
[472] Fix | Delete
# # #<Pathname:/usr/local/sbin>
[473] Fix | Delete
# # #<Pathname:/usr/local/src>
[474] Fix | Delete
# # #<Pathname:/usr/local/man>
[475] Fix | Delete
#
[476] Fix | Delete
# Pathname("/usr/local").each_child(false) {|f| p f }
[477] Fix | Delete
# #=> #<Pathname:share>
[478] Fix | Delete
# # #<Pathname:bin>
[479] Fix | Delete
# # #<Pathname:games>
[480] Fix | Delete
# # #<Pathname:lib>
[481] Fix | Delete
# # #<Pathname:include>
[482] Fix | Delete
# # #<Pathname:sbin>
[483] Fix | Delete
# # #<Pathname:src>
[484] Fix | Delete
# # #<Pathname:man>
[485] Fix | Delete
#
[486] Fix | Delete
# Note that the results never contain the entries +.+ and +..+ in
[487] Fix | Delete
# the directory because they are not children.
[488] Fix | Delete
#
[489] Fix | Delete
# See Pathname#children
[490] Fix | Delete
#
[491] Fix | Delete
def each_child(with_directory=true, &b)
[492] Fix | Delete
children(with_directory).each(&b)
[493] Fix | Delete
end
[494] Fix | Delete
[495] Fix | Delete
#
[496] Fix | Delete
# Returns a relative path from the given +base_directory+ to the receiver.
[497] Fix | Delete
#
[498] Fix | Delete
# If +self+ is absolute, then +base_directory+ must be absolute too.
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function