2022-07-24 21:32:18 +02:00
|
|
|
/*
|
2023-02-25 10:27:38 +01:00
|
|
|
* Copyright (c) 2022-2023, Kenneth Myhra <kennethmyhra@serenityos.org>
|
2022-07-24 21:32:18 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibWeb/FileAPI/Blob.h>
|
|
|
|
|
|
|
|
namespace Web::FileAPI {
|
|
|
|
|
|
|
|
struct FilePropertyBag : BlobPropertyBag {
|
|
|
|
Optional<i64> last_modified;
|
|
|
|
};
|
|
|
|
|
|
|
|
class File : public Blob {
|
2022-09-04 11:44:38 +02:00
|
|
|
WEB_PLATFORM_OBJECT(File, Blob);
|
2023-11-19 19:47:52 +01:00
|
|
|
JS_DECLARE_ALLOCATOR(File);
|
2022-07-24 21:32:18 +02:00
|
|
|
|
|
|
|
public:
|
2023-02-25 10:27:38 +01:00
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> create(JS::Realm&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
|
|
|
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<File>> construct_impl(JS::Realm&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
|
2022-07-24 21:32:18 +02:00
|
|
|
|
2022-09-04 11:44:38 +02:00
|
|
|
virtual ~File() override;
|
2022-07-24 21:32:18 +02:00
|
|
|
|
|
|
|
// https://w3c.github.io/FileAPI/#dfn-name
|
2023-02-25 10:27:38 +01:00
|
|
|
String const& name() const { return m_name; }
|
2022-07-24 21:32:18 +02:00
|
|
|
// https://w3c.github.io/FileAPI/#dfn-lastModified
|
|
|
|
i64 last_modified() const { return m_last_modified; }
|
|
|
|
|
|
|
|
private:
|
2023-02-25 10:27:38 +01:00
|
|
|
File(JS::Realm&, ByteBuffer, String file_name, String type, i64 last_modified);
|
2022-07-24 21:32:18 +02:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2023-02-25 10:27:38 +01:00
|
|
|
String m_name;
|
2022-07-24 21:32:18 +02:00
|
|
|
i64 m_last_modified { 0 };
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|