refactor: remove TR_PATH_DELIMITER (#6618)

This commit is contained in:
Charles Kerr 2024-02-18 01:47:12 -06:00 committed by GitHub
parent 348177863a
commit 189fe73575
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 8 additions and 19 deletions

View File

@ -351,7 +351,7 @@ private:
};
public:
struct Settings : public libtransmission::Settings
struct Settings final : public libtransmission::Settings
{
public:
Settings() = default;

View File

@ -2318,15 +2318,13 @@ namespace rename_helpers
{
bool renameArgsAreValid(tr_torrent const* tor, std::string_view oldpath, std::string_view newname)
{
if (std::empty(oldpath) || std::empty(newname) || newname == "."sv || newname == ".."sv ||
tr_strv_contains(newname, TR_PATH_DELIMITER))
if (std::empty(oldpath) || std::empty(newname) || newname == "."sv || newname == ".."sv || tr_strv_contains(newname, '/'))
{
return false;
}
auto const newpath = tr_strv_contains(oldpath, TR_PATH_DELIMITER) ?
tr_pathbuf{ tr_sys_path_dirname(oldpath), '/', newname } :
tr_pathbuf{ newname };
auto const newpath = tr_strv_contains(oldpath, '/') ? tr_pathbuf{ tr_sys_path_dirname(oldpath), '/', newname } :
tr_pathbuf{ newname };
if (newpath == oldpath)
{
@ -2412,7 +2410,7 @@ void renameTorrentFileString(tr_torrent* tor, std::string_view oldpath, std::str
auto const subpath = std::string_view{ tor->file_subpath(file_index) };
auto const oldpath_len = std::size(oldpath);
if (!tr_strv_contains(oldpath, TR_PATH_DELIMITER))
if (!tr_strv_contains(oldpath, '/'))
{
if (oldpath_len >= std::size(subpath))
{

View File

@ -72,8 +72,6 @@
// ---
#define TR_PATH_DELIMITER '/'
#define TR_INET6_ADDRSTRLEN 46
#define TR_ADDRSTRLEN 64

View File

@ -33,7 +33,7 @@ std::string getTestProgramPath(std::string const& filename)
{
auto const exe_path = tr_sys_path_resolve(testing::internal::GetArgvs().front().data());
auto const exe_dir = tr_sys_path_dirname(exe_path);
return std::string{ exe_dir } + TR_PATH_DELIMITER + filename;
return fmt::format("{:s}/{:s}", exe_dir, filename);
}
class SubprocessTest
@ -45,9 +45,7 @@ protected:
[[nodiscard]] std::string buildSandboxPath(std::string const& filename) const
{
auto path = sandbox_.path();
path += TR_PATH_DELIMITER;
path += filename;
auto path = fmt::format("{:s}/{:s}", sandbox_.path(), filename);
tr_sys_path_native_separators(&path.front());
return path;
}

View File

@ -21,7 +21,6 @@
#include <libtransmission/crypto-utils.h> // tr_base64_decode()
#include <libtransmission/error.h>
#include <libtransmission/file.h> // tr_sys_file_*()
#include <libtransmission/platform.h> // TR_PATH_DELIMITER
#include <libtransmission/quark.h>
#include <libtransmission/torrent-ctor.h>
#include <libtransmission/torrent.h>

View File

@ -106,12 +106,8 @@ protected:
static std::string createDir(std::string_view dirname, std::string_view basename)
{
auto path = std::string{ dirname };
path += TR_PATH_DELIMITER;
path += basename;
auto path = fmt::format("{:s}/{:s}", dirname, basename);
tr_sys_dir_create(path, 0, 0700);
return path;
}