Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: pathname.rb
#
[0] Fix | Delete
# = pathname.rb
[1] Fix | Delete
#
[2] Fix | Delete
# Object-Oriented Pathname Class
[3] Fix | Delete
#
[4] Fix | Delete
# Author:: Tanaka Akira <akr@m17n.org>
[5] Fix | Delete
# Documentation:: Author and Gavin Sinclair
[6] Fix | Delete
#
[7] Fix | Delete
# For documentation, see class Pathname.
[8] Fix | Delete
#
[9] Fix | Delete
# <tt>pathname.rb</tt> is distributed with Ruby since 1.8.0.
[10] Fix | Delete
#
[11] Fix | Delete
[12] Fix | Delete
#
[13] Fix | Delete
# == Pathname
[14] Fix | Delete
#
[15] Fix | Delete
# Pathname represents a pathname which locates a file in a filesystem.
[16] Fix | Delete
# The pathname depends on OS: Unix, Windows, etc.
[17] Fix | Delete
# Pathname library works with pathnames of local OS.
[18] Fix | Delete
# However non-Unix pathnames are supported experimentally.
[19] Fix | Delete
#
[20] Fix | Delete
# It does not represent the file itself.
[21] Fix | Delete
# A Pathname can be relative or absolute. It's not until you try to
[22] Fix | Delete
# reference the file that it even matters whether the file exists or not.
[23] Fix | Delete
#
[24] Fix | Delete
# Pathname is immutable. It has no method for destructive update.
[25] Fix | Delete
#
[26] Fix | Delete
# The value of this class is to manipulate file path information in a neater
[27] Fix | Delete
# way than standard Ruby provides. The examples below demonstrate the
[28] Fix | Delete
# difference. *All* functionality from File, FileTest, and some from Dir and
[29] Fix | Delete
# FileUtils is included, in an unsurprising way. It is essentially a facade for
[30] Fix | Delete
# all of these, and more.
[31] Fix | Delete
#
[32] Fix | Delete
# == Examples
[33] Fix | Delete
#
[34] Fix | Delete
# === Example 1: Using Pathname
[35] Fix | Delete
#
[36] Fix | Delete
# require 'pathname'
[37] Fix | Delete
# p = Pathname.new("/usr/bin/ruby")
[38] Fix | Delete
# size = p.size # 27662
[39] Fix | Delete
# isdir = p.directory? # false
[40] Fix | Delete
# dir = p.dirname # Pathname:/usr/bin
[41] Fix | Delete
# base = p.basename # Pathname:ruby
[42] Fix | Delete
# dir, base = p.split # [Pathname:/usr/bin, Pathname:ruby]
[43] Fix | Delete
# data = p.read
[44] Fix | Delete
# p.open { |f| _ }
[45] Fix | Delete
# p.each_line { |line| _ }
[46] Fix | Delete
#
[47] Fix | Delete
# === Example 2: Using standard Ruby
[48] Fix | Delete
#
[49] Fix | Delete
# p = "/usr/bin/ruby"
[50] Fix | Delete
# size = File.size(p) # 27662
[51] Fix | Delete
# isdir = File.directory?(p) # false
[52] Fix | Delete
# dir = File.dirname(p) # "/usr/bin"
[53] Fix | Delete
# base = File.basename(p) # "ruby"
[54] Fix | Delete
# dir, base = File.split(p) # ["/usr/bin", "ruby"]
[55] Fix | Delete
# data = File.read(p)
[56] Fix | Delete
# File.open(p) { |f| _ }
[57] Fix | Delete
# File.foreach(p) { |line| _ }
[58] Fix | Delete
#
[59] Fix | Delete
# === Example 3: Special features
[60] Fix | Delete
#
[61] Fix | Delete
# p1 = Pathname.new("/usr/lib") # Pathname:/usr/lib
[62] Fix | Delete
# p2 = p1 + "ruby/1.8" # Pathname:/usr/lib/ruby/1.8
[63] Fix | Delete
# p3 = p1.parent # Pathname:/usr
[64] Fix | Delete
# p4 = p2.relative_path_from(p3) # Pathname:lib/ruby/1.8
[65] Fix | Delete
# pwd = Pathname.pwd # Pathname:/home/gavin
[66] Fix | Delete
# pwd.absolute? # true
[67] Fix | Delete
# p5 = Pathname.new "." # Pathname:.
[68] Fix | Delete
# p5 = p5 + "music/../articles" # Pathname:music/../articles
[69] Fix | Delete
# p5.cleanpath # Pathname:articles
[70] Fix | Delete
# p5.realpath # Pathname:/home/gavin/articles
[71] Fix | Delete
# p5.children # [Pathname:/home/gavin/articles/linux, ...]
[72] Fix | Delete
#
[73] Fix | Delete
# == Breakdown of functionality
[74] Fix | Delete
#
[75] Fix | Delete
# === Core methods
[76] Fix | Delete
#
[77] Fix | Delete
# These methods are effectively manipulating a String, because that's all a path
[78] Fix | Delete
# is. Except for #mountpoint?, #children, and #realpath, they don't access the
[79] Fix | Delete
# filesystem.
[80] Fix | Delete
#
[81] Fix | Delete
# - +
[82] Fix | Delete
# - #join
[83] Fix | Delete
# - #parent
[84] Fix | Delete
# - #root?
[85] Fix | Delete
# - #absolute?
[86] Fix | Delete
# - #relative?
[87] Fix | Delete
# - #relative_path_from
[88] Fix | Delete
# - #each_filename
[89] Fix | Delete
# - #cleanpath
[90] Fix | Delete
# - #realpath
[91] Fix | Delete
# - #children
[92] Fix | Delete
# - #mountpoint?
[93] Fix | Delete
#
[94] Fix | Delete
# === File status predicate methods
[95] Fix | Delete
#
[96] Fix | Delete
# These methods are a facade for FileTest:
[97] Fix | Delete
# - #blockdev?
[98] Fix | Delete
# - #chardev?
[99] Fix | Delete
# - #directory?
[100] Fix | Delete
# - #executable?
[101] Fix | Delete
# - #executable_real?
[102] Fix | Delete
# - #exist?
[103] Fix | Delete
# - #file?
[104] Fix | Delete
# - #grpowned?
[105] Fix | Delete
# - #owned?
[106] Fix | Delete
# - #pipe?
[107] Fix | Delete
# - #readable?
[108] Fix | Delete
# - #world_readable?
[109] Fix | Delete
# - #readable_real?
[110] Fix | Delete
# - #setgid?
[111] Fix | Delete
# - #setuid?
[112] Fix | Delete
# - #size
[113] Fix | Delete
# - #size?
[114] Fix | Delete
# - #socket?
[115] Fix | Delete
# - #sticky?
[116] Fix | Delete
# - #symlink?
[117] Fix | Delete
# - #writable?
[118] Fix | Delete
# - #world_writable?
[119] Fix | Delete
# - #writable_real?
[120] Fix | Delete
# - #zero?
[121] Fix | Delete
#
[122] Fix | Delete
# === File property and manipulation methods
[123] Fix | Delete
#
[124] Fix | Delete
# These methods are a facade for File:
[125] Fix | Delete
# - #atime
[126] Fix | Delete
# - #ctime
[127] Fix | Delete
# - #mtime
[128] Fix | Delete
# - #chmod(mode)
[129] Fix | Delete
# - #lchmod(mode)
[130] Fix | Delete
# - #chown(owner, group)
[131] Fix | Delete
# - #lchown(owner, group)
[132] Fix | Delete
# - #fnmatch(pattern, *args)
[133] Fix | Delete
# - #fnmatch?(pattern, *args)
[134] Fix | Delete
# - #ftype
[135] Fix | Delete
# - #make_link(old)
[136] Fix | Delete
# - #open(*args, &block)
[137] Fix | Delete
# - #readlink
[138] Fix | Delete
# - #rename(to)
[139] Fix | Delete
# - #stat
[140] Fix | Delete
# - #lstat
[141] Fix | Delete
# - #make_symlink(old)
[142] Fix | Delete
# - #truncate(length)
[143] Fix | Delete
# - #utime(atime, mtime)
[144] Fix | Delete
# - #basename(*args)
[145] Fix | Delete
# - #dirname
[146] Fix | Delete
# - #extname
[147] Fix | Delete
# - #expand_path(*args)
[148] Fix | Delete
# - #split
[149] Fix | Delete
#
[150] Fix | Delete
# === Directory methods
[151] Fix | Delete
#
[152] Fix | Delete
# These methods are a facade for Dir:
[153] Fix | Delete
# - Pathname.glob(*args)
[154] Fix | Delete
# - Pathname.getwd / Pathname.pwd
[155] Fix | Delete
# - #rmdir
[156] Fix | Delete
# - #entries
[157] Fix | Delete
# - #each_entry(&block)
[158] Fix | Delete
# - #mkdir(*args)
[159] Fix | Delete
# - #opendir(*args)
[160] Fix | Delete
#
[161] Fix | Delete
# === IO
[162] Fix | Delete
#
[163] Fix | Delete
# These methods are a facade for IO:
[164] Fix | Delete
# - #each_line(*args, &block)
[165] Fix | Delete
# - #read(*args)
[166] Fix | Delete
# - #readlines(*args)
[167] Fix | Delete
# - #sysopen(*args)
[168] Fix | Delete
#
[169] Fix | Delete
# === Utilities
[170] Fix | Delete
#
[171] Fix | Delete
# These methods are a mixture of Find, FileUtils, and others:
[172] Fix | Delete
# - #find(&block)
[173] Fix | Delete
# - #mkpath
[174] Fix | Delete
# - #rmtree
[175] Fix | Delete
# - #unlink / #delete
[176] Fix | Delete
#
[177] Fix | Delete
#
[178] Fix | Delete
# == Method documentation
[179] Fix | Delete
#
[180] Fix | Delete
# As the above section shows, most of the methods in Pathname are facades. The
[181] Fix | Delete
# documentation for these methods generally just says, for instance, "See
[182] Fix | Delete
# FileTest.writable?", as you should be familiar with the original method
[183] Fix | Delete
# anyway, and its documentation (e.g. through +ri+) will contain more
[184] Fix | Delete
# information. In some cases, a brief description will follow.
[185] Fix | Delete
#
[186] Fix | Delete
class Pathname
[187] Fix | Delete
[188] Fix | Delete
# :stopdoc:
[189] Fix | Delete
if RUBY_VERSION < "1.9"
[190] Fix | Delete
TO_PATH = :to_str
[191] Fix | Delete
else
[192] Fix | Delete
# to_path is implemented so Pathname objects are usable with File.open, etc.
[193] Fix | Delete
TO_PATH = :to_path
[194] Fix | Delete
end
[195] Fix | Delete
[196] Fix | Delete
SAME_PATHS = if File::FNM_SYSCASE.nonzero?
[197] Fix | Delete
proc {|a, b| a.casecmp(b).zero?}
[198] Fix | Delete
else
[199] Fix | Delete
proc {|a, b| a == b}
[200] Fix | Delete
end
[201] Fix | Delete
[202] Fix | Delete
# :startdoc:
[203] Fix | Delete
[204] Fix | Delete
#
[205] Fix | Delete
# Create a Pathname object from the given String (or String-like object).
[206] Fix | Delete
# If +path+ contains a NUL character (<tt>\0</tt>), an ArgumentError is raised.
[207] Fix | Delete
#
[208] Fix | Delete
def initialize(path)
[209] Fix | Delete
path = path.__send__(TO_PATH) if path.respond_to? TO_PATH
[210] Fix | Delete
@path = path.dup
[211] Fix | Delete
[212] Fix | Delete
if /\0/ =~ @path
[213] Fix | Delete
raise ArgumentError, "pathname contains \\0: #{@path.inspect}"
[214] Fix | Delete
end
[215] Fix | Delete
[216] Fix | Delete
self.taint if @path.tainted?
[217] Fix | Delete
end
[218] Fix | Delete
[219] Fix | Delete
def freeze() super; @path.freeze; self end
[220] Fix | Delete
def taint() super; @path.taint; self end
[221] Fix | Delete
def untaint() super; @path.untaint; self end
[222] Fix | Delete
[223] Fix | Delete
#
[224] Fix | Delete
# Compare this pathname with +other+. The comparison is string-based.
[225] Fix | Delete
# Be aware that two different paths (<tt>foo.txt</tt> and <tt>./foo.txt</tt>)
[226] Fix | Delete
# can refer to the same file.
[227] Fix | Delete
#
[228] Fix | Delete
def ==(other)
[229] Fix | Delete
return false unless Pathname === other
[230] Fix | Delete
other.to_s == @path
[231] Fix | Delete
end
[232] Fix | Delete
alias === ==
[233] Fix | Delete
alias eql? ==
[234] Fix | Delete
[235] Fix | Delete
# Provides for comparing pathnames, case-sensitively.
[236] Fix | Delete
def <=>(other)
[237] Fix | Delete
return nil unless Pathname === other
[238] Fix | Delete
@path.tr('/', "\0") <=> other.to_s.tr('/', "\0")
[239] Fix | Delete
end
[240] Fix | Delete
[241] Fix | Delete
def hash # :nodoc:
[242] Fix | Delete
@path.hash
[243] Fix | Delete
end
[244] Fix | Delete
[245] Fix | Delete
# Return the path as a String.
[246] Fix | Delete
def to_s
[247] Fix | Delete
@path.dup
[248] Fix | Delete
end
[249] Fix | Delete
[250] Fix | Delete
# to_path is implemented so Pathname objects are usable with File.open, etc.
[251] Fix | Delete
alias_method TO_PATH, :to_s
[252] Fix | Delete
[253] Fix | Delete
def inspect # :nodoc:
[254] Fix | Delete
"#<#{self.class}:#{@path}>"
[255] Fix | Delete
end
[256] Fix | Delete
[257] Fix | Delete
# Return a pathname which is substituted by String#sub.
[258] Fix | Delete
def sub(pattern, *rest, &block)
[259] Fix | Delete
if block
[260] Fix | Delete
path = @path.sub(pattern, *rest) {|*args|
[261] Fix | Delete
begin
[262] Fix | Delete
old = Thread.current[:pathname_sub_matchdata]
[263] Fix | Delete
Thread.current[:pathname_sub_matchdata] = $~
[264] Fix | Delete
eval("$~ = Thread.current[:pathname_sub_matchdata]", block.binding)
[265] Fix | Delete
ensure
[266] Fix | Delete
Thread.current[:pathname_sub_matchdata] = old
[267] Fix | Delete
end
[268] Fix | Delete
yield(*args)
[269] Fix | Delete
}
[270] Fix | Delete
else
[271] Fix | Delete
path = @path.sub(pattern, *rest)
[272] Fix | Delete
end
[273] Fix | Delete
self.class.new(path)
[274] Fix | Delete
end
[275] Fix | Delete
[276] Fix | Delete
if File::ALT_SEPARATOR
[277] Fix | Delete
SEPARATOR_PAT = /[#{Regexp.quote File::ALT_SEPARATOR}#{Regexp.quote File::SEPARATOR}]/
[278] Fix | Delete
else
[279] Fix | Delete
SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/
[280] Fix | Delete
end
[281] Fix | Delete
[282] Fix | Delete
# chop_basename(path) -> [pre-basename, basename] or nil
[283] Fix | Delete
def chop_basename(path)
[284] Fix | Delete
base = File.basename(path)
[285] Fix | Delete
if /\A#{SEPARATOR_PAT}?\z/ =~ base
[286] Fix | Delete
return nil
[287] Fix | Delete
else
[288] Fix | Delete
return path[0, path.rindex(base)], base
[289] Fix | Delete
end
[290] Fix | Delete
end
[291] Fix | Delete
private :chop_basename
[292] Fix | Delete
[293] Fix | Delete
# split_names(path) -> prefix, [name, ...]
[294] Fix | Delete
def split_names(path)
[295] Fix | Delete
names = []
[296] Fix | Delete
while r = chop_basename(path)
[297] Fix | Delete
path, basename = r
[298] Fix | Delete
names.unshift basename
[299] Fix | Delete
end
[300] Fix | Delete
return path, names
[301] Fix | Delete
end
[302] Fix | Delete
private :split_names
[303] Fix | Delete
[304] Fix | Delete
def prepend_prefix(prefix, relpath)
[305] Fix | Delete
if relpath.empty?
[306] Fix | Delete
File.dirname(prefix)
[307] Fix | Delete
elsif /#{SEPARATOR_PAT}/ =~ prefix
[308] Fix | Delete
prefix = File.dirname(prefix)
[309] Fix | Delete
prefix = File.join(prefix, "") if File.basename(prefix + 'a') != 'a'
[310] Fix | Delete
prefix + relpath
[311] Fix | Delete
else
[312] Fix | Delete
prefix + relpath
[313] Fix | Delete
end
[314] Fix | Delete
end
[315] Fix | Delete
private :prepend_prefix
[316] Fix | Delete
[317] Fix | Delete
# Returns clean pathname of +self+ with consecutive slashes and useless dots
[318] Fix | Delete
# removed. The filesystem is not accessed.
[319] Fix | Delete
#
[320] Fix | Delete
# If +consider_symlink+ is +true+, then a more conservative algorithm is used
[321] Fix | Delete
# to avoid breaking symbolic linkages. This may retain more <tt>..</tt>
[322] Fix | Delete
# entries than absolutely necessary, but without accessing the filesystem,
[323] Fix | Delete
# this can't be avoided. See #realpath.
[324] Fix | Delete
#
[325] Fix | Delete
def cleanpath(consider_symlink=false)
[326] Fix | Delete
if consider_symlink
[327] Fix | Delete
cleanpath_conservative
[328] Fix | Delete
else
[329] Fix | Delete
cleanpath_aggressive
[330] Fix | Delete
end
[331] Fix | Delete
end
[332] Fix | Delete
[333] Fix | Delete
#
[334] Fix | Delete
# Clean the path simply by resolving and removing excess "." and ".." entries.
[335] Fix | Delete
# Nothing more, nothing less.
[336] Fix | Delete
#
[337] Fix | Delete
def cleanpath_aggressive
[338] Fix | Delete
path = @path
[339] Fix | Delete
names = []
[340] Fix | Delete
pre = path
[341] Fix | Delete
while r = chop_basename(pre)
[342] Fix | Delete
pre, base = r
[343] Fix | Delete
case base
[344] Fix | Delete
when '.'
[345] Fix | Delete
when '..'
[346] Fix | Delete
names.unshift base
[347] Fix | Delete
else
[348] Fix | Delete
if names[0] == '..'
[349] Fix | Delete
names.shift
[350] Fix | Delete
else
[351] Fix | Delete
names.unshift base
[352] Fix | Delete
end
[353] Fix | Delete
end
[354] Fix | Delete
end
[355] Fix | Delete
if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
[356] Fix | Delete
names.shift while names[0] == '..'
[357] Fix | Delete
end
[358] Fix | Delete
self.class.new(prepend_prefix(pre, File.join(*names)))
[359] Fix | Delete
end
[360] Fix | Delete
private :cleanpath_aggressive
[361] Fix | Delete
[362] Fix | Delete
# has_trailing_separator?(path) -> bool
[363] Fix | Delete
def has_trailing_separator?(path)
[364] Fix | Delete
if r = chop_basename(path)
[365] Fix | Delete
pre, basename = r
[366] Fix | Delete
pre.length + basename.length < path.length
[367] Fix | Delete
else
[368] Fix | Delete
false
[369] Fix | Delete
end
[370] Fix | Delete
end
[371] Fix | Delete
private :has_trailing_separator?
[372] Fix | Delete
[373] Fix | Delete
# add_trailing_separator(path) -> path
[374] Fix | Delete
def add_trailing_separator(path)
[375] Fix | Delete
if File.basename(path + 'a') == 'a'
[376] Fix | Delete
path
[377] Fix | Delete
else
[378] Fix | Delete
File.join(path, "") # xxx: Is File.join is appropriate to add separator?
[379] Fix | Delete
end
[380] Fix | Delete
end
[381] Fix | Delete
private :add_trailing_separator
[382] Fix | Delete
[383] Fix | Delete
def del_trailing_separator(path)
[384] Fix | Delete
if r = chop_basename(path)
[385] Fix | Delete
pre, basename = r
[386] Fix | Delete
pre + basename
[387] Fix | Delete
elsif /#{SEPARATOR_PAT}+\z/o =~ path
[388] Fix | Delete
$` + File.dirname(path)[/#{SEPARATOR_PAT}*\z/o]
[389] Fix | Delete
else
[390] Fix | Delete
path
[391] Fix | Delete
end
[392] Fix | Delete
end
[393] Fix | Delete
private :del_trailing_separator
[394] Fix | Delete
[395] Fix | Delete
def cleanpath_conservative
[396] Fix | Delete
path = @path
[397] Fix | Delete
names = []
[398] Fix | Delete
pre = path
[399] Fix | Delete
while r = chop_basename(pre)
[400] Fix | Delete
pre, base = r
[401] Fix | Delete
names.unshift base if base != '.'
[402] Fix | Delete
end
[403] Fix | Delete
if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
[404] Fix | Delete
names.shift while names[0] == '..'
[405] Fix | Delete
end
[406] Fix | Delete
if names.empty?
[407] Fix | Delete
self.class.new(File.dirname(pre))
[408] Fix | Delete
else
[409] Fix | Delete
if names.last != '..' && File.basename(path) == '.'
[410] Fix | Delete
names << '.'
[411] Fix | Delete
end
[412] Fix | Delete
result = prepend_prefix(pre, File.join(*names))
[413] Fix | Delete
if /\A(?:\.|\.\.)\z/ !~ names.last && has_trailing_separator?(path)
[414] Fix | Delete
self.class.new(add_trailing_separator(result))
[415] Fix | Delete
else
[416] Fix | Delete
self.class.new(result)
[417] Fix | Delete
end
[418] Fix | Delete
end
[419] Fix | Delete
end
[420] Fix | Delete
private :cleanpath_conservative
[421] Fix | Delete
[422] Fix | Delete
def realpath_rec(prefix, unresolved, h)
[423] Fix | Delete
resolved = []
[424] Fix | Delete
until unresolved.empty?
[425] Fix | Delete
n = unresolved.shift
[426] Fix | Delete
if n == '.'
[427] Fix | Delete
next
[428] Fix | Delete
elsif n == '..'
[429] Fix | Delete
resolved.pop
[430] Fix | Delete
else
[431] Fix | Delete
path = prepend_prefix(prefix, File.join(*(resolved + [n])))
[432] Fix | Delete
if h.include? path
[433] Fix | Delete
if h[path] == :resolving
[434] Fix | Delete
raise Errno::ELOOP.new(path)
[435] Fix | Delete
else
[436] Fix | Delete
prefix, *resolved = h[path]
[437] Fix | Delete
end
[438] Fix | Delete
else
[439] Fix | Delete
s = File.lstat(path)
[440] Fix | Delete
if s.symlink?
[441] Fix | Delete
h[path] = :resolving
[442] Fix | Delete
link_prefix, link_names = split_names(File.readlink(path))
[443] Fix | Delete
if link_prefix == ''
[444] Fix | Delete
prefix, *resolved = h[path] = realpath_rec(prefix, resolved + link_names, h)
[445] Fix | Delete
else
[446] Fix | Delete
prefix, *resolved = h[path] = realpath_rec(link_prefix, link_names, h)
[447] Fix | Delete
end
[448] Fix | Delete
else
[449] Fix | Delete
resolved << n
[450] Fix | Delete
h[path] = [prefix, *resolved]
[451] Fix | Delete
end
[452] Fix | Delete
end
[453] Fix | Delete
end
[454] Fix | Delete
end
[455] Fix | Delete
return prefix, *resolved
[456] Fix | Delete
end
[457] Fix | Delete
private :realpath_rec
[458] Fix | Delete
[459] Fix | Delete
#
[460] Fix | Delete
# Returns a real (absolute) pathname of +self+ in the actual filesystem.
[461] Fix | Delete
# The real pathname doesn't contain symlinks or useless dots.
[462] Fix | Delete
#
[463] Fix | Delete
# No arguments should be given; the old behaviour is *obsoleted*.
[464] Fix | Delete
#
[465] Fix | Delete
def realpath
[466] Fix | Delete
path = @path
[467] Fix | Delete
prefix, names = split_names(path)
[468] Fix | Delete
if prefix == ''
[469] Fix | Delete
prefix, names2 = split_names(Dir.pwd)
[470] Fix | Delete
names = names2 + names
[471] Fix | Delete
end
[472] Fix | Delete
prefix, *names = realpath_rec(prefix, names, {})
[473] Fix | Delete
self.class.new(prepend_prefix(prefix, File.join(*names)))
[474] Fix | Delete
end
[475] Fix | Delete
[476] Fix | Delete
# #parent returns the parent directory.
[477] Fix | Delete
#
[478] Fix | Delete
# This is same as <tt>self + '..'</tt>.
[479] Fix | Delete
def parent
[480] Fix | Delete
self + '..'
[481] Fix | Delete
end
[482] Fix | Delete
[483] Fix | Delete
# #mountpoint? returns +true+ if <tt>self</tt> points to a mountpoint.
[484] Fix | Delete
def mountpoint?
[485] Fix | Delete
begin
[486] Fix | Delete
stat1 = self.lstat
[487] Fix | Delete
stat2 = self.parent.lstat
[488] Fix | Delete
stat1.dev == stat2.dev && stat1.ino == stat2.ino ||
[489] Fix | Delete
stat1.dev != stat2.dev
[490] Fix | Delete
rescue Errno::ENOENT
[491] Fix | Delete
false
[492] Fix | Delete
end
[493] Fix | Delete
end
[494] Fix | Delete
[495] Fix | Delete
#
[496] Fix | Delete
# #root? is a predicate for root directories. I.e. it returns +true+ if the
[497] Fix | Delete
# pathname consists of consecutive slashes.
[498] Fix | Delete
#
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function