File.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. public:
  15. using WrapperType = Bindings::FileWrapper;
  16. static DOM::ExceptionOr<NonnullRefPtr<File>> create(Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
  17. static DOM::ExceptionOr<NonnullRefPtr<File>> create_with_global_object(Bindings::WindowObject&, Vector<BlobPart> const& file_bits, String const& file_name, Optional<FilePropertyBag> const& options = {});
  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(ByteBuffer byte_buffer, String file_name, String type, i64 last_modified);
  24. String m_name;
  25. i64 m_last_modified { 0 };
  26. };
  27. }