libluna: Add Result<void>::from_syscall
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
67e9543675
commit
8560918931
@ -199,6 +199,13 @@ template <> class Result<void>
|
||||
return *this;
|
||||
}
|
||||
|
||||
static Result<void> from_syscall(long rc)
|
||||
{
|
||||
if (rc < 0) return Error { -rc };
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool has_error() const
|
||||
{
|
||||
return m_has_error;
|
||||
|
@ -32,21 +32,15 @@ namespace os::FileSystem
|
||||
Result<void> create_directory(StringView path, mode_t mode)
|
||||
{
|
||||
long rc = syscall(SYS_mkdir, path.chars(), mode);
|
||||
int _ignore = TRY(Result<int>::from_syscall(rc));
|
||||
|
||||
ignore(_ignore);
|
||||
|
||||
return {};
|
||||
return Result<void>::from_syscall(rc);
|
||||
}
|
||||
|
||||
Result<void> remove(StringView path)
|
||||
{
|
||||
long rc = syscall(SYS_unlink, path.chars(), 0);
|
||||
int _ignore = TRY(Result<int>::from_syscall(rc));
|
||||
|
||||
ignore(_ignore);
|
||||
|
||||
return {};
|
||||
return Result<void>::from_syscall(rc);
|
||||
}
|
||||
|
||||
Result<String> working_directory()
|
||||
@ -70,10 +64,7 @@ namespace os::FileSystem
|
||||
Result<void> change_directory(StringView path)
|
||||
{
|
||||
long rc = syscall(SYS_chdir, path.chars());
|
||||
int _ignore = TRY(Result<int>::from_syscall(rc));
|
||||
|
||||
ignore(_ignore);
|
||||
|
||||
return {};
|
||||
return Result<void>::from_syscall(rc);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user