mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::fs: Test if O_DIRECT possible on path target.
This commit is contained in:
parent
67d202a5e4
commit
3426fc650f
2 changed files with 25 additions and 0 deletions
|
@ -52,6 +52,7 @@ namespace ircd::fs
|
|||
bool is_dir(const string_view &path);
|
||||
bool is_reg(const string_view &path);
|
||||
size_t size(const string_view &path);
|
||||
bool direct_io_support(const string_view &path);
|
||||
|
||||
std::vector<std::string> ls(const string_view &path);
|
||||
std::vector<std::string> ls_recursive(const string_view &path);
|
||||
|
|
24
ircd/fs.cc
24
ircd/fs.cc
|
@ -860,6 +860,30 @@ catch(const filesystem::filesystem_error &e)
|
|||
throw error{e};
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::fs::direct_io_support(const string_view &path)
|
||||
try
|
||||
{
|
||||
fd::opts opts{std::ios::out};
|
||||
opts.direct = true;
|
||||
fd{path, opts};
|
||||
return true;
|
||||
}
|
||||
catch(const std::system_error &e)
|
||||
{
|
||||
const auto &code(e.code());
|
||||
if(code.category() == std::system_category()) switch(code.value())
|
||||
{
|
||||
case int(std::errc::invalid_argument):
|
||||
return false;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::fs::size(const string_view &path)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue