~ubuntu-branches/ubuntu/oneiric/libtorrent-rasterbar/oneiric

« back to all changes in this revision

Viewing changes to examples/make_torrent.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2010-08-10 12:57:25 UTC
  • mfrom: (1.3.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125725-i2o9iblow20w7qde
Tags: 0.15.1-0ubuntu1
* New upstream point release.

* New package libtorrent-rasterbar6 (bump up library soname). (LP: #615950)
 - Must Conflict/Replace libtorrent-rasterbar5 (= 0.15.0-0ubuntu1) or it will
   fail to install trying to overwrite '/usr/lib/libtorrent-rasterbar.so.6.0.0'

* Sync on git.debian.org/collab-maint/libtorrent-rasterbar.git:
 - debian/{control,rules}: Bump debhelper build-dep to (>= 7.4.10)
   and pass to dh in order to enable parallel build support.
 - debian/watch: Use googlecode.debian.net redirector.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
                "            than bytes will be piece-aligned\n"
77
77
                "-s bytes    specifies a piece size for the torrent\n"
78
78
                "            This has to be a multiple of 16 kiB\n"
 
79
                "-l          Don't follow symlinks, instead encode them as\n"
 
80
                "            links in the torrent file\n"
 
81
                "-o file     specifies the output filename of the torrent file\n"
 
82
                "            If this is not specified, the torrent file is\n"
 
83
                "            printed to the standard out, except on windows\n"
 
84
                "            where the filename defaults to a.torrent\n"
79
85
                , stderr);
80
86
}
81
87
 
102
108
                int piece_size = 0;
103
109
                int flags = 0;
104
110
 
 
111
                std::string outfile;
 
112
#ifdef TORRENT_WINDOWS
 
113
                // don't ever write binary data to the console on windows
 
114
                // it will just be interpreted as text and corrupted
 
115
                outfile = "a.torrent";
 
116
#endif
 
117
 
105
118
                for (int i = 2; i < argc; ++i)
106
119
                {
107
120
                        if (argv[i][0] != '-')
132
145
                                case 'm':
133
146
                                        flags |= create_torrent::merkle;
134
147
                                        break;
 
148
                                case 'o':
 
149
                                        ++i;
 
150
                                        outfile = argv[i];
 
151
                                        break;
 
152
                                case 'l':
 
153
                                        flags |= create_torrent::symlinks;
 
154
                                        break;
135
155
                                default:
136
156
                                        print_usage();
137
157
                                        return 1;
142
162
                file_pool fp;
143
163
                path full_path = complete(path(argv[1]));
144
164
 
145
 
                add_files(fs, full_path, file_filter);
 
165
                add_files(fs, full_path, file_filter, flags);
146
166
                if (fs.num_files() == 0)
147
167
                {
148
168
                        fputs("no files specified.\n", stderr);
173
193
                // create the torrent and print it to stdout
174
194
                std::vector<char> torrent;
175
195
                bencode(back_inserter(torrent), t.generate());
176
 
                fwrite(&torrent[0], 1, torrent.size(), stdout);
 
196
                FILE* output = stdout;
 
197
                if (!outfile.empty())
 
198
                        output = fopen(outfile.c_str(), "wb+");
 
199
                fwrite(&torrent[0], 1, torrent.size(), output);
 
200
 
 
201
                if (output != stdout)
 
202
                        fclose(output);
177
203
 
178
204
#ifndef BOOST_NO_EXCEPTIONS
179
205
        }