*** empty log message ***
This commit is contained in:
@@ -4,11 +4,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="generator" content="Docutils 0.3.1: http://docutils.sourceforge.net/" />
|
<meta name="generator" content="Docutils 0.3.1: http://docutils.sourceforge.net/" />
|
||||||
|
<title>libtorrent</title>
|
||||||
<link rel="stylesheet" href="style.css" type="text/css" />
|
<link rel="stylesheet" href="style.css" type="text/css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="document">
|
<div class="document" id="libtorrent">
|
||||||
<p><img alt="logo.png" src="logo.png" /></p>
|
<h1 class="title">libtorrent</h1>
|
||||||
<table border class="menu table">
|
<table border class="menu table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col width="26%" />
|
<col width="26%" />
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
.. image:: logo.png
|
==========
|
||||||
|
libtorrent
|
||||||
|
==========
|
||||||
|
|
||||||
|
|
||||||
.. class:: menu
|
.. class:: menu
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
<li><a class="reference" href="#hash-failed-alert" id="id29" name="id29">hash_failed_alert</a></li>
|
<li><a class="reference" href="#hash-failed-alert" id="id29" name="id29">hash_failed_alert</a></li>
|
||||||
<li><a class="reference" href="#peer-error-alert" id="id30" name="id30">peer_error_alert</a></li>
|
<li><a class="reference" href="#peer-error-alert" id="id30" name="id30">peer_error_alert</a></li>
|
||||||
<li><a class="reference" href="#invalid-request-alert" id="id31" name="id31">invalid_request_alert</a></li>
|
<li><a class="reference" href="#invalid-request-alert" id="id31" name="id31">invalid_request_alert</a></li>
|
||||||
<li><a class="reference" href="#chat-message-alert" id="id32" name="id32">chat_message_alert</a></li>
|
<li><a class="reference" href="#torrent-finished-alert" id="id32" name="id32">torrent_finished_alert</a></li>
|
||||||
<li><a class="reference" href="#dispatcher" id="id33" name="id33">dispatcher</a></li>
|
<li><a class="reference" href="#dispatcher" id="id33" name="id33">dispatcher</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
@@ -101,7 +101,8 @@ party.</li>
|
|||||||
of a resumed torrent. Saves the storage state, piece_picker state as well as all local
|
of a resumed torrent. Saves the storage state, piece_picker state as well as all local
|
||||||
peers in a separate fast-resume file.</li>
|
peers in a separate fast-resume file.</li>
|
||||||
<li>Supports the extension protocol <a class="reference" href="http://nolar.com/azureus/extended.htm">described by Nolar</a>. See <a class="reference" href="#extensions">extensions</a>.</li>
|
<li>Supports the extension protocol <a class="reference" href="http://nolar.com/azureus/extended.htm">described by Nolar</a>. See <a class="reference" href="#extensions">extensions</a>.</li>
|
||||||
<li>Supports files > 2 gigabytes (currently only on windows)</li>
|
<li>Supports files > 2 gigabytes (currently only on windows).</li>
|
||||||
|
<li>Supports the <tt class="literal"><span class="pre">no_peer_id=1</span></tt> extension that will ease the load off trackers.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<p>Functions that are yet to be implemented:</p>
|
<p>Functions that are yet to be implemented:</p>
|
||||||
@@ -1074,7 +1075,8 @@ struct peer_error_alert: alert
|
|||||||
</div>
|
</div>
|
||||||
<div class="section" id="invalid-request-alert">
|
<div class="section" id="invalid-request-alert">
|
||||||
<h2><a name="invalid-request-alert">invalid_request_alert</a></h2>
|
<h2><a name="invalid-request-alert">invalid_request_alert</a></h2>
|
||||||
<p>Thie is a debug alert that is generated by an incoming invalid piece request.</p>
|
<p>This is a debug alert that is generated by an incoming invalid piece request. It is
|
||||||
|
generated as severity level <tt class="literal"><span class="pre">debug</span></tt>.</p>
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
struct invalid_request_alert: alert
|
struct invalid_request_alert: alert
|
||||||
{
|
{
|
||||||
@@ -1092,27 +1094,46 @@ struct invalid_request_alert: alert
|
|||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="chat-message-alert">
|
<div class="section" id="torrent-finished-alert">
|
||||||
<h2><a name="chat-message-alert">chat_message_alert</a></h2>
|
<h2><a name="torrent-finished-alert">torrent_finished_alert</a></h2>
|
||||||
<p>This alert is generated when you receive a chat message from another peer. Chat messages
|
<p>This alert is generated when a torrent switches from being a downloader to a seed.
|
||||||
are supported as an extension ("chat"). It is generated as severity level <tt class="literal"><span class="pre">critical</span></tt>,
|
It will only be generated once per torrent. It contains a torrent_handle to the
|
||||||
even though it doesn't necessarily require any user intervention, it's high priority
|
torrent in question. This alert is generated as severity level <tt class="literal"><span class="pre">info</span></tt>.</p>
|
||||||
since you would almost never want to ignore such a message. The alert class contain
|
|
||||||
a <a class="reference" href="#torrent-handle">torrent_handle</a> to the torrent in which the sender-peer is a member and the peer_id
|
|
||||||
of the sending peer.</p>
|
|
||||||
<pre class="literal-block">
|
<pre class="literal-block">
|
||||||
struct chat_message_alert: alert
|
struct torrent_finished_alert: alert
|
||||||
{
|
{
|
||||||
chat_message_alert(const torrent_handle& h
|
torrent_finished_alert(
|
||||||
, const peer_id& sender
|
const torrent_handle& h
|
||||||
, const std::string& msg);
|
, const std::string& msg);
|
||||||
|
|
||||||
virtual std::auto_ptr<alert> clone() const;
|
virtual std::auto_ptr<alert> clone() const;
|
||||||
|
|
||||||
torrent_handle handle;
|
torrent_handle handle;
|
||||||
peer_id sender;
|
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
|
<!-- chat_message_alert
|
||||||
|
- - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
This alert is generated when you receive a chat message from another peer. Chat messages
|
||||||
|
are supported as an extension ("chat"). It is generated as severity level ``critical``,
|
||||||
|
even though it doesn't necessarily require any user intervention, it's high priority
|
||||||
|
since you would almost never want to ignore such a message. The alert class contain
|
||||||
|
a torrent_handle_ to the torrent in which the sender-peer is a member and the peer_id
|
||||||
|
of the sending peer.
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
struct chat_message_alert: alert
|
||||||
|
{
|
||||||
|
chat_message_alert(const torrent_handle& h
|
||||||
|
, const peer_id& sender
|
||||||
|
, const std::string& msg);
|
||||||
|
|
||||||
|
virtual std::auto_ptr<alert> clone() const;
|
||||||
|
|
||||||
|
torrent_handle handle;
|
||||||
|
peer_id sender;
|
||||||
|
}; -->
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="dispatcher">
|
<div class="section" id="dispatcher">
|
||||||
<h2><a name="dispatcher">dispatcher</a></h2>
|
<h2><a name="dispatcher">dispatcher</a></h2>
|
||||||
|
@@ -38,7 +38,8 @@ The current state includes the following features:
|
|||||||
of a resumed torrent. Saves the storage state, piece_picker state as well as all local
|
of a resumed torrent. Saves the storage state, piece_picker state as well as all local
|
||||||
peers in a separate fast-resume file.
|
peers in a separate fast-resume file.
|
||||||
* Supports the extension protocol `described by Nolar`__. See extensions_.
|
* Supports the extension protocol `described by Nolar`__. See extensions_.
|
||||||
* Supports files > 2 gigabytes (currently only on windows)
|
* Supports files > 2 gigabytes (currently only on windows).
|
||||||
|
* Supports the ``no_peer_id=1`` extension that will ease the load off trackers.
|
||||||
|
|
||||||
__ http://home.elp.rr.com/tur/multitracker-spec.txt
|
__ http://home.elp.rr.com/tur/multitracker-spec.txt
|
||||||
.. _Azureus: http://azureus.sourceforge.net
|
.. _Azureus: http://azureus.sourceforge.net
|
||||||
@@ -1127,7 +1128,8 @@ as severity level ``debug``.
|
|||||||
invalid_request_alert
|
invalid_request_alert
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
Thie is a debug alert that is generated by an incoming invalid piece request.
|
This is a debug alert that is generated by an incoming invalid piece request. It is
|
||||||
|
generated as severity level ``debug``.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
@@ -1147,32 +1149,52 @@ Thie is a debug alert that is generated by an incoming invalid piece request.
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
torrent_finished_alert
|
||||||
|
----------------------
|
||||||
|
|
||||||
chat_message_alert
|
This alert is generated when a torrent switches from being a downloader to a seed.
|
||||||
------------------
|
It will only be generated once per torrent. It contains a torrent_handle to the
|
||||||
|
torrent in question. This alert is generated as severity level ``info``.
|
||||||
This alert is generated when you receive a chat message from another peer. Chat messages
|
|
||||||
are supported as an extension ("chat"). It is generated as severity level ``critical``,
|
|
||||||
even though it doesn't necessarily require any user intervention, it's high priority
|
|
||||||
since you would almost never want to ignore such a message. The alert class contain
|
|
||||||
a torrent_handle_ to the torrent in which the sender-peer is a member and the peer_id
|
|
||||||
of the sending peer.
|
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
struct chat_message_alert: alert
|
struct torrent_finished_alert: alert
|
||||||
{
|
{
|
||||||
chat_message_alert(const torrent_handle& h
|
torrent_finished_alert(
|
||||||
, const peer_id& sender
|
const torrent_handle& h
|
||||||
, const std::string& msg);
|
, const std::string& msg);
|
||||||
|
|
||||||
virtual std::auto_ptr<alert> clone() const;
|
virtual std::auto_ptr<alert> clone() const;
|
||||||
|
|
||||||
torrent_handle handle;
|
torrent_handle handle;
|
||||||
peer_id sender;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
.. chat_message_alert
|
||||||
|
------------------
|
||||||
|
|
||||||
|
This alert is generated when you receive a chat message from another peer. Chat messages
|
||||||
|
are supported as an extension ("chat"). It is generated as severity level ``critical``,
|
||||||
|
even though it doesn't necessarily require any user intervention, it's high priority
|
||||||
|
since you would almost never want to ignore such a message. The alert class contain
|
||||||
|
a torrent_handle_ to the torrent in which the sender-peer is a member and the peer_id
|
||||||
|
of the sending peer.
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
struct chat_message_alert: alert
|
||||||
|
{
|
||||||
|
chat_message_alert(const torrent_handle& h
|
||||||
|
, const peer_id& sender
|
||||||
|
, const std::string& msg);
|
||||||
|
|
||||||
|
virtual std::auto_ptr<alert> clone() const;
|
||||||
|
|
||||||
|
torrent_handle handle;
|
||||||
|
peer_id sender;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
dispatcher
|
dispatcher
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
@@ -122,7 +122,6 @@ namespace libtorrent
|
|||||||
peer_request request;
|
peer_request request;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: document
|
|
||||||
struct torrent_finished_alert: alert
|
struct torrent_finished_alert: alert
|
||||||
{
|
{
|
||||||
torrent_finished_alert(
|
torrent_finished_alert(
|
||||||
|
@@ -65,7 +65,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/size_type.hpp"
|
#include "libtorrent/size_type.hpp"
|
||||||
|
|
||||||
|
@@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/size_type.hpp"
|
#include "libtorrent/size_type.hpp"
|
||||||
|
|
||||||
|
@@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <boost/limits.hpp>
|
#include <boost/limits.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/torrent_info.hpp"
|
#include "libtorrent/torrent_info.hpp"
|
||||||
#include "libtorrent/opaque_value_ptr.hpp"
|
#include "libtorrent/opaque_value_ptr.hpp"
|
||||||
|
@@ -42,7 +42,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <boost/limits.hpp>
|
#include <boost/limits.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/torrent_handle.hpp"
|
#include "libtorrent/torrent_handle.hpp"
|
||||||
#include "libtorrent/entry.hpp"
|
#include "libtorrent/entry.hpp"
|
||||||
|
@@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
|
|
||||||
#include "libtorrent/peer_id.hpp"
|
#include "libtorrent/peer_id.hpp"
|
||||||
#include "libtorrent/peer_info.hpp"
|
#include "libtorrent/peer_info.hpp"
|
||||||
|
@@ -36,13 +36,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
#include "libtorrent/entry.hpp"
|
#include "libtorrent/entry.hpp"
|
||||||
#include "libtorrent/socket.hpp"
|
#include "libtorrent/socket.hpp"
|
||||||
#include "libtorrent/peer_id.hpp"
|
#include "libtorrent/peer_id.hpp"
|
||||||
|
#include "libtorrent/size_type.hpp"
|
||||||
|
|
||||||
#include "boost/date_time/posix_time/posix_time.hpp"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file declares the following functions:
|
* This file declares the following functions:
|
||||||
@@ -59,7 +59,7 @@ namespace libtorrent
|
|||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
boost::int64_t size;
|
size_type size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct announce_entry
|
struct announce_entry
|
||||||
|
@@ -59,10 +59,6 @@ namespace libtorrent
|
|||||||
const file::seek_mode file::begin(1);
|
const file::seek_mode file::begin(1);
|
||||||
const file::seek_mode file::end(2);
|
const file::seek_mode file::end(2);
|
||||||
|
|
||||||
// TODO: this implementation will behave strange if
|
|
||||||
// a file is opened for both reading and writing
|
|
||||||
// and both read from and written to. Since the
|
|
||||||
// write-file position isn't updated when reading.
|
|
||||||
struct file::impl
|
struct file::impl
|
||||||
{
|
{
|
||||||
impl(): m_open_mode(0) {}
|
impl(): m_open_mode(0) {}
|
||||||
|
198
src/file_win.cpp
198
src/file_win.cpp
@@ -1,55 +1,117 @@
|
|||||||
#include <windows.h>
|
/*
|
||||||
#include "libtorrent/file.hpp"
|
|
||||||
|
|
||||||
|
Copyright (c) 2003, Magnus Jonsson
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the author nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libtorrent/file.hpp"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#define DWORD_MAX 0xffffffffu
|
#define DWORD_MAX 0xffffffffu
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace
|
||||||
|
{
|
||||||
|
void throw_exception(const char* thrower)
|
||||||
|
{
|
||||||
|
char buffer[1024];
|
||||||
|
int err = GetLastError();
|
||||||
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, err, 0, buffer, 0, 0);
|
||||||
|
std::stringstream s;
|
||||||
|
s << thrower << ": " << buffer;
|
||||||
|
throw libtorrent::file_error(s.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
|
||||||
struct file::impl : boost::noncopyable
|
struct file::impl : boost::noncopyable
|
||||||
{
|
{
|
||||||
enum open_flags { read_flag=1,
|
enum open_flags
|
||||||
write_flag=2 };
|
{
|
||||||
enum seek_mode { seek_begin=FILE_BEGIN,
|
read_flag = 1,
|
||||||
seek_from_here=FILE_CURRENT,
|
write_flag = 2
|
||||||
seek_end=FILE_END };
|
};
|
||||||
|
|
||||||
|
enum seek_mode
|
||||||
|
{
|
||||||
|
seek_begin = FILE_BEGIN,
|
||||||
|
seek_from_here = FILE_CURRENT,
|
||||||
|
seek_end = FILE_END
|
||||||
|
};
|
||||||
|
|
||||||
impl()
|
impl()
|
||||||
{
|
{
|
||||||
m_file_handle=INVALID_HANDLE_VALUE;
|
m_file_handle = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void open(const char *file_name, open_flags flags)
|
void open(const char *file_name, open_flags flags)
|
||||||
{
|
{
|
||||||
assert(file_name);
|
assert(file_name);
|
||||||
assert(flags&(read_flag|write_flag));
|
assert(flags & (read_flag | write_flag));
|
||||||
|
|
||||||
DWORD access_mask=0;
|
DWORD access_mask = 0;
|
||||||
if (flags&read_flag)
|
if (flags & read_flag)
|
||||||
access_mask|=GENERIC_READ;
|
access_mask |= GENERIC_READ;
|
||||||
if (flags&write_flag)
|
if (flags & write_flag)
|
||||||
access_mask|=GENERIC_WRITE;
|
access_mask |= GENERIC_WRITE;
|
||||||
|
|
||||||
assert(access_mask&(GENERIC_READ|GENERIC_WRITE));
|
assert(access_mask & (GENERIC_READ | GENERIC_WRITE));
|
||||||
|
|
||||||
HANDLE new_handle=CreateFile(file_name,access_mask,FILE_SHARE_READ,NULL,
|
HANDLE new_handle = CreateFile(
|
||||||
OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
|
file_name
|
||||||
|
, access_mask
|
||||||
|
, FILE_SHARE_READ
|
||||||
|
, NULL
|
||||||
|
, OPEN_ALWAYS
|
||||||
|
, FILE_ATTRIBUTE_NORMAL
|
||||||
|
, NULL);
|
||||||
|
|
||||||
if (new_handle==INVALID_HANDLE_VALUE)
|
if (new_handle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
throw file_error("could not open file");
|
std::stringstream s;
|
||||||
|
s << "couldn't open file '" << file_name << "'";
|
||||||
|
throw file_error(s.str());
|
||||||
}
|
}
|
||||||
// will only close old file if the open succeeded
|
// will only close old file if the open succeeded
|
||||||
close();
|
close();
|
||||||
m_file_handle=new_handle;
|
m_file_handle = new_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void close()
|
void close()
|
||||||
{
|
{
|
||||||
if (m_file_handle!=INVALID_HANDLE_VALUE)
|
if (m_file_handle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
CloseHandle(m_file_handle);
|
CloseHandle(m_file_handle);
|
||||||
m_file_handle=INVALID_HANDLE_VALUE;
|
m_file_handle = INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,13 +123,20 @@ namespace libtorrent {
|
|||||||
size_type write(const char* buffer, size_type num_bytes)
|
size_type write(const char* buffer, size_type num_bytes)
|
||||||
{
|
{
|
||||||
assert(buffer);
|
assert(buffer);
|
||||||
assert(num_bytes>0);
|
assert(num_bytes > 0);
|
||||||
assert((DWORD)num_bytes==num_bytes);
|
assert((DWORD)num_bytes == num_bytes);
|
||||||
DWORD bytes_written=0;
|
DWORD bytes_written = 0;
|
||||||
if (num_bytes!=0)
|
if (num_bytes != 0)
|
||||||
{
|
{
|
||||||
if (FALSE == WriteFile(m_file_handle,buffer,(DWORD)num_bytes,&bytes_written,NULL))
|
if (FALSE == WriteFile(
|
||||||
throw file_error("file::impl::write: couldn't write to file");
|
m_file_handle
|
||||||
|
, buffer
|
||||||
|
, (DWORD)num_bytes
|
||||||
|
, &bytes_written
|
||||||
|
, NULL))
|
||||||
|
{
|
||||||
|
throw_exception("file::write");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return bytes_written;
|
return bytes_written;
|
||||||
}
|
}
|
||||||
@@ -75,59 +144,84 @@ namespace libtorrent {
|
|||||||
size_type read(char* buffer, size_type num_bytes)
|
size_type read(char* buffer, size_type num_bytes)
|
||||||
{
|
{
|
||||||
assert(buffer);
|
assert(buffer);
|
||||||
assert(num_bytes>0);
|
assert(num_bytes > 0);
|
||||||
assert((DWORD)num_bytes==num_bytes);
|
assert((DWORD)num_bytes == num_bytes);
|
||||||
|
|
||||||
DWORD bytes_read=0;
|
DWORD bytes_read = 0;
|
||||||
if (num_bytes!=0)
|
if (num_bytes != 0)
|
||||||
{
|
{
|
||||||
if (FALSE == ReadFile(m_file_handle,buffer,(DWORD)num_bytes,&bytes_read,NULL))
|
if (FALSE == ReadFile(
|
||||||
throw file_error("file::impl::read: couldn't write to file");
|
m_file_handle
|
||||||
|
, buffer
|
||||||
|
, (DWORD)num_bytes
|
||||||
|
, &bytes_read
|
||||||
|
, NULL))
|
||||||
|
{
|
||||||
|
throw_exception("file::read");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return bytes_read;
|
return bytes_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
void seek(size_type pos, seek_mode from_where)
|
void seek(size_type pos, seek_mode from_where)
|
||||||
{
|
{
|
||||||
assert(pos>=0);
|
assert(pos >= 0);
|
||||||
LARGE_INTEGER offs;
|
LARGE_INTEGER offs;
|
||||||
offs.QuadPart=pos;
|
offs.QuadPart = pos;
|
||||||
// FILE_CURRENT
|
// FILE_CURRENT
|
||||||
// FILE_END
|
// FILE_END
|
||||||
if (FALSE == SetFilePointerEx(m_file_handle,offs,&offs,from_where))
|
if (FALSE == SetFilePointerEx(
|
||||||
throw file_error("file::impl::seek: error");
|
m_file_handle
|
||||||
|
, offs
|
||||||
|
, &offs
|
||||||
|
, from_where))
|
||||||
|
{
|
||||||
|
throw_exception("file::seek");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type tell()
|
size_type tell()
|
||||||
{
|
{
|
||||||
LARGE_INTEGER offs;
|
LARGE_INTEGER offs;
|
||||||
offs.QuadPart=0;
|
offs.QuadPart = 0;
|
||||||
|
|
||||||
// is there any other way to get offset?
|
// is there any other way to get offset?
|
||||||
if (FALSE == SetFilePointerEx(m_file_handle,offs,&offs,FILE_CURRENT))
|
if (FALSE == SetFilePointerEx(
|
||||||
throw file_error("file::impl::tell: error");
|
m_file_handle
|
||||||
|
, offs
|
||||||
|
, &offs
|
||||||
|
, FILE_CURRENT))
|
||||||
|
{
|
||||||
|
throw_exception("file::tell");
|
||||||
|
}
|
||||||
|
|
||||||
size_type pos=offs.QuadPart;
|
size_type pos=offs.QuadPart;
|
||||||
assert(pos>=0);
|
assert(pos>=0);
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
size_type size()
|
size_type size()
|
||||||
{
|
{
|
||||||
LARGE_INTEGER s;
|
LARGE_INTEGER s;
|
||||||
if (FALSE == GetFileSizeEx(m_file_handle,&s))
|
if (FALSE == GetFileSizeEx(m_file_handle, &s))
|
||||||
throw file_error("file::impl::size: error");
|
{
|
||||||
|
throw_exception("file::size");
|
||||||
|
}
|
||||||
|
|
||||||
size_type size=s.QuadPart;
|
size_type size = s.QuadPart;
|
||||||
assert(size>=0);
|
assert(size >= 0);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
private:
|
private:
|
||||||
|
|
||||||
HANDLE m_file_handle;
|
HANDLE m_file_handle;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
|
||||||
const file::seek_mode file::begin(file::impl::seek_begin);
|
const file::seek_mode file::begin(file::impl::seek_begin);
|
||||||
const file::seek_mode file::end(file::impl::seek_end);
|
const file::seek_mode file::end(file::impl::seek_end);
|
||||||
@@ -151,7 +245,7 @@ namespace libtorrent {
|
|||||||
|
|
||||||
void file::open(boost::filesystem::path const& p, open_mode m)
|
void file::open(boost::filesystem::path const& p, open_mode m)
|
||||||
{
|
{
|
||||||
m_impl->open(p.native_file_string().c_str(),impl::open_flags(m.m_mask));
|
m_impl->open(p.native_file_string().c_str(), impl::open_flags(m.m_mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
void file::close()
|
void file::close()
|
||||||
@@ -161,12 +255,12 @@ namespace libtorrent {
|
|||||||
|
|
||||||
size_type file::write(const char* buffer, size_type num_bytes)
|
size_type file::write(const char* buffer, size_type num_bytes)
|
||||||
{
|
{
|
||||||
return m_impl->write(buffer,num_bytes);
|
return m_impl->write(buffer, num_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type file::read(char* buffer, size_type num_bytes)
|
size_type file::read(char* buffer, size_type num_bytes)
|
||||||
{
|
{
|
||||||
return m_impl->read(buffer,num_bytes);
|
return m_impl->read(buffer, num_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void file::seek(size_type pos, seek_mode m)
|
void file::seek(size_type pos, seek_mode m)
|
||||||
@@ -178,4 +272,4 @@ namespace libtorrent {
|
|||||||
{
|
{
|
||||||
return m_impl->tell();
|
return m_impl->tell();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -680,7 +680,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
m_torrent->filesystem().write(&m_recv_buffer[9], p.piece, p.start, p.length);
|
m_torrent->filesystem().write(&m_recv_buffer[9], p.piece, p.start, p.length);
|
||||||
|
|
||||||
bool was_seed = is_seed();
|
bool was_seed = m_torrent->is_seed();
|
||||||
|
|
||||||
picker.mark_as_finished(block_finished, m_socket->sender());
|
picker.mark_as_finished(block_finished, m_socket->sender());
|
||||||
|
|
||||||
@@ -702,10 +702,10 @@ namespace libtorrent
|
|||||||
}
|
}
|
||||||
m_torrent->get_policy().piece_finished(p.piece, verified);
|
m_torrent->get_policy().piece_finished(p.piece, verified);
|
||||||
|
|
||||||
if (!was_seed && is_seed())
|
if (!was_seed && m_torrent->is_seed())
|
||||||
{
|
{
|
||||||
assert(verified);
|
assert(verified);
|
||||||
if (m_torrent->alerts().should_post(alert::warning))
|
if (m_torrent->alerts().should_post(alert::info))
|
||||||
{
|
{
|
||||||
m_torrent->alerts().post_alert(torrent_finished_alert(
|
m_torrent->alerts().post_alert(torrent_finished_alert(
|
||||||
m_torrent->get_handle()
|
m_torrent->get_handle()
|
||||||
|
Reference in New Issue
Block a user