refactor: migrate C strings to std::string_view in libtransmission/file.h (#8220)

* refactor: tr_sys_file_open() now takes a std::string_view arg

* refactor: tr_sys_path_copy() now takes a std::string_view arg

* refactor: tr_blocklistSetContent() now takes a std::string_view arg

* refactor: tr_sys_path_remove() now takes a std::string_view arg

* refactor: tr_sys_path_exists() now takes a std::string_view arg

* refactor: tr_sys_dir_create() now takes a std::string_view arg

* refactor: add private stat_sv(), lstat_sv() helpers in file-posix.cc

* refactor: tr_sys_path_is_same() now takes a std::string_view arg

* refactor: tr_sys_path_rename() now takes a std::string_view arg
This commit is contained in:
Charles Kerr
2026-01-25 18:39:50 -06:00
committed by GitHub
parent 4a900b10e7
commit 03fdb6f48e
18 changed files with 113 additions and 143 deletions

View File

@@ -537,7 +537,7 @@ TEST_F(DhtTest, savesStateIfSwarmIsGood)
{
auto const state_file = MockStateFile{};
auto const dat_file = MockStateFile::filename(sandboxDir());
EXPECT_FALSE(tr_sys_path_exists(dat_file.c_str()));
EXPECT_FALSE(tr_sys_path_exists(dat_file));
{
auto mediator = MockMediator{ event_base_ };
@@ -548,17 +548,17 @@ TEST_F(DhtTest, savesStateIfSwarmIsGood)
// as dht goes out of scope,
// it should save its state if the swarm is healthy
EXPECT_FALSE(tr_sys_path_exists(dat_file.c_str()));
EXPECT_FALSE(tr_sys_path_exists(dat_file));
}
EXPECT_TRUE(tr_sys_path_exists(dat_file.c_str()));
EXPECT_TRUE(tr_sys_path_exists(dat_file));
}
TEST_F(DhtTest, doesNotSaveStateIfSwarmIsBad)
{
auto const state_file = MockStateFile{};
auto const dat_file = MockStateFile::filename(sandboxDir());
EXPECT_FALSE(tr_sys_path_exists(dat_file.c_str()));
EXPECT_FALSE(tr_sys_path_exists(dat_file));
{
auto mediator = MockMediator{ event_base_ };
@@ -569,10 +569,10 @@ TEST_F(DhtTest, doesNotSaveStateIfSwarmIsBad)
// as dht goes out of scope,
// it should save its state if the swarm is healthy
EXPECT_FALSE(tr_sys_path_exists(dat_file.c_str()));
EXPECT_FALSE(tr_sys_path_exists(dat_file));
}
EXPECT_FALSE(tr_sys_path_exists(dat_file.c_str()));
EXPECT_FALSE(tr_sys_path_exists(dat_file));
}
TEST_F(DhtTest, usesBootstrapFile)

View File

@@ -159,7 +159,7 @@ using MoveTest = SessionTest;
TEST_F(MoveTest, setLocation)
{
auto const target_dir = tr_pathbuf{ session_->configDir(), "/target"sv };
tr_sys_dir_create(target_dir.data(), TR_SYS_DIR_CREATE_PARENTS, 0777, nullptr);
tr_sys_dir_create(target_dir, TR_SYS_DIR_CREATE_PARENTS, 0777, nullptr);
// init a torrent.
auto* const tor = zeroTorrentInit(ZeroTorrentState::Complete);

View File

@@ -62,6 +62,6 @@ int main(int argc, char** argv)
}
out.close();
tr_sys_path_rename(tmp_result_path.c_str(), result_path.c_str());
tr_sys_path_rename(tmp_result_path, result_path);
return 0;
}

View File

@@ -208,7 +208,7 @@ protected:
return child;
}
static void buildParentDir(std::string_view path)
static void buildParentDir(std::string_view const path)
{
auto const tmperr = errno;