80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/vfs/path.rb', line 80
def normalize_to_string path
root = path[0..0]
result, probably_dir = [], false
parts = path.split('/')[1..-1]
if parts
parts.each do |part|
if part == '..' and root != '.'
return nil, false unless result.size > 0
result.pop
probably_dir ||= true
else
result << part
probably_dir &&= false
end
end
end
normalized_path = result.join('/')
probably_dir ||= true if normalized_path.empty?
return "#{root}#{'/' unless root == '/' or normalized_path.empty?}#{normalized_path}", probably_dir
end
|