mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
refactor: remove unused libtransmission api (#8169)
* refactor: remove tr_getDefaultConfigDirToBuf() * refactor: remove tr_torrentFindFileToBuf() * refactor: remove tr_torrentGetMagnetLinkToBuf() * refactor: remove tr_getDefaultDownloadDirToBuf() * refactor: remove tr_torrentGetTrackerListToBuf() * refactor: remove tr_torrentFilenameToBuf() * refactor: remove tr_strv_to_buf()
This commit is contained in:
@@ -189,11 +189,6 @@ std::string tr_getDefaultConfigDir(std::string_view appname)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t tr_getDefaultConfigDirToBuf(char const* appname, char* buf, size_t buflen)
|
|
||||||
{
|
|
||||||
return tr_strv_to_buf(tr_getDefaultConfigDir(appname != nullptr ? appname : ""), buf, buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string tr_getDefaultDownloadDir()
|
std::string tr_getDefaultDownloadDir()
|
||||||
{
|
{
|
||||||
if (auto dir = getXdgEntryFromUserDirs("XDG_DOWNLOAD_DIR"sv); !std::empty(dir))
|
if (auto dir = getXdgEntryFromUserDirs("XDG_DOWNLOAD_DIR"sv); !std::empty(dir))
|
||||||
@@ -215,11 +210,6 @@ std::string tr_getDefaultDownloadDir()
|
|||||||
return fmt::format("{:s}/Downloads"sv, getHomeDir());
|
return fmt::format("{:s}/Downloads"sv, getHomeDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t tr_getDefaultDownloadDirToBuf(char* buf, size_t buflen)
|
|
||||||
{
|
|
||||||
return tr_strv_to_buf(tr_getDefaultDownloadDir(), buf, buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
std::string tr_getWebClientDir([[maybe_unused]] tr_session const* session)
|
std::string tr_getWebClientDir([[maybe_unused]] tr_session const* session)
|
||||||
|
|||||||
@@ -389,8 +389,3 @@ std::string tr_torrentGetMagnetLink(tr_torrent const* tor)
|
|||||||
{
|
{
|
||||||
return tor->magnet();
|
return tor->magnet();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t tr_torrentGetMagnetLinkToBuf(tr_torrent const* tor, char* buf, size_t buflen)
|
|
||||||
{
|
|
||||||
return tr_strv_to_buf(tr_torrentGetMagnetLink(tor), buf, buflen);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1495,11 +1495,6 @@ std::string tr_torrentFilename(tr_torrent const* tor)
|
|||||||
return std::string{ tor->torrent_file() };
|
return std::string{ tor->torrent_file() };
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t tr_torrentFilenameToBuf(tr_torrent const* tor, char* buf, size_t buflen)
|
|
||||||
{
|
|
||||||
return tr_strv_to_buf(tr_torrentFilename(tor), buf, buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
tr_peer_stat* tr_torrentPeers(tr_torrent const* tor, size_t* peer_count)
|
tr_peer_stat* tr_torrentPeers(tr_torrent const* tor, size_t* peer_count)
|
||||||
@@ -2111,11 +2106,6 @@ std::string tr_torrentGetTrackerList(tr_torrent const* tor)
|
|||||||
return tor->announce_list().to_string();
|
return tor->announce_list().to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t tr_torrentGetTrackerListToBuf(tr_torrent const* tor, char* buf, size_t buflen)
|
|
||||||
{
|
|
||||||
return tr_strv_to_buf(tr_torrentGetTrackerList(tor), buf, buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
uint64_t tr_torrentGetBytesLeftToAllocate(tr_torrent const* tor)
|
uint64_t tr_torrentGetBytesLeftToAllocate(tr_torrent const* tor)
|
||||||
@@ -2270,11 +2260,6 @@ std::string tr_torrentFindFile(tr_torrent const* tor, tr_file_index_t file_num)
|
|||||||
return std::string{ found ? found->filename().sv() : ""sv };
|
return std::string{ found ? found->filename().sv() : ""sv };
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t tr_torrentFindFileToBuf(tr_torrent const* tor, tr_file_index_t file_num, char* buf, size_t buflen)
|
|
||||||
{
|
|
||||||
return tr_strv_to_buf(tr_torrentFindFile(tor, file_num), buf, buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tr_torrent::set_download_dir(std::string_view path, bool is_new_torrent)
|
void tr_torrent::set_download_dir(std::string_view path, bool is_new_torrent)
|
||||||
{
|
{
|
||||||
download_dir_ = path;
|
download_dir_ = path;
|
||||||
|
|||||||
@@ -119,9 +119,6 @@ enum : int8_t
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] std::string tr_getDefaultConfigDir(std::string_view appname);
|
[[nodiscard]] std::string tr_getDefaultConfigDir(std::string_view appname);
|
||||||
|
|
||||||
/** @brief buffer variant of `tr_getDefaultConfigDir()`. See `tr_strv_to_buf()`. */
|
|
||||||
size_t tr_getDefaultConfigDirToBuf(char const* appname, char* buf, size_t buflen);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief returns Transmission's default download directory.
|
* @brief returns Transmission's default download directory.
|
||||||
*
|
*
|
||||||
@@ -132,9 +129,6 @@ size_t tr_getDefaultConfigDirToBuf(char const* appname, char* buf, size_t buflen
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] std::string tr_getDefaultDownloadDir();
|
[[nodiscard]] std::string tr_getDefaultDownloadDir();
|
||||||
|
|
||||||
/** @brief buffer variant of `tr_getDefaultDownloadDir()`. See `tr_strv_to_buf()`. */
|
|
||||||
size_t tr_getDefaultDownloadDirToBuf(char* buf, size_t buflen);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add libtransmission's default settings to the benc dictionary.
|
* Add libtransmission's default settings to the benc dictionary.
|
||||||
*
|
*
|
||||||
@@ -940,9 +934,6 @@ char const* tr_torrentName(tr_torrent const* tor);
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] std::string tr_torrentFindFile(tr_torrent const* tor, tr_file_index_t file_num);
|
[[nodiscard]] std::string tr_torrentFindFile(tr_torrent const* tor, tr_file_index_t file_num);
|
||||||
|
|
||||||
/** @brief buffer variant of `tr_torrentFindFile()`. See `tr_strv_to_buf()`. */
|
|
||||||
size_t tr_torrentFindFileToBuf(tr_torrent const* tor, tr_file_index_t file_num, char* buf, size_t buflen);
|
|
||||||
|
|
||||||
// --- Torrent speed limits
|
// --- Torrent speed limits
|
||||||
|
|
||||||
size_t tr_torrentGetSpeedLimit_KBps(tr_torrent const* tor, tr_direction dir);
|
size_t tr_torrentGetSpeedLimit_KBps(tr_torrent const* tor, tr_direction dir);
|
||||||
@@ -1034,9 +1025,6 @@ char const* tr_torrentGetCurrentDir(tr_torrent const* tor);
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] std::string tr_torrentGetMagnetLink(tr_torrent const* tor);
|
[[nodiscard]] std::string tr_torrentGetMagnetLink(tr_torrent const* tor);
|
||||||
|
|
||||||
/** @brief buffer variant of `tr_torrentGetMagnetLink()`. See `tr_strv_to_buf()`. */
|
|
||||||
size_t tr_torrentGetMagnetLinkToBuf(tr_torrent const* tor, char* buf, size_t buflen);
|
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1051,9 +1039,6 @@ size_t tr_torrentGetMagnetLinkToBuf(tr_torrent const* tor, char* buf, size_t buf
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] std::string tr_torrentGetTrackerList(tr_torrent const* tor);
|
[[nodiscard]] std::string tr_torrentGetTrackerList(tr_torrent const* tor);
|
||||||
|
|
||||||
/** @brief buffer variant of `tr_torrentGetTrackerList()`. See `tr_strv_to_buf()`. */
|
|
||||||
size_t tr_torrentGetTrackerListToBuf(tr_torrent const* tor, char* buf, size_t buflen);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a torrent's tracker list from a list of announce URLs with one
|
* Sets a torrent's tracker list from a list of announce URLs with one
|
||||||
* URL per line and a blank line between tiers.
|
* URL per line and a blank line between tiers.
|
||||||
@@ -1346,9 +1331,6 @@ struct tr_torrent_view tr_torrentView(tr_torrent const* tor);
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] std::string tr_torrentFilename(tr_torrent const* tor);
|
[[nodiscard]] std::string tr_torrentFilename(tr_torrent const* tor);
|
||||||
|
|
||||||
/** @brief buffer variant of `tr_torrentFilename()`. See `tr_strv_to_buf()`. */
|
|
||||||
size_t tr_torrentFilenameToBuf(tr_torrent const* tor, char* buf, size_t buflen);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this to draw an advanced progress bar which is 'size' pixels
|
* Use this to draw an advanced progress bar which is 'size' pixels
|
||||||
* wide. Fills 'tab' which you must have allocated: each byte is set
|
* wide. Fills 'tab' which you must have allocated: each byte is set
|
||||||
|
|||||||
@@ -233,23 +233,6 @@ bool tr_file_save(std::string_view filename, std::string_view contents, tr_error
|
|||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
size_t tr_strv_to_buf(std::string_view src, char* buf, size_t buflen)
|
|
||||||
{
|
|
||||||
size_t const len = std::size(src);
|
|
||||||
|
|
||||||
if (buflen >= len)
|
|
||||||
{
|
|
||||||
auto const out = std::copy(std::begin(src), std::end(src), buf);
|
|
||||||
|
|
||||||
if (buflen > len)
|
|
||||||
{
|
|
||||||
*out = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* User-level routine. returns whether or not 'text' and 'pattern' matched */
|
/* User-level routine. returns whether or not 'text' and 'pattern' matched */
|
||||||
bool tr_wildmat(char const* text, char const* pattern)
|
bool tr_wildmat(char const* text, char const* pattern)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -188,15 +188,6 @@ constexpr bool tr_strv_sep(std::string_view* sv, std::string_view* token, Args&&
|
|||||||
|
|
||||||
[[nodiscard]] std::string tr_strv_replace_invalid(std::string_view sv, uint32_t replacement = 0xFFFD /*<2A>*/);
|
[[nodiscard]] std::string tr_strv_replace_invalid(std::string_view sv, uint32_t replacement = 0xFFFD /*<2A>*/);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief copies `src` into `buf`.
|
|
||||||
*
|
|
||||||
* - Always returns std::size(src).
|
|
||||||
* - `src` will be copied into `buf` iff `buflen >= std::size(src)`
|
|
||||||
* - `buf` will also be zero terminated iff `buflen >= std::size(src) + 1`.
|
|
||||||
*/
|
|
||||||
size_t tr_strv_to_buf(std::string_view src, char* buf, size_t buflen);
|
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
|
template<typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
|
||||||
|
|||||||
Reference in New Issue
Block a user