From 7d5f055547e70fa93ee9ac944e62f8d657b9dc55 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 19 Oct 2018 08:36:44 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/Filesystem/je_filesystem.cpp | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/libjin/Filesystem/je_filesystem.cpp (limited to 'src/libjin/Filesystem/je_filesystem.cpp') diff --git a/src/libjin/Filesystem/je_filesystem.cpp b/src/libjin/Filesystem/je_filesystem.cpp new file mode 100644 index 0000000..339d470 --- /dev/null +++ b/src/libjin/Filesystem/je_filesystem.cpp @@ -0,0 +1,68 @@ +#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 -- cgit v1.1-26-g67d0