0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::fs::path: Add canonical() suite to interface; minor reorg.

This commit is contained in:
Jason Volk 2020-11-14 00:26:36 -08:00
parent bb7cda6fec
commit cb223b97c0
2 changed files with 26 additions and 9 deletions

View file

@ -46,8 +46,10 @@ namespace ircd::fs
string_view extension(const mutable_buffer &, const string_view &path, const string_view &replace); string_view extension(const mutable_buffer &, const string_view &path, const string_view &replace);
string_view extension(const mutable_buffer &, const string_view &path); string_view extension(const mutable_buffer &, const string_view &path);
string_view relative(const mutable_buffer &, const string_view &root, const string_view &path);
string_view filename(const mutable_buffer &, const string_view &path); string_view filename(const mutable_buffer &, const string_view &path);
string_view relative(const mutable_buffer &, const string_view &root, const string_view &path);
string_view canonical(const mutable_buffer &, const string_view &path);
string_view canonical(const mutable_buffer &, const string_view &root, const string_view &path);
string_view parent(const mutable_buffer &, const string_view &path); string_view parent(const mutable_buffer &, const string_view &path);
long pathconf(const string_view &path, const int &arg); long pathconf(const string_view &path, const int &arg);

View file

@ -287,6 +287,29 @@ ircd::fs::pathconf(const string_view &path,
return syscall(::pathconf, path_cstr(path), arg); return syscall(::pathconf, path_cstr(path), arg);
} }
ircd::string_view
ircd::fs::canonical(const mutable_buffer &buf,
const string_view &p)
{
return path(buf, canonical(_path(p)));
}
ircd::string_view
ircd::fs::canonical(const mutable_buffer &buf,
const string_view &root,
const string_view &p)
{
return path(buf, canonical(_path(p), _path(root)));
}
ircd::string_view
ircd::fs::relative(const mutable_buffer &buf,
const string_view &root,
const string_view &p)
{
return path(buf, relative(_path(p), _path(root)));
}
ircd::string_view ircd::string_view
ircd::fs::filename(const mutable_buffer &buf, ircd::fs::filename(const mutable_buffer &buf,
const string_view &p) const string_view &p)
@ -309,14 +332,6 @@ ircd::fs::extension(const mutable_buffer &buf,
return path(buf, _path(p).replace_extension(_path(replace))); return path(buf, _path(p).replace_extension(_path(replace)));
} }
ircd::string_view
ircd::fs::relative(const mutable_buffer &buf,
const string_view &root,
const string_view &p)
{
return path(buf, relative(_path(p), _path(root)));
}
bool bool
ircd::fs::is_relative(const string_view &p) ircd::fs::is_relative(const string_view &p)
{ {