diff --git a/libtransmission/platform.cc b/libtransmission/platform.cc index 30b894d87..3c1a9acd9 100644 --- a/libtransmission/platform.cc +++ b/libtransmission/platform.cc @@ -189,11 +189,6 @@ std::string tr_getDefaultConfigDir(std::string_view appname) #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() { 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()); } -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) diff --git a/libtransmission/torrent-magnet.cc b/libtransmission/torrent-magnet.cc index 6791ae81e..b026c5655 100644 --- a/libtransmission/torrent-magnet.cc +++ b/libtransmission/torrent-magnet.cc @@ -389,8 +389,3 @@ std::string tr_torrentGetMagnetLink(tr_torrent const* tor) { 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); -} diff --git a/libtransmission/torrent.cc b/libtransmission/torrent.cc index 525df31be..17a6c2f0f 100644 --- a/libtransmission/torrent.cc +++ b/libtransmission/torrent.cc @@ -1495,11 +1495,6 @@ std::string tr_torrentFilename(tr_torrent const* tor) 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) @@ -2111,11 +2106,6 @@ std::string tr_torrentGetTrackerList(tr_torrent const* tor) 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) @@ -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 }; } -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) { download_dir_ = path; diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 6fda5aca6..a422f7829 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -119,9 +119,6 @@ enum : int8_t */ [[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. * @@ -132,9 +129,6 @@ size_t tr_getDefaultConfigDirToBuf(char const* appname, char* buf, size_t buflen */ [[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. * @@ -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); -/** @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 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); -/** @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); -/** @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 * 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); -/** @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 * wide. Fills 'tab' which you must have allocated: each byte is set diff --git a/libtransmission/utils.cc b/libtransmission/utils.cc index 60840803c..f5dd95170 100644 --- a/libtransmission/utils.cc +++ b/libtransmission/utils.cc @@ -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 */ bool tr_wildmat(char const* text, char const* pattern) { diff --git a/libtransmission/utils.h b/libtransmission/utils.h index cade32a3b..1a285426c 100644 --- a/libtransmission/utils.h +++ b/libtransmission/utils.h @@ -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 /*�*/); -/** - * @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, bool> = true>