File.h 1.2 KB

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