updated file_win and file_pool error handling
This commit is contained in:
@@ -41,7 +41,8 @@ namespace libtorrent
|
||||
using boost::multi_index::nth_index;
|
||||
using boost::multi_index::get;
|
||||
|
||||
boost::shared_ptr<file> file_pool::open_file(void* st, fs::path const& p, file::open_mode m)
|
||||
boost::shared_ptr<file> file_pool::open_file(void* st, fs::path const& p
|
||||
, file::open_mode m, std::string& error)
|
||||
{
|
||||
TORRENT_ASSERT(st != 0);
|
||||
TORRENT_ASSERT(p.is_complete());
|
||||
@@ -57,14 +58,11 @@ namespace libtorrent
|
||||
|
||||
if (e.key != st)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
return boost::shared_ptr<file>();
|
||||
#else
|
||||
// this means that another instance of the storage
|
||||
// is using the exact same file.
|
||||
throw file_error("torrent uses the same file as another torrent "
|
||||
"(" + p.string() + ")");
|
||||
#endif
|
||||
error = "torrent uses the same file as another torrent "
|
||||
"(" + p.string() + ")";
|
||||
return boost::shared_ptr<file>();
|
||||
}
|
||||
|
||||
e.key = st;
|
||||
@@ -74,8 +72,13 @@ namespace libtorrent
|
||||
// the new read/write privilages
|
||||
i->file_ptr.reset();
|
||||
TORRENT_ASSERT(e.file_ptr.unique());
|
||||
e.file_ptr.reset();
|
||||
e.file_ptr.reset(new file(p, m));
|
||||
e.file_ptr->close();
|
||||
if (!e.file_ptr->open(p, m))
|
||||
{
|
||||
error = e.file_ptr->error();
|
||||
m_files.erase(i);
|
||||
return boost::shared_ptr<file>();
|
||||
}
|
||||
e.mode = m;
|
||||
}
|
||||
pt.replace(i, e);
|
||||
@@ -93,7 +96,18 @@ namespace libtorrent
|
||||
TORRENT_ASSERT(lt.size() == 1 || (i->last_use <= boost::next(i)->last_use));
|
||||
lt.erase(i);
|
||||
}
|
||||
lru_file_entry e(boost::shared_ptr<file>(new file(p, m)));
|
||||
lru_file_entry e;
|
||||
e.file_ptr.reset(new file);
|
||||
if (!e.file_ptr)
|
||||
{
|
||||
error = "no memory";
|
||||
return e.file_ptr;
|
||||
}
|
||||
if (!e.file_ptr->open(p, m))
|
||||
{
|
||||
error = e.file_ptr->error();
|
||||
return boost::shared_ptr<file>();
|
||||
}
|
||||
e.mode = m;
|
||||
e.key = st;
|
||||
e.file_path = p;
|
||||
|
Reference in New Issue
Block a user