Changeset 13800
- Timestamp:
- Jan 17, 2013, 6:55:51 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/makemeta.c
r13683 r13800 163 163 builderFileCompare); 164 164 165 ret->pieceSize = bestPieceSize (ret->totalSize); 166 ret->pieceCount = (int)(ret->totalSize / ret->pieceSize); 167 if (ret->totalSize % ret->pieceSize) 168 ++ret->pieceCount; 165 tr_metaInfoBuilderSetPieceSize (ret, bestPieceSize (ret->totalSize)); 169 166 170 167 return ret; 171 168 } 169 170 void 171 tr_metaInfoBuilderSetPieceSize (tr_metainfo_builder * b, 172 uint32_t bytes) 173 { 174 b->pieceSize = bytes; 175 176 b->pieceCount = (int)(b->totalSize / b->pieceSize); 177 if (b->totalSize % b->pieceSize) 178 ++b->pieceCount; 179 } 180 172 181 173 182 void -
trunk/libtransmission/makemeta.h
r13625 r13800 92 92 93 93 94 tr_metainfo_builder *tr_metaInfoBuilderCreate (const char * topFile);94 tr_metainfo_builder * tr_metaInfoBuilderCreate (const char * topFile); 95 95 96 void tr_metaInfoBuilderFree (tr_metainfo_builder*); 96 /** 97 * Call this before tr_makeMetaInfo() to override the builder.pieceSize 98 * and builder.pieceCount values that were set by tr_metainfoBuilderCreate() 99 */ 100 void tr_metaInfoBuilderSetPieceSize (tr_metainfo_builder * builder, 101 uint32_t bytes); 102 103 void tr_metaInfoBuilderFree (tr_metainfo_builder*); 97 104 98 105 /** -
trunk/utils/create.c
r13625 r13800 12 12 13 13 #include <errno.h> 14 #include <stdio.h> /* fprintf 15 #include <stdlib.h> /* EXIT_FAILURE */16 #include <unistd.h> /* getcwd 14 #include <stdio.h> /* fprintf() */ 15 #include <stdlib.h> /* strtoul(), EXIT_FAILURE */ 16 #include <unistd.h> /* getcwd() */ 17 17 18 18 #include <libtransmission/transmission.h> … … 25 25 26 26 #define MAX_TRACKERS 128 27 static const uint32_t KiB = 1024; 27 28 static tr_tracker_info trackers[MAX_TRACKERS]; 28 29 static int trackerCount = 0; 29 30 static bool isPrivate = false; 30 31 static bool showVersion = false; 31 const char * comment = NULL; 32 const char * outfile = NULL; 33 const char * infile = NULL; 32 static const char * comment = NULL; 33 static const char * outfile = NULL; 34 static const char * infile = NULL; 35 static uint32_t piecesize_kib = 0; 34 36 35 37 static tr_option options[] = … … 37 39 { 'p', "private", "Allow this torrent to only be used with the specified tracker(s)", "p", 0, NULL }, 38 40 { 'o', "outfile", "Save the generated .torrent to this filename", "o", 1, "<file>" }, 41 { 's', "piecesize", "Set how many KiB each piece should be, overriding the preferred default", "s", 1, "<size in KiB>" }, 39 42 { 'c', "comment", "Add a comment", "c", 1, "<comment>" }, 40 43 { 't', "tracker", "Add a tracker's announce URL", "t", 1, "<url>" }, … … 81 84 trackers[trackerCount].announce = (char*) optarg; 82 85 ++trackerCount; 86 } 87 break; 88 89 case 's': 90 if (optarg) 91 { 92 char * endptr = NULL; 93 piecesize_kib = strtoul (optarg, &endptr, 10); 94 if (endptr && *endptr=='M') 95 piecesize_kib *= KiB; 83 96 } 84 97 break; … … 170 183 171 184 b = tr_metaInfoBuilderCreate (infile); 185 186 if (piecesize_kib != 0) 187 tr_metaInfoBuilderSetPieceSize (b, piecesize_kib * KiB); 188 172 189 tr_makeMetaInfo (b, outfile, trackers, trackerCount, comment, isPrivate); 173 190 while (!b->isDone) -
trunk/utils/transmission-create.1
r12376 r13800 13 13 .Op Fl c Ar comment 14 14 .Op Fl t Ar tracker 15 .Op Fl s Ar piece-size-KiB 15 16 .Op Ar source file or directory 16 17 .Ek … … 28 29 .It Fl c Fl -comment 29 30 Add a comment to the torrent file. 31 .It Fl s Fl -piecesize 32 Set how many KiB each piece should be, overriding the preferred default 30 33 .It Fl t Fl -tracker 31 34 Add a tracker's
Note: See TracChangeset
for help on using the changeset viewer.