diff options
Diffstat (limited to 'src/libjin/filesystem')
-rw-r--r-- | src/libjin/filesystem/je_asset_database.cpp | 100 | ||||
-rw-r--r-- | src/libjin/filesystem/je_asset_database.h | 32 | ||||
-rw-r--r-- | src/libjin/filesystem/je_buffer.h | 74 |
3 files changed, 103 insertions, 103 deletions
diff --git a/src/libjin/filesystem/je_asset_database.cpp b/src/libjin/filesystem/je_asset_database.cpp index a8524c5..1203643 100644 --- a/src/libjin/filesystem/je_asset_database.cpp +++ b/src/libjin/filesystem/je_asset_database.cpp @@ -11,75 +11,75 @@ namespace JinEngine { - namespace Filesystem - { + namespace Filesystem + { - AssetDatabase* AssetDatabase::mAssetDatabase = 0; + AssetDatabase* AssetDatabase::mAssetDatabase = 0; - AssetDatabase::AssetDatabase() - { + AssetDatabase::AssetDatabase() + { mSmt = smtnewshared(); - } - - AssetDatabase* AssetDatabase::get() - { - return mAssetDatabase ? mAssetDatabase : (mAssetDatabase = new AssetDatabase()); - } - - void AssetDatabase::mount(const char * path) - { - int err = smtmount(mSmt, path); - if (err) - { - printf("%s mounted path %s", smterrstr(err), path); - exit(1); - } - } - - void AssetDatabase::read(const char* path, Buffer& buffer) - { + } + + AssetDatabase* AssetDatabase::get() + { + return mAssetDatabase ? mAssetDatabase : (mAssetDatabase = new AssetDatabase()); + } + + void AssetDatabase::mount(const char * path) + { + int err = smtmount(mSmt, path); + if (err) + { + printf("%s mounted path %s", smterrstr(err), path); + exit(1); + } + } + + void AssetDatabase::read(const char* path, Buffer& buffer) + { size_t size; byte* data = (byte*)smtread(mSmt, path, &size); if (data == nullptr) throw Exception("Could not read file %s.", path); buffer.bind(data, size); - } + } Buffer* read(const char* path) { return nullptr; } - void* AssetDatabase::read(const char* path, unsigned int* len) - { - return smtread(mSmt, path, len); - } - - const char* AssetDatabase::getFull(const char* path) - { - return smtfullpath(mSmt, path); - } - - bool AssetDatabase::isDir(const char* path) - { - return smtisdir(mSmt, path); - } - - bool AssetDatabase::isFile(const char* path) - { - return smtisreg(mSmt, path); - } - - bool AssetDatabase::exists(const char* path) - { - return smtexists(mSmt, path) == 0; - } + void* AssetDatabase::read(const char* path, unsigned int* len) + { + return smtread(mSmt, path, len); + } + + const char* AssetDatabase::getFull(const char* path) + { + return smtfullpath(mSmt, path); + } + + bool AssetDatabase::isDir(const char* path) + { + return smtisdir(mSmt, path); + } + + bool AssetDatabase::isFile(const char* path) + { + return smtisreg(mSmt, path); + } + + bool AssetDatabase::exists(const char* path) + { + return smtexists(mSmt, path) == 0; + } /* std::vector<std::string> AssetDatabase::getFiles(const char* path, bool recursive) { } */ - } // namespace Filesystem + } // namespace Filesystem } // namespace JinEngine #endif // jin_filesystem
\ No newline at end of file diff --git a/src/libjin/filesystem/je_asset_database.h b/src/libjin/filesystem/je_asset_database.h index 2e029ff..82d5ab4 100644 --- a/src/libjin/filesystem/je_asset_database.h +++ b/src/libjin/filesystem/je_asset_database.h @@ -12,21 +12,21 @@ namespace JinEngine { - namespace Filesystem - { + namespace Filesystem + { /// /// Assets managment. /// class AssetDatabase : public Object - { - public: + { + public: /// /// Get asset database singleton. /// /// @param Singleton of asset database. /// - static AssetDatabase* get(); + static AssetDatabase* get(); /// /// Asset database constructor. @@ -46,7 +46,7 @@ namespace JinEngine /// @param path Path under asset folder. /// @return True if the given path is directory, otherwise return false. /// - bool isDir(const char* path); + bool isDir(const char* path); /// /// Check if the path is file. @@ -54,14 +54,14 @@ namespace JinEngine /// @param path Path under asset folder. /// @return True if the given path is file, otherwise return false. /// - bool isFile(const char* path); + bool isFile(const char* path); /// /// Check if the path exists. /// @param path Given path. /// @return True if path exists, otherwise return false. /// - bool exists(const char* path); + bool exists(const char* path); /// /// Read file into a buffer. @@ -70,7 +70,7 @@ namespace JinEngine /// @param buffer Buffer to fill. /// @return True if read sucessful, otherwise return false. /// - void read(const char* path, Buffer& buffer); + void read(const char* path, Buffer& buffer); /// /// Read file and return data content. @@ -79,7 +79,7 @@ namespace JinEngine /// @param length Length of data. /// @return Data if read sucessful, otherwise return null. /// - void* read(const char* path, unsigned int* length); + void* read(const char* path, unsigned int* length); /// /// Get files under given directory. @@ -96,17 +96,17 @@ namespace JinEngine /// @param path Path of asset. /// @return Full path of asset. /// - const char* getFull(const char* path); + const char* getFull(const char* path); - private: - static AssetDatabase* mAssetDatabase; + private: + static AssetDatabase* mAssetDatabase; #if jin_filesystem == jin_filesystem_smount - smtShared* mSmt; + smtShared* mSmt; #endif - }; + }; - } // namespace Filesystem + } // namespace Filesystem } // namespace JinEngine #endif // jin_filesystem diff --git a/src/libjin/filesystem/je_buffer.h b/src/libjin/filesystem/je_buffer.h index 1111e49..b3c6612 100644 --- a/src/libjin/filesystem/je_buffer.h +++ b/src/libjin/filesystem/je_buffer.h @@ -12,19 +12,19 @@ namespace JinEngine { - namespace Filesystem - { + namespace Filesystem + { /// /// Data buffer allocated on heap. /// - class Buffer : public Temporary - { - public: + class Buffer : public Temporary + { + public: /// /// Buffer constructor. /// - Buffer() + Buffer() : mData(0) , mSize(0) { @@ -35,13 +35,13 @@ namespace JinEngine /// /// @param src Buffer source. /// - Buffer(const Buffer& src) - { - delete[] mData; - mSize = src.mSize; - mData = new byte[mSize]; - memcpy(mData, src.mData, mSize); - } + Buffer(const Buffer& src) + { + delete[] mData; + mSize = src.mSize; + mData = new byte[mSize]; + memcpy(mData, src.mData, mSize); + } /// /// Buffer constructor. @@ -49,33 +49,33 @@ namespace JinEngine /// @param data Buffer data. /// @param size Size of buffer. /// - Buffer(void* data, int size) - { + Buffer(void* data, int size) + { mSize = size; mData = new byte[mSize]; - memcpy(mData, data, mSize); - } + memcpy(mData, data, mSize); + } /// /// Buffer constructor. /// /// @param size Size of data. /// - Buffer(size_t size) - { + Buffer(size_t size) + { mData = new byte[size]; - memset(mData, 0, size); + memset(mData, 0, size); mSize = size; - } + } /// /// Buffer destructor. /// - ~Buffer() - { - delete[] mData; + ~Buffer() + { + delete[] mData; mSize = 0; - } + } /// /// Set buffer data. @@ -115,13 +115,13 @@ namespace JinEngine /// /// @param buffer Buffer to copy. /// - void operator = (const Buffer& buffer) - { - delete[] mData; + void operator = (const Buffer& buffer) + { + delete[] mData; mSize = buffer.mSize; mData = new byte[mSize]; - memcpy(mData, buffer.mData, mSize); - } + memcpy(mData, buffer.mData, mSize); + } /// /// Get data addresss. @@ -146,22 +146,22 @@ namespace JinEngine /// /// Clear data. /// - void clear() - { - if (mData == nullptr) - return; + void clear() + { + if (mData == nullptr) + return; delete mData; mData = nullptr; mSize = 0; - } + } private: byte* mData; size_t mSize; - }; + }; - } // namespace Filesystem + } // namespace Filesystem } // namespace JinEngine #endif // jin_filesystem |