mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibCore/System: Port getcwd, stat, rmdir, unlink to Windows
This commit is contained in:
parent
4b4a6991e3
commit
a828a0e158
Notes:
github-actions[bot]
2024-11-19 22:18:35 +00:00
Author: https://github.com/stasoid
Commit: a828a0e158
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2189
Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 45 additions and 0 deletions
|
@ -88,4 +88,49 @@ ErrorOr<void> ioctl(int, unsigned, ...)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ErrorOr<ByteString> getcwd()
|
||||
{
|
||||
auto* cwd = _getcwd(nullptr, 0);
|
||||
if (!cwd)
|
||||
return Error::from_syscall("getcwd"sv, -errno);
|
||||
|
||||
ByteString string_cwd(cwd);
|
||||
free(cwd);
|
||||
return string_cwd;
|
||||
}
|
||||
|
||||
ErrorOr<struct stat> stat(StringView path)
|
||||
{
|
||||
if (path.is_null())
|
||||
return Error::from_syscall("stat"sv, -EFAULT);
|
||||
|
||||
struct stat st = {};
|
||||
ByteString path_string = path;
|
||||
if (::stat(path_string.characters(), &st) < 0)
|
||||
return Error::from_syscall("stat"sv, -errno);
|
||||
return st;
|
||||
}
|
||||
|
||||
ErrorOr<void> rmdir(StringView path)
|
||||
{
|
||||
if (path.is_null())
|
||||
return Error::from_errno(EFAULT);
|
||||
|
||||
ByteString path_string = path;
|
||||
if (_rmdir(path_string.characters()) < 0)
|
||||
return Error::from_syscall("rmdir"sv, -errno);
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> unlink(StringView path)
|
||||
{
|
||||
if (path.is_null())
|
||||
return Error::from_errno(EFAULT);
|
||||
|
||||
ByteString path_string = path;
|
||||
if (_unlink(path_string.characters()) < 0)
|
||||
return Error::from_syscall("unlink"sv, -errno);
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue