mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibCore: Add Core::Stream::File::exists()
This commit is contained in:
parent
8a854ba309
commit
244357472a
Notes:
sideshowbarker
2024-07-17 10:45:15 +09:00
Author: https://github.com/arieldon
Commit: 244357472a
Pull-request: https://github.com/SerenityOS/serenity/pull/14027
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
2 changed files with 6 additions and 0 deletions
|
@ -117,6 +117,11 @@ ErrorOr<NonnullOwnPtr<File>> File::adopt_fd(int fd, OpenMode mode)
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool File::exists(StringView filename)
|
||||||
|
{
|
||||||
|
return !Core::System::stat(filename).is_error();
|
||||||
|
}
|
||||||
|
|
||||||
int File::open_mode_to_options(OpenMode mode)
|
int File::open_mode_to_options(OpenMode mode)
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
|
@ -179,6 +179,7 @@ class File final : public SeekableStream {
|
||||||
public:
|
public:
|
||||||
static ErrorOr<NonnullOwnPtr<File>> open(StringView filename, OpenMode, mode_t = 0644);
|
static ErrorOr<NonnullOwnPtr<File>> open(StringView filename, OpenMode, mode_t = 0644);
|
||||||
static ErrorOr<NonnullOwnPtr<File>> adopt_fd(int fd, OpenMode);
|
static ErrorOr<NonnullOwnPtr<File>> adopt_fd(int fd, OpenMode);
|
||||||
|
static bool exists(StringView filename);
|
||||||
|
|
||||||
File(File&& other) { operator=(move(other)); }
|
File(File&& other) { operator=(move(other)); }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue