reverted part of the file_storage API to match the previous one more closly
This commit is contained in:
@@ -48,11 +48,9 @@ namespace
|
||||
ct.add_node(std::make_pair(addr, port));
|
||||
}
|
||||
|
||||
void add_file(file_storage& ct, file_entry const& fe
|
||||
, std::string const& hash, std::string const& linkpath)
|
||||
void add_file(file_storage& ct, file_entry const& fe)
|
||||
{
|
||||
ct.add_file(fe, hash.empty() ? 0 : hash.c_str()
|
||||
, linkpath.empty() ? 0 : &linkpath);
|
||||
ct.add_file(fe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,21 +71,23 @@ void bind_create_torrent()
|
||||
#endif
|
||||
void (*add_files0)(file_storage&, std::string const&, boost::uint32_t) = add_files;
|
||||
|
||||
file_entry (file_storage::*at)(int) const = &file_storage::at;
|
||||
|
||||
class_<file_storage>("file_storage")
|
||||
.def("is_valid", &file_storage::is_valid)
|
||||
.def("add_file", add_file, (arg("entry"), arg("hash") = std::string(), arg("symlink") = std::string()))
|
||||
.def("add_file", add_file, arg("entry"))
|
||||
.def("add_file", add_file0, (arg("path"), arg("size"), arg("flags") = 0, arg("mtime") = 0, arg("linkpath") = ""))
|
||||
#if TORRENT_USE_WSTRING
|
||||
.def("add_file", add_file1, (arg("path"), arg("size"), arg("flags") = 0, arg("mtime") = 0, arg("linkpath") = ""))
|
||||
#endif
|
||||
.def("num_files", &file_storage::num_files)
|
||||
.def("at", &file_storage::at, return_internal_reference<>())
|
||||
.def("hash", &file_storage::hash)
|
||||
.def("symlink", &file_storage::symlink, return_internal_reference<>())
|
||||
.def("file_index", &file_storage::file_index)
|
||||
.def("file_base", &file_storage::file_base)
|
||||
.def("set_file_base", &file_storage::set_file_base)
|
||||
.def("file_path", &file_storage::file_path)
|
||||
.def("at", at)
|
||||
// .def("hash", &file_storage::hash)
|
||||
// .def("symlink", &file_storage::symlink, return_internal_reference<>())
|
||||
// .def("file_index", &file_storage::file_index)
|
||||
// .def("file_base", &file_storage::file_base)
|
||||
// .def("set_file_base", &file_storage::set_file_base)
|
||||
// .def("file_path", &file_storage::file_path)
|
||||
.def("total_size", &file_storage::total_size)
|
||||
.def("set_num_pieces", &file_storage::set_num_pieces)
|
||||
.def("num_pieces", &file_storage::num_pieces)
|
||||
|
@@ -55,10 +55,10 @@ namespace
|
||||
list files(torrent_info const& ti, bool storage) {
|
||||
list result;
|
||||
|
||||
typedef std::vector<file_entry> list_type;
|
||||
typedef torrent_info::file_iterator iter;
|
||||
|
||||
for (list_type::const_iterator i = ti.begin_files(); i != ti.end_files(); ++i)
|
||||
result.append(*i);
|
||||
for (iter i = ti.begin_files(); i != ti.end_files(); ++i)
|
||||
result.append(ti.files().at(i));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ void bind_torrent_info()
|
||||
.def("piece_size", &torrent_info::piece_size)
|
||||
|
||||
.def("num_files", &torrent_info::num_files, (arg("storage")=false))
|
||||
.def("file_at", &torrent_info::file_at, return_internal_reference<>())
|
||||
.def("file_at", &torrent_info::file_at)
|
||||
.def("file_at_offset", &torrent_info::file_at_offset)
|
||||
.def("files", &files, (arg("storage")=false))
|
||||
.def("rename_file", rename_file0)
|
||||
@@ -182,8 +182,10 @@ void bind_torrent_info()
|
||||
;
|
||||
|
||||
class_<file_entry>("file_entry")
|
||||
.def("filename", &file_entry::filename)
|
||||
.def("set_name", &file_entry::set_name)
|
||||
.def_readwrite("path", &file_entry::path)
|
||||
.def_readwrite("symlink_path", &file_entry::symlink_path)
|
||||
.def_readwrite("filehash", &file_entry::filehash)
|
||||
.def_readwrite("mtime", &file_entry::mtime)
|
||||
.add_property("pad_file", &get_pad_file)
|
||||
.add_property("executable_attribute", &get_executable_attribute)
|
||||
.add_property("hidden_attribute", &get_hidden_attribute)
|
||||
|
Reference in New Issue
Block a user