AndroidAssetStream.h#

Parent directory (Android)

A Stream implementation used to access Android resources.

Includes#

  • PVRCore/stream/Stream.h

Namespaces#

Classes#

Source Code#

#pragma once
#include "PVRCore/stream/Stream.h"

struct AAssetManager;
struct AAsset;

namespace pvr {
class AndroidAssetStream : public Stream
{
public:
    AndroidAssetStream(AAssetManager* assetManager, const std::string& filename) : Stream(filename, true, false, true), assetManager(assetManager), _asset(NULL) { open(); }

    ~AndroidAssetStream() { close(); }

    void _read(size_t size, size_t count, void* const outData, size_t& outElementsRead) const override;
    void _write(size_t size, size_t count, const void* data, size_t& dataWritten) override;
    void _seek(long offset, SeekOrigin origin) const override;
    uint64_t _getPosition() const override;
    uint64_t _getSize() const override;
    void open() const;
    void close();

    AAssetManager* getAndroidAssetManager() { return assetManager; }

private:
    AAssetManager* const assetManager;
    mutable AAsset* _asset;
};
} // namespace pvr