diff --git a/libluna/include/luna/Result.h b/libluna/include/luna/Result.h index 98765412..00c88feb 100644 --- a/libluna/include/luna/Result.h +++ b/libluna/include/luna/Result.h @@ -199,6 +199,13 @@ template <> class Result return *this; } + static Result from_syscall(long rc) + { + if (rc < 0) return Error { -rc }; + + return {}; + } + bool has_error() const { return m_has_error; diff --git a/libos/src/FileSystem.cpp b/libos/src/FileSystem.cpp index 77e3d3fe..af379645 100644 --- a/libos/src/FileSystem.cpp +++ b/libos/src/FileSystem.cpp @@ -32,21 +32,15 @@ namespace os::FileSystem Result create_directory(StringView path, mode_t mode) { long rc = syscall(SYS_mkdir, path.chars(), mode); - int _ignore = TRY(Result::from_syscall(rc)); - ignore(_ignore); - - return {}; + return Result::from_syscall(rc); } Result remove(StringView path) { long rc = syscall(SYS_unlink, path.chars(), 0); - int _ignore = TRY(Result::from_syscall(rc)); - ignore(_ignore); - - return {}; + return Result::from_syscall(rc); } Result working_directory() @@ -70,10 +64,7 @@ namespace os::FileSystem Result change_directory(StringView path) { long rc = syscall(SYS_chdir, path.chars()); - int _ignore = TRY(Result::from_syscall(rc)); - ignore(_ignore); - - return {}; + return Result::from_syscall(rc); } }