mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 09:52:31 +00:00
LibWeb/EntriesAPI: Implement FileSystemEntry
This commit is contained in:
parent
b583aec3ac
commit
169163b002
Notes:
github-actions[bot]
2024-08-24 12:54:09 +00:00
Author: https://github.com/jamierocks
Commit: 169163b002
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1172
Reviewed-by: https://github.com/trflynn89
10 changed files with 118 additions and 0 deletions
55
Userland/Libraries/LibWeb/EntriesAPI/FileSystemEntry.cpp
Normal file
55
Userland/Libraries/LibWeb/EntriesAPI/FileSystemEntry.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/FileSystemEntryPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/EntriesAPI/FileSystemEntry.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
|
||||
namespace Web::EntriesAPI {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(FileSystemEntry);
|
||||
|
||||
JS::NonnullGCPtr<FileSystemEntry> FileSystemEntry::create(JS::Realm& realm, EntryType entry_type, ByteString name)
|
||||
{
|
||||
return realm.heap().allocate<FileSystemEntry>(realm, realm, entry_type, name);
|
||||
}
|
||||
|
||||
FileSystemEntry::FileSystemEntry(JS::Realm& realm, EntryType entry_type, ByteString name)
|
||||
: PlatformObject(realm)
|
||||
, m_entry_type(entry_type)
|
||||
, m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
void FileSystemEntry::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(FileSystemEntry);
|
||||
}
|
||||
|
||||
// https://wicg.github.io/entries-api/#dom-filesystementry-isfile
|
||||
bool FileSystemEntry::is_file() const
|
||||
{
|
||||
// The isFile getter steps are to return true if this is a file entry and false otherwise.
|
||||
return m_entry_type == EntryType::File;
|
||||
}
|
||||
|
||||
// https://wicg.github.io/entries-api/#dom-filesystementry-isdirectory
|
||||
bool FileSystemEntry::is_directory() const
|
||||
{
|
||||
// The isDirectory getter steps are to return true if this is a directory entry and false otherwise.
|
||||
return m_entry_type == EntryType::Directory;
|
||||
}
|
||||
|
||||
// https://wicg.github.io/entries-api/#dom-filesystementry-name
|
||||
ByteString FileSystemEntry::name() const
|
||||
{
|
||||
// The name getter steps are to return this's name.
|
||||
return m_name;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue