Discussion:
[libtorrent] Cannot locate file_storage object in python_bindings
Ronald Degmar
2017-03-19 20:48:46 UTC
Permalink
Hi guys,

*I'm trying to get the filenames included in a torrent.*
When I execute the following for a handler called "h", I get:

h.get_torrent_info().files()
the result is a list: [libtorrent.file_entry object at
0x7fb...,libtorrent.file_entry object at 0xghfb..., libtorrent.file_entry
object at 0x545db...]
However, according to documentation I should have gotten a file_storage
object

torrent_info
*orig_files() files()*
file_storage const& *files ()* const;
file_storage const& orig_files () const;
The file_storage object contains the information on how to map the pieces
to files. It is separated from the torrent_info object because when
creating torrents a storage object needs to be created without having a
torrent file. When renaming files in a storage, the storage needs to make
its own copy of the file_storage in order to make its mapping differ from
the one in the torrent file.

I want to call the file_name() method in the file storage according to
documentation:

file_storage
file_name() returns just the name of the file, whereas file_path() returns
the path (inside the torrent file) with the filename appended.

However, I got a different structure [libtorrent.file_entry object at
0x7fb...,libtorrent.file_entry object at 0xghfb..., libtorrent.file_entry
object at 0x545db...]
Each one of this objects has a set of methods different to the one
specified in the file storage object. They are as follows:
executable_attribute, file_base, filehash,hidden_attribute,mtime, offset,
pad_file, *path*, size, symlink_attribute, symlink_path.

The only attribute that can help me getting the filenames is the path
attribute, but this retrieves the entire path.
how can I get a list of all the filenames in a single torrent? why did I
get a different structure?

Ronald

Loading...