mirror of
https://github.com/transmission/transmission
synced 2025-02-22 06:00:41 +00:00
refactor: tr_sys_dir_open() takes a std::string_view (#5380)
This commit is contained in:
parent
487f5d9676
commit
63421489fe
7 changed files with 8 additions and 10 deletions
|
@ -296,7 +296,7 @@ auto getFilenamesInDir(std::string_view folder)
|
|||
{
|
||||
auto files = std::vector<std::string>{};
|
||||
|
||||
if (auto const odir = tr_sys_dir_open(tr_pathbuf{ folder }); odir != TR_BAD_SYS_DIR)
|
||||
if (auto const odir = tr_sys_dir_open(folder); odir != TR_BAD_SYS_DIR)
|
||||
{
|
||||
char const* name = nullptr;
|
||||
auto const prefix = std::string{ folder } + '/';
|
||||
|
|
|
@ -1205,11 +1205,9 @@ bool tr_sys_dir_create_temp(char* path_template, tr_error** error)
|
|||
return ret;
|
||||
}
|
||||
|
||||
tr_sys_dir_t tr_sys_dir_open(char const* path, tr_error** error)
|
||||
tr_sys_dir_t tr_sys_dir_open(std::string_view path, tr_error** error)
|
||||
{
|
||||
TR_ASSERT(path != nullptr);
|
||||
|
||||
DIR* ret = opendir(path);
|
||||
auto* const ret = opendir(tr_pathbuf{ path });
|
||||
|
||||
if (ret == nullptr)
|
||||
{
|
||||
|
|
|
@ -1256,7 +1256,7 @@ bool tr_sys_dir_create_temp(char* path_template, tr_error** error)
|
|||
return ret;
|
||||
}
|
||||
|
||||
tr_sys_dir_t tr_sys_dir_open(char const* path, tr_error** error)
|
||||
tr_sys_dir_t tr_sys_dir_open(std::string_view path, tr_error** error)
|
||||
{
|
||||
TR_ASSERT(path != nullptr);
|
||||
|
||||
|
|
|
@ -584,7 +584,7 @@ bool tr_sys_dir_create_temp(char* path_template, struct tr_error** error = nullp
|
|||
* @return Opened directory descriptor on success, `TR_BAD_SYS_DIR` otherwise
|
||||
* (with `error` set accordingly).
|
||||
*/
|
||||
tr_sys_dir_t tr_sys_dir_open(char const* path, struct tr_error** error = nullptr);
|
||||
tr_sys_dir_t tr_sys_dir_open(std::string_view path, struct tr_error** error = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Portability wrapper for `readdir()`.
|
||||
|
|
|
@ -86,7 +86,7 @@ void walkTree(std::string_view const top, std::string_view const subpath, std::s
|
|||
switch (info->type)
|
||||
{
|
||||
case TR_SYS_PATH_IS_DIRECTORY:
|
||||
if (tr_sys_dir_t odir = tr_sys_dir_open(path.c_str()); odir != TR_BAD_SYS_DIR)
|
||||
if (tr_sys_dir_t odir = tr_sys_dir_open(path); odir != TR_BAD_SYS_DIR)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
|
|
|
@ -1349,7 +1349,7 @@ namespace load_torrents_helpers
|
|||
return {};
|
||||
}
|
||||
|
||||
auto const odir = tr_sys_dir_open(folder.c_str());
|
||||
auto const odir = tr_sys_dir_open(folder);
|
||||
if (odir == TR_BAD_SYS_DIR)
|
||||
{
|
||||
return {};
|
||||
|
|
|
@ -110,7 +110,7 @@ void BaseWatchdir::processFile(std::string_view basename)
|
|||
void BaseWatchdir::scan()
|
||||
{
|
||||
tr_error* error = nullptr;
|
||||
auto const dir = tr_sys_dir_open(dirname_.c_str(), &error);
|
||||
auto const dir = tr_sys_dir_open(dirname_, &error);
|
||||
if (dir == TR_BAD_SYS_DIR)
|
||||
{
|
||||
tr_logAddWarn(fmt::format(
|
||||
|
|
Loading…
Reference in a new issue