mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
refactor: remove tr_pathbuf::popdir() (#8221)
This commit is contained in:
@@ -845,10 +845,6 @@ TEST_F(FileTest, pathDirname)
|
||||
{
|
||||
EXPECT_EQ(expected, tr_sys_path_dirname(input))
|
||||
<< "input[" << input << "] expected [" << expected << "] actual [" << tr_sys_path_dirname(input) << "]\n";
|
||||
|
||||
auto path = tr_pathbuf{ input };
|
||||
path.popdir();
|
||||
EXPECT_EQ(expected, path) << "input[" << input << "] expected [" << expected << "] actual [" << path << "]\n";
|
||||
}
|
||||
|
||||
/* TODO: is_same(dirname(x) + '/' + basename(x), x) */
|
||||
|
||||
@@ -178,13 +178,14 @@ protected:
|
||||
|
||||
for (tr_file_index_t i = 0, n = files.file_count(); i < n; ++i)
|
||||
{
|
||||
auto walk = tr_pathbuf{ parent, '/', files.path(i) };
|
||||
createFileWithContents(walk, std::data(Content), std::size(Content));
|
||||
paths.emplace(walk);
|
||||
auto const filename = tr_pathbuf{ parent, '/', files.path(i) };
|
||||
createFileWithContents(filename, std::data(Content), std::size(Content));
|
||||
paths.emplace(filename);
|
||||
|
||||
auto walk = filename.sv();
|
||||
while (!tr_sys_path_is_same(parent, walk))
|
||||
{
|
||||
walk.popdir();
|
||||
walk = tr_sys_path_dirname(walk);
|
||||
paths.emplace(walk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,9 +212,7 @@ protected:
|
||||
{
|
||||
auto const tmperr = errno;
|
||||
|
||||
auto dir = tr_pathbuf{ path };
|
||||
dir.popdir();
|
||||
if (auto const info = tr_sys_path_get_info(path); !info)
|
||||
if (auto const dir = tr_sys_path_dirname(path); !tr_sys_path_exists(dir))
|
||||
{
|
||||
auto error = tr_error{};
|
||||
tr_sys_dir_create(dir, TR_SYS_DIR_CREATE_PARENTS, 0700, &error);
|
||||
@@ -433,9 +431,7 @@ protected:
|
||||
auto const suffix = std::string_view{ partial ? ".part" : "" };
|
||||
auto const filename = tr_pathbuf{ base, '/', subpath, suffix };
|
||||
|
||||
auto dirname = tr_pathbuf{ filename.sv() };
|
||||
dirname.popdir();
|
||||
tr_sys_dir_create(dirname, TR_SYS_DIR_CREATE_PARENTS, 0700);
|
||||
tr_sys_dir_create(tr_sys_path_dirname(filename), TR_SYS_DIR_CREATE_PARENTS, 0700);
|
||||
|
||||
auto fd = tr_sys_file_open(filename, TR_SYS_FILE_WRITE | TR_SYS_FILE_CREATE | TR_SYS_FILE_TRUNCATE, 0600);
|
||||
auto const file_size = metainfo->file_size(i);
|
||||
|
||||
Reference in New Issue
Block a user