]> git.tdb.fi Git - libs/core.git/blob - source/io/asset.h
Add move semantics to Variant
[libs/core.git] / source / io / asset.h
1 #ifndef MSP_IO_ASSET_H_
2 #define MSP_IO_ASSET_H_
3
4 #include <msp/core/mspcore_api.h>
5 #include "seekable.h"
6
7 namespace Msp {
8 namespace IO {
9
10 /**
11 Opens a file from the application's assets.  On Android, this means the assets
12 contained within the APK.  On other platfoms, assets are located in the
13 directory indicated by FS::get_sys_data_dir().  Assets are always read-only.
14 */
15 class MSPCORE_API Asset: public Seekable
16 {
17 private:
18         struct Private;
19
20         Private *priv = nullptr;
21
22 public:
23         Asset(const std::string &);
24         ~Asset();
25
26         void set_block(bool) override;
27         void set_inherit(bool) override;
28
29 private:
30         std::size_t do_write(const char *, std::size_t) override;
31         std::size_t do_read(char *, std::size_t) override;
32
33 public:
34         const Handle &get_handle(Mode) override;
35
36         SeekOffset seek(SeekOffset, SeekType) override;
37         SeekOffset tell() const override;
38 };
39
40 } // namespace IO
41 } // namespace Msp
42
43 #endif