File.h 1.1 KB

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