Discussion:
[libtorrent] Download a torrent without making a subdir
Jeff Brill
2016-03-15 02:17:13 UTC
Permalink
Hey, I'm not super familiar with the structure of torrents, so feel free to
let me know that I'm totally off base here. I'm using mktorrent to
generate a torrent, and on the other side, I'm using libtorrent in a small
app to download the files. I'm placing my files in a directory, say
MyFiles/*, and passing that dir to mktorrent. When I download the files, I
don't specify that directory name in the save_path or the data_path of
libtorrent, but they're being placed in a subdirectory named MyFiles anyway.

First off, am I correct in understanding that this is because libtorrent
automatically places files in a subdir using the name of the torrent?
If so, is there a way to disable that functionality, so the subdir is not
created?
Arvid Norberg
2016-03-15 05:35:22 UTC
Permalink
Post by Jeff Brill
Hey, I'm not super familiar with the structure of torrents, so feel free to
let me know that I'm totally off base here. I'm using mktorrent to
generate a torrent, and on the other side, I'm using libtorrent in a small
app to download the files. I'm placing my files in a directory, say
MyFiles/*, and passing that dir to mktorrent. When I download the files, I
don't specify that directory name in the save_path or the data_path of
libtorrent, but they're being placed in a subdirectory named MyFiles anyway.
First off, am I correct in understanding that this is because libtorrent
automatically places files in a subdir using the name of the torrent?
If so, is there a way to disable that functionality, so the subdir is not
created?
Yes, you can rename the files to not include the root directory. Once
you've loaded the .torrent file into the torrent_info object, it gives you
the opportunity to rename the files before adding it to the session.

See rename_file() http://libtorrent.org/reference-Core.html#torrent-info
--
Arvid Norberg
Loading...