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 +++++++++++++++++++++++++++++ src/libjin/Filesystem/je_asset_database.h | 31 +++++++++++++ src/libjin/Filesystem/je_buffer.h | 8 ++-- src/libjin/Filesystem/je_filesystem.cpp | 68 ----------------------------- src/libjin/Filesystem/je_filesystem.h | 31 ------------- 5 files changed, 103 insertions(+), 103 deletions(-) create mode 100644 src/libjin/Filesystem/je_asset_database.cpp create mode 100644 src/libjin/Filesystem/je_asset_database.h delete mode 100644 src/libjin/Filesystem/je_filesystem.cpp delete mode 100644 src/libjin/Filesystem/je_filesystem.h (limited to 'src/libjin/Filesystem') 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 diff --git a/src/libjin/Filesystem/je_asset_database.h b/src/libjin/Filesystem/je_asset_database.h new file mode 100644 index 0000000..ef16263 --- /dev/null +++ b/src/libjin/Filesystem/je_asset_database.h @@ -0,0 +1,31 @@ +#include "je_buffer.h" +#include "../3rdparty/smount/smount.h" + +namespace JinEngine +{ + namespace Filesystem + { + /* 资源管理 */ + class AssetDatabase + { + public: + static AssetDatabase* get(); + + AssetDatabase(); + + bool isDir(const char* path); + bool isFile(const char* path); + bool exists(const char* path); + int read(const char* path, Buffer* buffer); + void* read(const char* path, unsigned int* len); + void mount(const char* root); + const char* getFull(const char* path); + + private: + static AssetDatabase* fs; + smtShared* S; + + }; + + } // namespace Filesystem +} // namespace JinEngine \ No newline at end of file diff --git a/src/libjin/Filesystem/je_buffer.h b/src/libjin/Filesystem/je_buffer.h index 6ac9f4a..11faf79 100644 --- a/src/libjin/Filesystem/je_buffer.h +++ b/src/libjin/Filesystem/je_buffer.h @@ -4,9 +4,9 @@ #include #include -namespace jin +namespace JinEngine { - namespace filesystem + namespace Filesystem { /** @@ -61,7 +61,7 @@ namespace jin }; - } // namespace filesystem -} // namespace jin + } // namespace Filesystem +} // namespace JinEngine #endif \ No newline at end of file diff --git a/src/libjin/Filesystem/je_filesystem.cpp b/src/libjin/Filesystem/je_filesystem.cpp deleted file mode 100644 index 339d470..0000000 --- a/src/libjin/Filesystem/je_filesystem.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include /* defines FILENAME_MAX */ - -#include "je_filesystem.h" - -namespace jin -{ - namespace filesystem - { - - Filesystem* Filesystem::fs = 0; - - Filesystem::Filesystem() - { - S = smtnewshared(); - } - - Filesystem* Filesystem::get() - { - return fs ? fs : (fs = new Filesystem()); - } - - void Filesystem::mount(const char * path) - { - int err = smtmount(S, path); - if (err) - { - printf("%s mounted path %s", smterrstr(err), path); - exit(1); - } - } - - int Filesystem::read(const char* path, Buffer* buffer) - { - buffer->data = smtread(S, path, &buffer->size); - if (buffer->data == 0) - return 0; - return 1; - } - - void* Filesystem::read(const char* path, unsigned int* len) - { - return smtread(S, path, len); - } - - const char* Filesystem::getFull(const char* path) - { - return smtfullpath(S, path); - } - - bool Filesystem::isDir(const char* path) - { - return smtisdir(S, path); - } - - bool Filesystem::isFile(const char* path) - { - return smtisreg(S, path); - } - - bool Filesystem::exists(const char* path) - { - return smtexists(S, path) == 0; - } - - } // namespace filesystem -} // namespace jin \ No newline at end of file diff --git a/src/libjin/Filesystem/je_filesystem.h b/src/libjin/Filesystem/je_filesystem.h deleted file mode 100644 index 5d65fea..0000000 --- a/src/libjin/Filesystem/je_filesystem.h +++ /dev/null @@ -1,31 +0,0 @@ -#include "je_buffer.h" -#include "../3rdparty/smount/smount.h" - -namespace jin -{ - namespace filesystem - { - /* 资源管理 */ - class Filesystem - { - public: - static Filesystem* get(); - - Filesystem(); - - bool isDir(const char* path); - bool isFile(const char* path); - bool exists(const char* path); - int read(const char* path, Buffer* buffer); - void* read(const char* path, unsigned int* len); - void mount(const char* root); - const char* getFull(const char* path); - - private: - static Filesystem* fs; - smtShared* S; - - }; - - } // namespace filesystem -} // namespace jin \ No newline at end of file -- cgit v1.1-26-g67d0