Serenity Operating System
1/*
2 * Copyright (c) 2022-2023, Kenneth Myhra <kennethmyhra@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <LibWeb/FileAPI/Blob.h>
10
11namespace Web::FileAPI {
12
13struct FilePropertyBag : BlobPropertyBag {
14 Optional<i64> last_modified;
15};
16
17class File : public Blob {
18 WEB_PLATFORM_OBJECT(File, Blob);
19
20public:
21 static WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> create(JS::Realm&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
22 static WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> construct_impl(JS::Realm&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
23
24 virtual ~File() override;
25
26 // https://w3c.github.io/FileAPI/#dfn-name
27 String const& name() const { return m_name; }
28 // https://w3c.github.io/FileAPI/#dfn-lastModified
29 i64 last_modified() const { return m_last_modified; }
30
31private:
32 File(JS::Realm&, ByteBuffer, String file_name, String type, i64 last_modified);
33
34 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
35
36 String m_name;
37 i64 m_last_modified { 0 };
38};
39
40}