method
realpath_rec
v1_8_6_287 -
Show latest stable
-
0 notes -
Class: Pathname
- 1_8_6_287 (0)
- 1_8_7_72 (0)
- 1_8_7_330 (0)
- 1_9_1_378 (0)
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
realpath_rec(prefix, unresolved, h)
private
Hide source
# File lib/pathname.rb, line 403 def realpath_rec(prefix, unresolved, h) resolved = [] until unresolved.empty? n = unresolved.shift if n == '.' next elsif n == '..' resolved.pop else path = prepend_prefix(prefix, File.join(*(resolved + [n]))) if h.include? path if h[path] == :resolving raise Errno::ELOOP.new(path) else prefix, *resolved = h[path] end else s = File.lstat(path) if s.symlink? h[path] = :resolving link_prefix, link_names = split_names(File.readlink(path)) if link_prefix == '' prefix, *resolved = h[path] = realpath_rec(prefix, resolved + link_names, h) else prefix, *resolved = h[path] = realpath_rec(link_prefix, link_names, h) end else resolved << n h[path] = [prefix, *resolved] end end end end return prefix, *resolved end