Change coral::path::joined to return coral::expected
This commit is contained in:
parent
261b62fc2d
commit
c53fd30cc2
@ -7,6 +7,15 @@ export namespace coral {
|
|||||||
* Platform-generalized identifier for a resource in a [fs].
|
* Platform-generalized identifier for a resource in a [fs].
|
||||||
*/
|
*/
|
||||||
struct path {
|
struct path {
|
||||||
|
/**
|
||||||
|
* Errors that may occur during a path joining operation.
|
||||||
|
*
|
||||||
|
* [join_error::overflow] signals that the given path join exceeds the maximum valid length of a path.
|
||||||
|
*/
|
||||||
|
enum class join_error {
|
||||||
|
overflow,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maximum path length.
|
* Maximum path length.
|
||||||
*/
|
*/
|
||||||
@ -83,14 +92,11 @@ export namespace coral {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new [path] composed of the current path joined with `text`.
|
* Attempts to create a new path composed from the current path joined with `text`, returning it or a
|
||||||
*
|
* [join_error] if it failed.
|
||||||
* *Note:* should the new path exceed [max] bytes in size, an empty [path] is returned instead.
|
|
||||||
*
|
|
||||||
* *Note:* should the new path exceed [max] bytes in size, an empty [path] is returned instead.
|
|
||||||
*/
|
*/
|
||||||
constexpr path joined(slice<char const> const & text) const {
|
constexpr expected<path, join_error> joined(slice<char const> const & text) const {
|
||||||
if (text.length > this->buffer[max]) return path{};
|
if (text.length > this->buffer[max]) return join_error::overflow;
|
||||||
|
|
||||||
path joined_path = *this;
|
path joined_path = *this;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user