diff options
Diffstat (limited to 'Userland/Libraries/LibCore')
-rw-r--r-- | Userland/Libraries/LibCore/File.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/File.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/Stream.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/Stream.h | 1 |
4 files changed, 4 insertions, 10 deletions
diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp index 1af47ec5ee..0290d4205e 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/File.cpp @@ -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) diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h index 233e9c2364..6ac18fd95c 100644 --- a/Userland/Libraries/LibCore/File.h +++ b/Userland/Libraries/LibCore/File.h @@ -47,7 +47,7 @@ public: bool looks_like_shared_library() const; static bool looks_like_shared_library(DeprecatedString const& filename); - static bool exists(DeprecatedString const& filename); + static bool exists(StringView filename); static ErrorOr<size_t> size(DeprecatedString const& filename); static DeprecatedString current_working_directory(); static DeprecatedString absolute_path(DeprecatedString const& path); diff --git a/Userland/Libraries/LibCore/Stream.cpp b/Userland/Libraries/LibCore/Stream.cpp index 3ff6ba837f..3f198cb760 100644 --- a/Userland/Libraries/LibCore/Stream.cpp +++ b/Userland/Libraries/LibCore/Stream.cpp @@ -165,11 +165,6 @@ ErrorOr<NonnullOwnPtr<File>> File::adopt_fd(int fd, OpenMode mode, ShouldCloseFi return file; } -bool File::exists(StringView filename) -{ - return !Core::System::stat(filename).is_error(); -} - ErrorOr<NonnullOwnPtr<File>> File::standard_input() { return File::adopt_fd(STDIN_FILENO, OpenMode::Read, ShouldCloseFileDescriptor::No); diff --git a/Userland/Libraries/LibCore/Stream.h b/Userland/Libraries/LibCore/Stream.h index f4048f386a..87e983c17d 100644 --- a/Userland/Libraries/LibCore/Stream.h +++ b/Userland/Libraries/LibCore/Stream.h @@ -220,7 +220,6 @@ class File final : public SeekableStream { public: static ErrorOr<NonnullOwnPtr<File>> open(StringView filename, OpenMode, mode_t = 0644); static ErrorOr<NonnullOwnPtr<File>> adopt_fd(int fd, OpenMode, ShouldCloseFileDescriptor = ShouldCloseFileDescriptor::Yes); - static bool exists(StringView filename); static ErrorOr<NonnullOwnPtr<File>> standard_input(); static ErrorOr<NonnullOwnPtr<File>> standard_output(); |