ResourceImplementation.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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 NonnullRefPtr<Resource> make_resource(String full_path, NonnullOwnPtr<Core::MappedFile>, time_t modified_time);
  24. static NonnullRefPtr<Resource> make_resource(String full_path, ByteBuffer, time_t modified_time);
  25. static NonnullRefPtr<Resource> make_directory_resource(String full_path, time_t modified_time);
  26. };
  27. }