refactor: tr_sys_path_dirname returns a std::string (#2792)

This commit is contained in:
Charles Kerr
2022-03-21 15:22:50 -05:00
committed by GitHub
parent fcc1510ecb
commit 03ee0028d4
27 changed files with 259 additions and 288 deletions

View File

@@ -1129,12 +1129,10 @@ bool tr_moveFile(char const* oldpath, char const* newpath, tr_error** error)
return false;
}
/* make sure the target directory exists */
// ensure the target directory exists
{
char* newdir = tr_sys_path_dirname(newpath, error);
bool const i = newdir != nullptr && tr_sys_dir_create(newdir, TR_SYS_DIR_CREATE_PARENTS, 0777, error);
tr_free(newdir);
auto const newdir = tr_sys_path_dirname(newpath, error);
bool const i = !std::empty(newdir) && tr_sys_dir_create(newdir.c_str(), TR_SYS_DIR_CREATE_PARENTS, 0777, error);
if (!i)
{
tr_error_prefix(error, "Unable to create directory for new file: ");