mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibCore: Add wrapper for fstatat()
`Core::System::fstatat()` is similar to our standard `Core::System` wrappers. `Core::Directory::stat(relative_path, flags)` is a convenience method if you already have a Directory, to stat a file relative to it.
This commit is contained in:
parent
c140b67be3
commit
da8da79e62
Notes:
sideshowbarker
2024-07-16 20:44:03 +09:00
Author: https://github.com/AtkinsSJ
Commit: da8da79e62
Pull-request: https://github.com/SerenityOS/serenity/pull/17894
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/supercomputer7
4 changed files with 24 additions and 1 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Kenneth Myhra <kennethmyhra@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, Matthias Zimmerman <matthias291999@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -380,6 +380,22 @@ ErrorOr<struct stat> fstat(int fd)
|
|||
return st;
|
||||
}
|
||||
|
||||
ErrorOr<struct stat> fstatat(int fd, StringView path, int flags)
|
||||
{
|
||||
if (!path.characters_without_null_termination())
|
||||
return Error::from_syscall("fstatat"sv, -EFAULT);
|
||||
|
||||
struct stat st = {};
|
||||
#ifdef AK_OS_SERENITY
|
||||
Syscall::SC_stat_params params { { path.characters_without_null_termination(), path.length() }, &st, fd, !(flags & AT_SYMLINK_NOFOLLOW) };
|
||||
int rc = syscall(SC_stat, ¶ms);
|
||||
#else
|
||||
DeprecatedString path_string = path;
|
||||
int rc = ::fstatat(fd, path_string.characters(), &st, flags);
|
||||
#endif
|
||||
HANDLE_SYSCALL_RETURN_VALUE("fstatat", rc, st);
|
||||
}
|
||||
|
||||
ErrorOr<int> fcntl(int fd, int command, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue