diff --git a/source/coral/files.cpp b/source/coral/files.cpp index 967456b..09f746e 100755 --- a/source/coral/files.cpp +++ b/source/coral/files.cpp @@ -7,6 +7,15 @@ export namespace coral { * Platform-generalized identifier for a resource in a [fs]. */ 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. */ @@ -83,14 +92,11 @@ export namespace coral { } /** - * Returns a new [path] composed of the current path joined with `text`. - * - * *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. + * Attempts to create a new path composed from the current path joined with `text`, returning it or a + * [join_error] if it failed. */ - constexpr path joined(slice const & text) const { - if (text.length > this->buffer[max]) return path{}; + constexpr expected joined(slice const & text) const { + if (text.length > this->buffer[max]) return join_error::overflow; path joined_path = *this;