class QuartzTorrent::Metainfo::FileInfo

Information about a file contained in the torrent.

Attributes

length[RW]

Length of the file.

path[RW]

Relative path to the file. For a single-file torrent this is simply the name of the file. For a multi-file torrent, this is the directory names from the torrent and the filename separated by the file separator.

Public Class Methods

createFromBdecode(bdecode) click to toggle source

Create a FileInfo object from a bdecoded structure.

# File lib/quartz_torrent/metainfo.rb, line 34
def self.createFromBdecode(bdecode)
  result = FileInfo.new
  result.length = Metainfo.valueOrException(bdecode['length'], "Torrent metainfo listed multiple files, and one is missing the length property.")
  path = Metainfo.valueOrException(bdecode['path'], "Torrent metainfo listed multiple files, and one is missing the path property.")

  result.path = ""
  path.each do |part|
    result.path << File::SEPARATOR if result.path.length > 0
    result.path << part
  end
  
  result
end
new(length = nil, path = nil) click to toggle source
# File lib/quartz_torrent/metainfo.rb, line 22
def initialize(length = nil, path = nil)
  @length = length
  @path = path
end