0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 15:30:52 +01:00

ircd::fs: Add remove() / rename() support.

This commit is contained in:
Jason Volk 2018-02-26 20:37:19 -08:00
parent 121be689e8
commit e37a8599f7
2 changed files with 46 additions and 0 deletions

View file

@ -78,6 +78,12 @@ namespace ircd::fs
std::vector<std::string> ls(const string_view &path); std::vector<std::string> ls(const string_view &path);
std::vector<std::string> ls_recursive(const string_view &path); std::vector<std::string> ls_recursive(const string_view &path);
bool rename(std::nothrow_t, const string_view &old, const string_view &new_);
void rename(const string_view &old, const string_view &new_);
bool remove(std::nothrow_t, const string_view &path);
bool remove(const string_view &path);
std::string cwd(); std::string cwd();
void chdir(const string_view &path); void chdir(const string_view &path);
bool mkdir(const string_view &path); bool mkdir(const string_view &path);

View file

@ -239,6 +239,13 @@ catch(const filesystem::filesystem_error &e)
"%s", e.what() "%s", e.what()
}; };
} }
bool
ircd::fs::remove(const string_view &path)
try
{
return filesystem::remove(fs::path(path));
}
catch(const filesystem::filesystem_error &e) catch(const filesystem::filesystem_error &e)
{ {
throw filesystem_error throw filesystem_error
@ -247,6 +254,39 @@ catch(const filesystem::filesystem_error &e)
}; };
} }
bool
ircd::fs::remove(std::nothrow_t,
const string_view &path)
{
error_code ec;
return filesystem::remove(fs::path(path), ec);
}
void
ircd::fs::rename(const string_view &old,
const string_view &new_)
try
{
filesystem::rename(path(old), path(new_));
}
catch(const filesystem::filesystem_error &e)
{
throw filesystem_error
{
"%s", e.what()
};
}
bool
ircd::fs::rename(std::nothrow_t,
const string_view &old,
const string_view &new_)
{
error_code ec;
filesystem::rename(path(old), path(new_), ec);
return !ec;
}
std::vector<std::string> std::vector<std::string>
ircd::fs::ls_recursive(const string_view &path) ircd::fs::ls_recursive(const string_view &path)
try try