1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

LibCore: Move Core::Stream::File::exists() to Core::File

`Core::Stream::File` shouldn't hold any utility methods that are
unrelated to constructing a `Core::Stream`, so let's just replace the
existing `Core::File::exists` with the nicer looking implementation.
This commit is contained in:
Tim Schumacher 2022-12-07 21:34:00 +01:00 committed by Sam Atkins
parent bd272e638c
commit 2fc2025f49
10 changed files with 14 additions and 18 deletions

View file

@ -9,6 +9,7 @@
#include <AK/ScopeGuard.h>
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
#include <LibCore/System.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
@ -191,10 +192,9 @@ bool File::looks_like_shared_library(DeprecatedString const& filename)
return filename.ends_with(".so"sv) || filename.contains(".so."sv);
}
bool File::exists(DeprecatedString const& filename)
bool File::exists(StringView filename)
{
struct stat st;
return stat(filename.characters(), &st) == 0;
return !Core::System::stat(filename).is_error();
}
ErrorOr<size_t> File::size(DeprecatedString const& filename)