]> git.tdb.fi Git - libs/core.git/blob - source/io/unix/asset.cpp
7971f1b0346eeff7d848ca1a2c7f67183e4a3d03
[libs/core.git] / source / io / unix / asset.cpp
1 #include <msp/fs/dir.h>
2 #include "asset.h"
3 #include "file.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace IO {
9
10 struct Asset::Private
11 {
12         Seekable *file;
13 };
14
15 Asset::Asset(const string &name)
16 {
17         Seekable *file = new BufferedFile((FS::get_sys_data_dir()/name).str());
18
19         priv = new Private;
20         priv->file = file;
21
22         priv->file->signal_flush_required.connect(signal_flush_required);
23 }
24
25 Asset::~Asset()
26 {
27         delete priv->file;
28         delete priv;
29 }
30
31 unsigned Asset::do_read(char *buf, unsigned size)
32 {
33         return priv->file->read(buf, size);
34 }
35
36 SeekOffset Asset::seek(SeekOffset off, SeekType type)
37 {
38         return priv->file->seek(off, type);
39 }
40
41 SeekOffset Asset::tell() const
42 {
43         return priv->file->tell();
44 }
45
46 } // namespace IO
47 } // namespace Msp