]> git.tdb.fi Git - libs/core.git/blobdiff - source/io/asset.h
Add a class for accessing applications assets
[libs/core.git] / source / io / asset.h
diff --git a/source/io/asset.h b/source/io/asset.h
new file mode 100644 (file)
index 0000000..d1d63b5
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef MSP_IO_ASSET_H_
+#define MSP_IO_ASSET_H_
+
+#include "seekable.h"
+
+namespace Msp {
+namespace IO {
+
+/**
+Opens a file from the application's assets.  On Android, this means the assets
+contained within the APK.  On other platfoms, assets are located in the
+directory indicated by FS::get_sys_data_dir().  Assets are always read-only.
+*/
+class Asset: public Seekable
+{
+private:
+       struct Private;
+
+       Private *priv;
+
+public:
+       Asset(const std::string &);
+       ~Asset();
+
+private:
+       virtual unsigned do_write(const char *, unsigned);
+       virtual unsigned do_read(char *, unsigned);
+
+public:
+       virtual SeekOffset seek(SeekOffset, SeekType);
+       virtual SeekOffset tell() const;
+};
+
+} // namespace IO
+} // namespace Msp
+
+#endif