Merge branch 'RC_1_1'
This commit is contained in:
commit
dec093dc1a
|
@ -750,7 +750,7 @@ class*. There are a few default peer classes that are always created:
|
|||
|
||||
* global - all peers belong to this class, except peers on the local network
|
||||
* local peers - all peers on the local network belongs to this class TCP peers
|
||||
* - all peers connected over TCP belong to this class
|
||||
* tcp class - all peers connected over TCP belong to this class
|
||||
|
||||
The TCP peers class is used by the uTP/TCP balancing logic, if it's enabled, to
|
||||
throttle TCP peers. The global and local classes are used to adjust the global
|
||||
|
|
|
@ -1006,7 +1006,7 @@ namespace libtorrent
|
|||
// +1 is here to make it possible to distinguish uninitialized (to
|
||||
// 0) timestamps and timestamps of things that happend during the
|
||||
// first second after the session was constructed
|
||||
boost::int64_t const ret = total_seconds(aux::time_now() - m_created) + 1;
|
||||
boost::int64_t const ret = total_seconds(clock_type::now() - m_created) + 1;
|
||||
TORRENT_ASSERT(ret >= 0);
|
||||
TORRENT_ASSERT(ret <= (std::numeric_limits<boost::uint16_t>::max)());
|
||||
return static_cast<boost::uint16_t>(ret);
|
||||
|
|
|
@ -34,13 +34,10 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#define TORRENT_CREATE_TORRENT_HPP_INCLUDED
|
||||
|
||||
#include "libtorrent/bencode.hpp"
|
||||
#include "libtorrent/peer_id.hpp"
|
||||
#include "libtorrent/file_storage.hpp"
|
||||
#include "libtorrent/config.hpp"
|
||||
#include "libtorrent/storage.hpp"
|
||||
#include "libtorrent/hasher.hpp"
|
||||
#include "libtorrent/utf8.hpp"
|
||||
#include "libtorrent/allocator.hpp"
|
||||
#include "libtorrent/file.hpp" // for combine_path etc.
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||
|
@ -49,7 +46,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||
|
@ -68,7 +64,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
// and set the piece hashes.
|
||||
// 4. The torrent is bencoded into a file or buffer.
|
||||
//
|
||||
// If there are a lot of files and or deep directoy hierarchies to
|
||||
// If there are a lot of files and or deep directory hierarchies to
|
||||
// traverse, step one can be time consuming.
|
||||
//
|
||||
// Typically step 3 is by far the most time consuming step, since it
|
||||
|
@ -156,7 +152,7 @@ namespace libtorrent
|
|||
// piece_size will be calculated such that the torrent file is roughly 40 kB.
|
||||
//
|
||||
// If a ``pad_size_limit`` is specified (other than -1), any file larger than
|
||||
// the specified number of bytes will be preceeded by a pad file to align it
|
||||
// the specified number of bytes will be preceded by a pad file to align it
|
||||
// with the start of a piece. The pad_file_limit is ignored unless the
|
||||
// ``optimize_alignment`` flag is passed. Typically it doesn't make sense
|
||||
// to set this any lower than 4kiB.
|
||||
|
@ -267,7 +263,7 @@ namespace libtorrent
|
|||
|
||||
// Sets and queries the private flag of the torrent.
|
||||
// Torrents with the private flag set ask clients to not use any other
|
||||
// sources than the tracker for peers, and to not advertize itself publicly,
|
||||
// sources than the tracker for peers, and to not advertise itself publicly,
|
||||
// apart from the tracker.
|
||||
void set_priv(bool p) { m_private = p; }
|
||||
bool priv() const { return m_private; }
|
||||
|
@ -382,17 +378,17 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
// Adds the file specified by ``path`` to the file_storage object. In case ``path``
|
||||
// refers to a diretory, files will be added recursively from the directory.
|
||||
// refers to a directory, files will be added recursively from the directory.
|
||||
//
|
||||
// If specified, the predicate ``p`` is called once for every file and directory that
|
||||
// is encountered. files for which ``p`` returns true are added, and directories for
|
||||
// is encountered. Files for which ``p`` returns true are added, and directories for
|
||||
// which ``p`` returns true are traversed. ``p`` must have the following signature::
|
||||
//
|
||||
// bool Pred(std::string const& p);
|
||||
//
|
||||
// The path that is passed in to the predicate is the full path of the file or
|
||||
// directory. If no predicate is specified, all files are added, and all directories
|
||||
// are traveresed.
|
||||
// are traversed.
|
||||
//
|
||||
// The ".." directory is never traversed.
|
||||
//
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace libtorrent
|
|||
{
|
||||
// libtorrent uses boost.system's ``error_code`` class to represent
|
||||
// errors. libtorrent has its own error category
|
||||
// get_libtorrent_category() whith the error codes defined by
|
||||
// get_libtorrent_category() with the error codes defined by
|
||||
// error_code_enum.
|
||||
enum error_code_enum
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ namespace libtorrent
|
|||
invalid_entry_type,
|
||||
// The specified URI does not contain a valid info-hash
|
||||
missing_info_hash_in_uri,
|
||||
// One of the files in the torrent was unexpectadly small. This
|
||||
// One of the files in the torrent was unexpectedly small. This
|
||||
// might be caused by files being changed by an external process
|
||||
file_too_short,
|
||||
// The URL used an unknown protocol. Currently ``http`` and
|
||||
|
@ -122,7 +122,7 @@ namespace libtorrent
|
|||
url_parse_error,
|
||||
// The peer sent a 'piece' message of length 0
|
||||
peer_sent_empty_piece,
|
||||
// A bencoded structure was currupt and failed to be parsed
|
||||
// A bencoded structure was corrupt and failed to be parsed
|
||||
parse_failed,
|
||||
// The fast resume file was missing or had an invalid file version
|
||||
// tag
|
||||
|
@ -216,7 +216,7 @@ namespace libtorrent
|
|||
invalid_reject,
|
||||
// The peer sent an invalid allow fast-message
|
||||
invalid_allow_fast,
|
||||
// The peer sent an invalid extesion message ID
|
||||
// The peer sent an invalid extension message ID
|
||||
invalid_extended,
|
||||
// The peer sent an invalid message ID
|
||||
invalid_message,
|
||||
|
@ -260,7 +260,7 @@ namespace libtorrent
|
|||
// The web seed redirected to a path that no longer matches the
|
||||
// .torrent directory structure
|
||||
invalid_redirection,
|
||||
// The connection was closed becaused it redirected to a different
|
||||
// The connection was closed because it redirected to a different
|
||||
// URL
|
||||
redirecting,
|
||||
// The HTTP range header is invalid
|
||||
|
@ -314,7 +314,7 @@ namespace libtorrent
|
|||
// This happens for magnet links before they have downloaded the
|
||||
// metadata, and also torrents added by URL.
|
||||
no_metadata,
|
||||
// The peer sent an invalid ``dont_have`` message. The dont have
|
||||
// The peer sent an invalid ``dont_have`` message. The don't have
|
||||
// message is an extension to allow peers to advertise that the
|
||||
// no longer has a piece they previously had.
|
||||
invalid_dont_have,
|
||||
|
|
|
@ -63,7 +63,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
// mutex locked. And they are always called from the libtorrent network thread. In
|
||||
// case portions of your plugin are called from other threads, typically the main
|
||||
// thread, you cannot use any of the member functions on the internal structures
|
||||
// in libtorrent, since those require the mutex to be locked. Futhermore, you would
|
||||
// in libtorrent, since those require the mutex to be locked. Furthermore, you would
|
||||
// also need to have a mutex on your own shared data within the plugin, to make
|
||||
// sure it is not accessed at the same time from the libtorrent thread (through a
|
||||
// callback). See `boost thread's mutex`_. If you need to send out a message from
|
||||
|
@ -71,7 +71,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
// sending in ``tick()``.
|
||||
//
|
||||
// Since the plugin interface gives you easy access to internal structures, it
|
||||
// is not supported as a stable API. Plugins should be considered spcific to a
|
||||
// is not supported as a stable API. Plugins should be considered specific to a
|
||||
// specific version of libtorrent. Although, in practice the internals mostly
|
||||
// don't change that dramatically.
|
||||
//
|
||||
|
@ -150,7 +150,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
// of simply allocating a new instance as a copy of ``*this`` is all that's
|
||||
// expected.
|
||||
//
|
||||
// The static category is required for checking wether or not the category
|
||||
// The static category is required for checking whether or not the category
|
||||
// for a specific alert is enabled or not, without instantiating the alert.
|
||||
// The ``category`` virtual function is the run-time equivalence.
|
||||
//
|
||||
|
|
|
@ -253,7 +253,7 @@ namespace libtorrent
|
|||
// this file has the executable attribute set.
|
||||
attribute_executable = 4,
|
||||
|
||||
// this file is a symbilic link. It should have a link
|
||||
// this file is a symbolic link. It should have a link
|
||||
// target string associated with it.
|
||||
attribute_symlink = 8
|
||||
};
|
||||
|
@ -269,7 +269,7 @@ namespace libtorrent
|
|||
// being added. This memory is *borrowed*, i.e. it is the caller's
|
||||
// responsibility to make sure it stays valid throughout the lifetime
|
||||
// of this file_storage object or any copy of it. The same thing applies
|
||||
// to ``filehash``, wich is an optional pointer to a 20 byte binary
|
||||
// to ``filehash``, which is an optional pointer to a 20 byte binary
|
||||
// SHA-1 hash of the file.
|
||||
//
|
||||
// if ``filename`` is NULL, the filename from ``path`` is used and not
|
||||
|
|
|
@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include "libtorrent/create_torrent.hpp"
|
||||
#include "libtorrent/utf8.hpp"
|
||||
#include "libtorrent/file_pool.hpp"
|
||||
#include "libtorrent/storage.hpp"
|
||||
#include "libtorrent/aux_/escape_string.hpp" // for convert_to_wstring
|
||||
|
@ -262,6 +263,12 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
if (t.files().total_size() == 0)
|
||||
{
|
||||
ec = error_code(errors::torrent_invalid_length, get_libtorrent_category());
|
||||
return;
|
||||
}
|
||||
|
||||
// dummy torrent object pointer
|
||||
boost::shared_ptr<char> dummy;
|
||||
counters cnt;
|
||||
|
|
|
@ -987,16 +987,18 @@ namespace libtorrent
|
|||
stat_file(save_path, &s, e);
|
||||
if (e == boost::system::errc::no_such_file_or_directory)
|
||||
{
|
||||
create_directories(save_path, ec.ec);
|
||||
if (ec)
|
||||
create_directories(save_path, e);
|
||||
if (e)
|
||||
{
|
||||
ec.ec = e;
|
||||
ec.file = -1;
|
||||
ec.operation = storage_error::mkdir;
|
||||
return piece_manager::fatal_disk_error;
|
||||
}
|
||||
}
|
||||
else if (ec)
|
||||
else if (e)
|
||||
{
|
||||
ec.ec = e;
|
||||
ec.file = -1;
|
||||
ec.operation = storage_error::mkdir;
|
||||
return piece_manager::fatal_disk_error;
|
||||
|
|
|
@ -261,7 +261,18 @@ TORRENT_TEST(torrent)
|
|||
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&tmp[0], tmp.size(), boost::ref(ec), 0));
|
||||
test_running_torrent(info, 0);
|
||||
}
|
||||
}
|
||||
|
||||
TORRENT_TEST(torrent_total_size_zero)
|
||||
{
|
||||
file_storage fs;
|
||||
|
||||
fs.add_file("test_torrent_dir2/tmp1", 0);
|
||||
libtorrent::create_torrent t(fs);
|
||||
|
||||
error_code ec;
|
||||
set_piece_hashes(t, ".", ec);
|
||||
TEST_CHECK(ec);
|
||||
}
|
||||
|
||||
TORRENT_TEST(rename_file)
|
||||
|
|
Loading…
Reference in New Issue