std::string directory::file() const { #ifdef TORRENT_WINDOWS #if TORRENT_USE_WSTRING return convert_from_wstring(m_fd.cFileName); #else return convert_from_native(m_fd.cFileName); #endif #else return convert_from_native(m_dirent.d_name); #endif }
std::string i2p_alert::message() const { char msg[600]; snprintf(msg, sizeof(msg), "i2p_error: [%s] %s" , error.category().name(), convert_from_native(error.message()).c_str()); return msg; }
std::string peer_disconnected_alert::message() const { char msg[600]; snprintf(msg, sizeof(msg), "%s disconnecting: [%s] %s", peer_alert::message().c_str() , error.category().name(), convert_from_native(error.message()).c_str()); return msg; }
portmap_error_alert::portmap_error_alert(int i, int t, error_code const& e) : mapping(i), map_type(t), error(e) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
std::string mmap_cache_alert::message() const { char msg[600]; snprintf(msg, sizeof(msg), "mmap cache failed: (%d) %s", error.value() , convert_from_native(error.message()).c_str()); return msg; }
std::string file_rename_failed_alert::message() const { char ret[200 + TORRENT_MAX_PATH * 2]; snprintf(ret, sizeof(ret), "%s: failed to rename file %d: %s" , torrent_alert::message().c_str(), index, convert_from_native(error.message()).c_str()); return ret; }
scrape_failed_alert::scrape_failed_alert(torrent_handle const& h , std::string const& u , error_code const& e) : tracker_alert(h, u) , msg(convert_from_native(e.message())) { TORRENT_ASSERT(!url.empty()); }
std::string rss_alert::message() const { char msg[600]; char const* state_msg[] = {"updating", "updated", "error"}; snprintf(msg, sizeof(msg), "RSS feed %s: %s (%s)" , url.c_str(), state_msg[state], convert_from_native(error.message()).c_str()); return msg; }
url_seed_alert::url_seed_alert( torrent_handle const& h , std::string const& u , error_code const& e) : torrent_alert(h) , url(u) , msg(convert_from_native(e.message())) {}
peer_error_alert::peer_error_alert(torrent_handle const& h, tcp::endpoint const& ep , peer_id const& peer_id, error_code const& e) : peer_alert(h, ep, peer_id) , error(e) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
save_resume_data_failed_alert::save_resume_data_failed_alert(aux::stack_allocator& alloc , torrent_handle const& h, error_code const& e) : torrent_alert(alloc, h) , error(e) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
fastresume_rejected_alert::fastresume_rejected_alert(torrent_handle const& h , error_code const& e) : torrent_alert(h) , error(e) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
std::string tracker_error_alert::message() const { char ret[400]; snprintf(ret, sizeof(ret), "%s (%d) %s \"%s\" (%d)" , tracker_alert::message().c_str(), status_code , convert_from_native(error.message()).c_str(), error_message() , times_in_row); return ret; }
torrent_delete_failed_alert::torrent_delete_failed_alert(torrent_handle const& h, error_code const& e, sha1_hash const& ih) : torrent_alert(h) , error(e) , info_hash(ih) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
std::string peer_error_alert::message() const { char buf[200]; snprintf(buf, sizeof(buf), "%s peer error [%s] [%s]: %s" , peer_alert::message().c_str() , operation_name(operation), error.category().name() , convert_from_native(error.message()).c_str()); return buf; }
const char* libtorrent_exception::what() const throw() { if (!m_msg) { std::string msg = convert_from_native(m_error.message()); m_msg = allocate_string_copy(msg.c_str()); } return m_msg; }
std::string peer_disconnected_alert::message() const { char buf[600]; snprintf(buf, sizeof(buf), "%s disconnecting (%s) [%s] [%s]: %s (reason: %d)" , peer_alert::message().c_str() , socket_type_str[socket_type] , operation_name(operation), error.category().name() , convert_from_native(error.message()).c_str() , int(reason)); return buf; }
peer_error_alert::peer_error_alert(aux::stack_allocator& alloc, torrent_handle const& h , tcp::endpoint const& ep, peer_id const& peer_id, int op , error_code const& e) : peer_alert(alloc, h, ep, peer_id) , operation(op) , error(e) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
url_seed_alert::url_seed_alert(aux::stack_allocator& alloc, torrent_handle const& h , std::string const& u, error_code const& e) : torrent_alert(alloc, h) #ifndef TORRENT_NO_DEPRECATE , url(u) , msg(convert_from_native(e.message())) #endif , error(e) , m_url_idx(alloc.copy_string(u)) , m_msg_idx(-1) {}
file_error_alert::file_error_alert( std::string const& f , torrent_handle const& h , error_code const& e) : torrent_alert(h) , file(f) , error(e) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
scrape_failed_alert::scrape_failed_alert(aux::stack_allocator& alloc , torrent_handle const& h , std::string const& u , error_code const& e) : tracker_alert(alloc, h, u) #ifndef TORRENT_NO_DEPRECATE , msg(convert_from_native(e.message())) #endif , error(e) , m_msg_idx(-1) { TORRENT_ASSERT(!u.empty()); }
peer_disconnected_alert::peer_disconnected_alert(aux::stack_allocator& alloc , torrent_handle const& h, tcp::endpoint const& ep , peer_id const& peer_id, operation_t op, int type, error_code const& e , close_reason_t r) : peer_alert(alloc, h, ep, peer_id) , socket_type(type) , operation(op) , error(e) , reason(r) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
std::string read_piece_alert::message() const { char msg[200]; if (ec) { snprintf(msg, sizeof(msg), "%s: read_piece %u failed: %s" , torrent_alert::message().c_str() , piece , convert_from_native(ec.message()).c_str()); } else { snprintf(msg, sizeof(msg), "%s: read_piece %u successful" , torrent_alert::message().c_str() , piece); } return msg; }
file_error_alert::file_error_alert(aux::stack_allocator& alloc , error_code const& ec , std::string const& f , char const* op , torrent_handle const& h) : torrent_alert(alloc, h) #ifndef TORRENT_NO_DEPRECATE , file(f) #endif , error(ec) , operation(op) , m_file_idx(alloc.copy_string(f)) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
fastresume_rejected_alert::fastresume_rejected_alert( aux::stack_allocator& alloc , torrent_handle const& h , error_code const& ec , std::string const& file , char const* op) : torrent_alert(alloc, h) , error(ec) #ifndef TORRENT_NO_DEPRECATE , file(file) #endif , operation(op) , m_path_idx(alloc.copy_string(file)) { #ifndef TORRENT_NO_DEPRECATE msg = convert_from_native(error.message()); #endif }
std::string listen_failed_alert::message() const { static char const* op_str[] = { "parse_addr", "open", "bind", "listen", "get_peer_name", "accept" }; char ret[300]; snprintf(ret, sizeof(ret), "listening on %s failed: [%s] [%s] %s" , listen_interface() , op_str[operation] , sock_type_str[sock_type] , convert_from_native(error.message()).c_str()); return ret; }
std::string dht_error_alert::message() const { static const char* const operation_names[] = { "unknown", "hostname lookup" }; int op = operation; if (op < 0 || op >= int(sizeof(operation_names)/sizeof(operation_names[0]))) op = 0; char msg[600]; snprintf(msg, sizeof(msg), "DHT error [%s] (%d) %s" , operation_names[op] , error.value() , convert_from_native(error.message()).c_str()); return msg; }
std::string current_working_directory() { #ifdef TORRENT_WINDOWS #if TORRENT_USE_WSTRING wchar_t cwd[TORRENT_MAX_PATH]; _wgetcwd(cwd, sizeof(cwd) / sizeof(wchar_t)); #else char cwd[TORRENT_MAX_PATH]; _getcwd(cwd, sizeof(cwd)); #endif // TORRENT_USE_WSTRING #else char cwd[TORRENT_MAX_PATH]; if (getcwd(cwd, sizeof(cwd)) == 0) return "/"; #endif #if defined TORRENT_WINDOWS && TORRENT_USE_WSTRING return convert_from_wstring(cwd); #else return convert_from_native(cwd); #endif }
std::string listen_failed_alert::message() const { static char const* op_str[] = { "parse_addr", "open", "bind", "listen", "get_socket_name", "accept", "enum_if", "bind_to_device" }; char ret[300]; snprintf(ret, sizeof(ret), "listening on %s (device: %s) failed: [%s] [%s] %s" , print_endpoint(endpoint).c_str() , listen_interface() , op_str[operation] , sock_type_str[sock_type] , convert_from_native(error.message()).c_str()); return ret; }
std::string add_torrent_alert::message() const { char msg[600]; char info_hash[41]; char const* torrent_name = info_hash; if (params.ti) torrent_name = params.ti->name().c_str(); else if (!params.name.empty()) torrent_name = params.name.c_str(); else if (!params.url.empty()) torrent_name = params.url.c_str(); else to_hex(params.info_hash.data(), 20, info_hash); if (error) { snprintf(msg, sizeof(msg), "failed to add torrent \"%s\": [%s] %s" , torrent_name, error.category().name() , convert_from_native(error.message()).c_str()); } else { snprintf(msg, sizeof(msg), "added torrent: %s", torrent_name); } return msg; }