/src/serenity/Userland/Libraries/LibWeb/EntriesAPI/FileSystemEntry.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibWeb/Bindings/FileSystemEntryPrototype.h> |
8 | | #include <LibWeb/Bindings/Intrinsics.h> |
9 | | #include <LibWeb/EntriesAPI/FileSystemEntry.h> |
10 | | #include <LibWeb/HTML/Window.h> |
11 | | |
12 | | namespace Web::EntriesAPI { |
13 | | |
14 | | JS_DEFINE_ALLOCATOR(FileSystemEntry); |
15 | | |
16 | | JS::NonnullGCPtr<FileSystemEntry> FileSystemEntry::create(JS::Realm& realm, EntryType entry_type, ByteString name) |
17 | 0 | { |
18 | 0 | return realm.heap().allocate<FileSystemEntry>(realm, realm, entry_type, name); |
19 | 0 | } |
20 | | |
21 | | FileSystemEntry::FileSystemEntry(JS::Realm& realm, EntryType entry_type, ByteString name) |
22 | 0 | : PlatformObject(realm) |
23 | 0 | , m_entry_type(entry_type) |
24 | 0 | , m_name(name) |
25 | 0 | { |
26 | 0 | } |
27 | | |
28 | | void FileSystemEntry::initialize(JS::Realm& realm) |
29 | 0 | { |
30 | 0 | Base::initialize(realm); |
31 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(FileSystemEntry); |
32 | 0 | } |
33 | | |
34 | | // https://wicg.github.io/entries-api/#dom-filesystementry-isfile |
35 | | bool FileSystemEntry::is_file() const |
36 | 0 | { |
37 | | // The isFile getter steps are to return true if this is a file entry and false otherwise. |
38 | 0 | return m_entry_type == EntryType::File; |
39 | 0 | } |
40 | | |
41 | | // https://wicg.github.io/entries-api/#dom-filesystementry-isdirectory |
42 | | bool FileSystemEntry::is_directory() const |
43 | 0 | { |
44 | | // The isDirectory getter steps are to return true if this is a directory entry and false otherwise. |
45 | 0 | return m_entry_type == EntryType::Directory; |
46 | 0 | } |
47 | | |
48 | | // https://wicg.github.io/entries-api/#dom-filesystementry-name |
49 | | ByteString FileSystemEntry::name() const |
50 | 0 | { |
51 | | // The name getter steps are to return this's name. |
52 | 0 | return m_name; |
53 | 0 | } |
54 | | |
55 | | } |