The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.7KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. namespace juce
  18. {
  19. //==============================================================================
  20. /**
  21. An InputSource backed by an AndroidDocument.
  22. @see InputSource, AndroidDocument
  23. @tags{Core}
  24. */
  25. class JUCE_API AndroidDocumentInputSource : public InputSource
  26. {
  27. public:
  28. //==============================================================================
  29. /** Creates a new AndroidDocumentInputSource, backed by the provided document.
  30. */
  31. explicit AndroidDocumentInputSource (const AndroidDocument& doc)
  32. : document (doc) {}
  33. //==============================================================================
  34. /** Returns a new InputStream to read this item.
  35. @returns an inputstream that the caller will delete, or nullptr if
  36. the document can't be opened.
  37. */
  38. InputStream* createInputStream() override
  39. {
  40. return document.createInputStream().release();
  41. }
  42. /** @internal
  43. An AndroidDocument doesn't use conventional filesystem paths.
  44. Use the member functions of AndroidDocument to locate relative items.
  45. @param relatedItemPath the relative pathname of the resource that is required
  46. @returns an input stream if relatedItemPath was empty, otherwise
  47. nullptr.
  48. */
  49. InputStream* createInputStreamFor (const String& relatedItemPath) override
  50. {
  51. return relatedItemPath.isEmpty() ? document.createInputStream().release() : nullptr;
  52. }
  53. /** Returns a hash code that uniquely represents this item.
  54. */
  55. int64 hashCode() const override
  56. {
  57. return document.getUrl().toString (true).hashCode64();
  58. }
  59. private:
  60. AndroidDocument document;
  61. };
  62. } // namespace juce