File_Bittorrent2
[ class tree: File_Bittorrent2 ] [ index: File_Bittorrent2 ] [ all elements ]

Class: File_Bittorrent2_MakeTorrent

Source Location: /File_Bittorrent2-1.1.0/File/Bittorrent2/MakeTorrent.php

Class Overview


Provides a class for making .torrent files from a file or directory. Produces virtually identical torrent files as btmaketorrent.py from Bram Cohen's original BT client.


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 60]
Provides a class for making .torrent files from a file or directory. Produces virtually identical torrent files as btmaketorrent.py from Bram Cohen's original BT client.


[ Top ]


Class Variables

$announce =  ''

[line 80]

  • Var: The .torrent announce URL
  • Access: protected

Type:   string


[ Top ]

$announce_list = array()

[line 85]

  • Var: The .torrent announce_list extension
  • Access: protected

Type:   array


[ Top ]

$comment =  ''

[line 90]

  • Var: The .torrent comment
  • Access: protected

Type:   string


[ Top ]

$created_by =  'File_Bittorrent2_MakeTorrent $Rev: 79 $. http://pear.php.net/package/File_Bittorrent'

[line 95]

  • Var: The .torrent created by string
  • Access: protected

Type:   string


[ Top ]

$data_gap =  false

[line 120]

  • Var: The data gap used to join two files into the same piece. string if it contains data or false
  • Access: protected

Type:   string|false


[ Top ]

$files = array()

[line 115]

  • Var: The list of files (if this is a multi-file torrent)
  • Access: protected

Type:   array


[ Top ]

$fp =

[line 125]

  • Var: file pointer
  • Access: protected

Type:   resource


[ Top ]

$is_dir =  false

[line 75]

  • Var: Where or not $path is a directory
  • Access: protected

Type:   bool


[ Top ]

$is_file =  false

[line 70]

  • Var: Whether or not $path is a file
  • Access: protected

Type:   bool


[ Top ]

$is_multifile =  false

[line 135]

  • Var: Where or not we have a list of files
  • Access: protected

Type:   bool


[ Top ]

$last_error =

[line 130]

  • Var: The last error object or null if no error has occurred.
  • Access: protected

Type:   mixed


[ Top ]

$name =  ''

[line 100]

  • Var: The .torrent suggested name (file/dir)
  • Access: protected

Type:   string


[ Top ]

$path =  ''

[line 65]

  • Var: Path to the file or directory to create the torrent from.
  • Access: protected

Type:   string


[ Top ]

$pieces =  ''

[line 105]

  • Var: The .torrent packed piece data
  • Access: protected

Type:   string


[ Top ]

$piece_length =  524288

[line 110]

  • Var: The size of each piece in bytes.
  • Access: protected

Type:   int


[ Top ]



Method Detail

File_Bittorrent2_MakeTorrent (Constructor)   [line 145]

File_Bittorrent2_MakeTorrent File_Bittorrent2_MakeTorrent( string $path)

Constructor

Sets up the path to the file/dir to create a torrent from


Parameters:

string   $path   —  Path to use

[ Top ]

addDir   [line 376]

void addDir( string $path)

Internal function which iterates through directories and subdirectories, using _addFile for each file it finds.
  • Access: protected

Parameters:

string   $path   —  path to the directory

[ Top ]

addFile   [line 307]

mixed addFile( string $file)

Internal function which generates metainfo data for a file
  • Return: false on failure or file metainfo data
  • Throws: File_Bittorrent2_Exception if given file cannot be opened
  • Access: protected

Parameters:

string   $file   —  path to the file

[ Top ]

addFiles   [line 504]

bool addFiles( array $filelist, string $dir)

Function to add a specific list of files, pass blank to the constructor then call this function

Parameters:

array   $filelist   —  list of filepaths to add;
string   $dir   —  folder containing files

[ Top ]

buildTorrent   [line 238]

mixed buildTorrent( )

Function to build the .torrent file based on the parameters you have set with the set* functions.
  • Return: false on failure or a string containing the metainfo
  • Throws: File_Bittorrent2_Exception if no file or directory is given

[ Top ]

closeFile   [line 474]

void closeFile( )

Internal function to close a file pointer
  • Access: protected

[ Top ]

dirList   [line 405]

array dirList( string $dir)

Internal function which recurses through subdirectory and returns an array of file paths
  • Return: file list
  • Access: protected

Parameters:

string   $dir   —  path to the directory

[ Top ]

encodeTorrent   [line 270]

mixed encodeTorrent( [array $info = array()])

Internal function which bencodes the data into a valid torrent metainfo string
  • Return: false on failure or the bencoded metainfo string
  • Throws: File_Bittorrent2_Exception if no file or directory is defined
  • Access: protected

Parameters:

array   $info   —  file data

[ Top ]

filesize   [line 435]

int filesize( string $file)

Internal function to get the filesize of a file. Workaround for files >2GB.
  • Return: the filesize
  • Access: protected

Parameters:

string   $file   —  path to the file

[ Top ]

openFile   [line 453]

bool openFile( string $file)

Internal function to open a file.

Workaround for files >2GB using popen

  • Throws: File_Bittorrent2_Exception if opening file fails or is larger than 2GB (on Windows only)
  • Access: protected

Parameters:

string   $file   —  path to the file

[ Top ]

setAnnounce   [line 157]

bool setAnnounce( string $announce)

Function to set the announce URL for the .torrent file

Parameters:

string   $announce   —  announce url

[ Top ]

setAnnounceList   [line 170]

bool setAnnounceList( array $announce_list)

Function to set the announce list for the .torrent file

Parameters:

array   $announce_list   —  announce list

[ Top ]

setComment   [line 183]

bool setComment( string $comment)

Function to set the comment for the .torrent file

Parameters:

string   $comment   —  comment

[ Top ]

setName   [line 490]

bool setName( string $name)

Function to set the name for the .torrent file

Parameters:

string   $name   —  name

[ Top ]

setPath   [line 197]

bool setPath( string $path)

Function to set the path for the file/dir to make the .torrent for Can also be set through the constructor.

Parameters:

string   $path   —  path to file/dir

[ Top ]

setPieceLength   [line 221]

bool setPieceLength( int $piece_length)

Function to set the piece length for the .torrent file.

min: 32 (32KB), max: 4096 (4MB)

  • Throws: File_Bittorrent2_Exception if piece length is invalid

Parameters:

int   $piece_length   —  piece length in kilobytes

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:14:41 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.