apply tiennou's "output directory" patch from ticket #502

This commit is contained in:
Charles Kerr 2007-11-26 16:22:36 +00:00
parent 0ed3610468
commit b670e8e14a
2 changed files with 31 additions and 24 deletions

View File

@ -37,6 +37,7 @@
.Op Fl d Ar download-rate
.Op Fl u Ar upload-rate
.Op Fl f Ar script
.Op Fl o Ar output-dir
.Op Fl n
.Ar torrent-file
.Nm
@ -55,15 +56,15 @@ scripting capabilities.
.Pp
The options are as follows:
.Bl -tag -width Ds
.lt Fl c, Fl -create-from Ar source-file
.It Fl c, Fl -create-from Ar source-file
Create torrent from the specified source file.
.lt Fl a, Fl -announce Ar announce-url
Specifies the Announceurl the new torrent will use. Can only be
.It Fl a, Fl -announce Ar announce-url
Specifies the announce-url the new torrent will use. Can only be
used in conjunction with -c or --create-from.
.lt Fl r, Fl -private
.It Fl r, Fl -private
Sets the private flag for the new torrent. Can only be used in
conjunction with -c or --create-from.
.lt Fl m, Fl -comment Ar comment-text
.It Fl m, Fl -comment Ar comment-text
This optional parameter adds a comment to the new torrent. Can only
be used in conjunction with -c or --create-from.
.It Fl h, Fl -help
@ -72,6 +73,8 @@ Prints a short usage summary.
Shows information from the specified torrent file, such as the
cryptographic hash, the tracker, announcement, file size and file
name.
.It Fl o, Fl -output-dir Ar directory
Uses the specified directory as destination for downloaded data.
.It Fl s, -scrape
Prints the number of seeders and leechers for the specified torrent
file, and exits.
@ -95,7 +98,7 @@ Specifies a shell script to be executed upon successful download.
.Sh SIGNALS
In addition to these options, sending
.Nm
a SIGHUP signal can ask the tracker for more peers.
a SIGHUP signal will contact the tracker for more peers.
.El
.Sh FILES
.Bl -tag -width Ds -compact

View File

@ -41,7 +41,7 @@
#endif
const char * USAGE =
"Usage: %s [options] file.torrent [options]\n\n"
"Usage: %s [-car[-m]] [-dfinpsuv] [-h] file.torrent [output-dir]\n\n"
"Options:\n"
" -c, --create-from <file> Create torrent from the specified source file.\n"
" -a, --announce <url> Used in conjunction with -c.\n"
@ -65,7 +65,8 @@ static int verboseLevel = 0;
static int bindPort = TR_DEFAULT_PORT;
static int uploadLimit = 20;
static int downloadLimit = -1;
static char * torrentPath = NULL;
static char * torrentPath = NULL;
static char * savePath = ".";
static int natTraversal = 0;
static sig_atomic_t gotsig = 0;
static sig_atomic_t manualUpdate = 0;
@ -161,7 +162,7 @@ int main( int argc, char ** argv )
}
/* Open and parse torrent file */
if( !( tor = tr_torrentInit( h, torrentPath, ".", 0, &error ) ) )
if( !( tor = tr_torrentInit( h, torrentPath, savePath, 0, &error ) ) )
{
printf( "Failed opening torrent file `%s'\n", torrentPath );
tr_close( h );
@ -350,23 +351,24 @@ static int parseCommandLine( int argc, char ** argv )
for( ;; )
{
static struct option long_options[] =
{ { "help", no_argument, NULL, 'h' },
{ "info", no_argument, NULL, 'i' },
{ "scrape", no_argument, NULL, 's' },
{ "private", no_argument, NULL, 'r' },
{ "verbose", required_argument, NULL, 'v' },
{ "port", required_argument, NULL, 'p' },
{ "upload", required_argument, NULL, 'u' },
{ "download", required_argument, NULL, 'd' },
{ "finish", required_argument, NULL, 'f' },
{ "create", required_argument, NULL, 'c' },
{ "comment", required_argument, NULL, 'm' },
{ "announce", required_argument, NULL, 'a' },
{ "nat-traversal", no_argument, NULL, 'n' },
{ { "help", no_argument, NULL, 'h' },
{ "info", no_argument, NULL, 'i' },
{ "scrape", no_argument, NULL, 's' },
{ "private", no_argument, NULL, 'r' },
{ "verbose", required_argument, NULL, 'v' },
{ "port", required_argument, NULL, 'p' },
{ "upload", required_argument, NULL, 'u' },
{ "download", required_argument, NULL, 'd' },
{ "finish", required_argument, NULL, 'f' },
{ "create", required_argument, NULL, 'c' },
{ "comment", required_argument, NULL, 'm' },
{ "announce", required_argument, NULL, 'a' },
{ "nat-traversal", no_argument, NULL, 'n' },
{ "output-dir", required_argument, NULL, 'o' },
{ 0, 0, 0, 0} };
int c, optind = 0;
c = getopt_long( argc, argv, "hisrv:p:u:d:f:c:m:a:n",
c = getopt_long( argc, argv, "hisrv:p:u:d:f:c:m:a:n:o",
long_options, &optind );
if( c < 0 )
{
@ -413,12 +415,14 @@ static int parseCommandLine( int argc, char ** argv )
case 'n':
natTraversal = 1;
break;
case 'o':
savePath = optarg;
default:
return 1;
}
}
if( optind > argc - 1 )
if( optind >= argc )
{
return !showHelp;
}