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