ResourceImplementation.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/RefPtr.h>
  8. #include <AK/StringView.h>
  9. #include <LibCore/Resource.h>
  10. namespace Core {
  11. class ResourceImplementation {
  12. public:
  13. ErrorOr<NonnullRefPtr<Resource>> load_from_uri(StringView);
  14. Vector<String> child_names(Resource const&);
  15. String filesystem_path(Resource const&);
  16. virtual ~ResourceImplementation() = default;
  17. static void install(OwnPtr<ResourceImplementation>);
  18. static ResourceImplementation& the();
  19. protected:
  20. virtual ErrorOr<NonnullRefPtr<Resource>> load_from_resource_scheme_uri(StringView) = 0;
  21. virtual Vector<String> child_names_for_resource_scheme(Resource const&) = 0;
  22. virtual String filesystem_path_for_resource_scheme(String const&) = 0;
  23. static bool is_directory(StringView filesystem_path);
  24. static NonnullRefPtr<Resource> make_resource(String full_path, NonnullOwnPtr<Core::MappedFile>);
  25. static NonnullRefPtr<Resource> make_resource(String full_path, ByteBuffer);
  26. static NonnullRefPtr<Resource> make_directory_resource(String full_path);
  27. };
  28. }