From: Mikko Rasa Date: Thu, 13 Nov 2014 20:46:14 +0000 (+0200) Subject: Move the generic file-based Asset implementation to a generic directory X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8a3d4f05f46bcd6dda9fc28794d4ac84d0d96f08;p=libs%2Fcore.git Move the generic file-based Asset implementation to a generic directory --- diff --git a/Build b/Build index fb10fd4..d940f4a 100644 --- a/Build +++ b/Build @@ -62,6 +62,7 @@ package "mspcore" { overlay "unix"; }; + overlay "generic"; install true; install_map { diff --git a/source/io/generic/asset.cpp b/source/io/generic/asset.cpp new file mode 100644 index 0000000..7971f1b --- /dev/null +++ b/source/io/generic/asset.cpp @@ -0,0 +1,47 @@ +#include +#include "asset.h" +#include "file.h" + +using namespace std; + +namespace Msp { +namespace IO { + +struct Asset::Private +{ + Seekable *file; +}; + +Asset::Asset(const string &name) +{ + Seekable *file = new BufferedFile((FS::get_sys_data_dir()/name).str()); + + priv = new Private; + priv->file = file; + + priv->file->signal_flush_required.connect(signal_flush_required); +} + +Asset::~Asset() +{ + delete priv->file; + delete priv; +} + +unsigned Asset::do_read(char *buf, unsigned size) +{ + return priv->file->read(buf, size); +} + +SeekOffset Asset::seek(SeekOffset off, SeekType type) +{ + return priv->file->seek(off, type); +} + +SeekOffset Asset::tell() const +{ + return priv->file->tell(); +} + +} // namespace IO +} // namespace Msp diff --git a/source/io/unix/asset.cpp b/source/io/unix/asset.cpp deleted file mode 100644 index 7971f1b..0000000 --- a/source/io/unix/asset.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include "asset.h" -#include "file.h" - -using namespace std; - -namespace Msp { -namespace IO { - -struct Asset::Private -{ - Seekable *file; -}; - -Asset::Asset(const string &name) -{ - Seekable *file = new BufferedFile((FS::get_sys_data_dir()/name).str()); - - priv = new Private; - priv->file = file; - - priv->file->signal_flush_required.connect(signal_flush_required); -} - -Asset::~Asset() -{ - delete priv->file; - delete priv; -} - -unsigned Asset::do_read(char *buf, unsigned size) -{ - return priv->file->read(buf, size); -} - -SeekOffset Asset::seek(SeekOffset off, SeekType type) -{ - return priv->file->seek(off, type); -} - -SeekOffset Asset::tell() const -{ - return priv->file->tell(); -} - -} // namespace IO -} // namespace Msp