module Archive::Tar
Constants
- VERSION
Public Instance Methods
join_path(*files)
click to toggle source
# File lib/archive/tar.rb, line 62 def join_path(*files) absolute = files[0][0] == "/" files = files.map do |element| normalize_path element end new_path = files.join("/") new_path = "/" + new_path if absolute new_path end
normalize_path(path)
click to toggle source
# File lib/archive/tar.rb, line 27 def normalize_path(path) path = path.gsub("\\", "/") while path[-1] == "/" path = path[0..-2] end while path[0] == "/" path = path[1..-1] end solve_path(path.gsub(/[\/]{2,}/, "/")) end
solve_path(path)
click to toggle source
# File lib/archive/tar.rb, line 41 def solve_path(path) path_parts = path.split("/") realpath = [] path_parts.each do |i| if i == "." next end if i == ".." realpath = realpath[1..-2] realpath = [] if realpath == nil next end realpath << i end realpath.join("/") end