Module FileType::ExtractableDir
In: lib/file_type.rb

Methods

Public Instance methods

[Source]

# File lib/file_type.rb, line 194
    def extract
      dir = extract_extractable
      FileType.guess(dir.path + longest_common_path(@log).join('/'))
    end

We want the longest common path

[Source]

# File lib/file_type.rb, line 200
    def longest_common_path ( log )
      longest = nil
      raise CorruptedTarballError, 'tar output empty' if log.zero?
      log.each_line do |line|
        line.chomp!
        path = line.split(/\//)
        longest = path if longest.nil?
        longest &= path
        raise CorruptedTarballError, log.read if longest.empty?
      end
      raise CorruptedTarballError, log.read if longest.nil?
      longest
    end

[Source]

# File lib/file_type.rb, line 187
    def mk_cmd ( out )
      @log = TempPath.new('log')
      cmd = extract_command[@tmp] < @path > @log
      @tmp.mkpath
      cmd
    end

[Validate]