From e9410bd371fc68169c57d2c52382948a0b083da4 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 20 Oct 2018 15:50:06 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E5=90=8D=E7=A7=B0=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/Filesystem/je_asset_database.cpp | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/libjin/Filesystem/je_asset_database.cpp (limited to 'src/libjin/Filesystem/je_asset_database.cpp') diff --git a/src/libjin/Filesystem/je_asset_database.cpp b/src/libjin/Filesystem/je_asset_database.cpp new file mode 100644 index 0000000..c945d6a --- /dev/null +++ b/src/libjin/Filesystem/je_asset_database.cpp @@ -0,0 +1,68 @@ +#include +#include +#include /* defines FILENAME_MAX */ + +#include "je_asset_database.h" + +namespace JinEngine +{ + namespace Filesystem + { + + AssetDatabase* AssetDatabase::fs = 0; + + AssetDatabase::AssetDatabase() + { + S = smtnewshared(); + } + + AssetDatabase* AssetDatabase::get() + { + return fs ? fs : (fs = new AssetDatabase()); + } + + void AssetDatabase::mount(const char * path) + { + int err = smtmount(S, path); + if (err) + { + printf("%s mounted path %s", smterrstr(err), path); + exit(1); + } + } + + int AssetDatabase::read(const char* path, Buffer* buffer) + { + buffer->data = smtread(S, path, &buffer->size); + if (buffer->data == 0) + return 0; + return 1; + } + + void* AssetDatabase::read(const char* path, unsigned int* len) + { + return smtread(S, path, len); + } + + const char* AssetDatabase::getFull(const char* path) + { + return smtfullpath(S, path); + } + + bool AssetDatabase::isDir(const char* path) + { + return smtisdir(S, path); + } + + bool AssetDatabase::isFile(const char* path) + { + return smtisreg(S, path); + } + + bool AssetDatabase::exists(const char* path) + { + return smtexists(S, path) == 0; + } + + } // namespace Filesystem +} // namespace JinEngine \ No newline at end of file -- cgit v1.1-26-g67d0