aboutsummaryrefslogtreecommitdiff
path: root/src/irrlicht/RezLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/irrlicht/RezLoader.cpp')
-rw-r--r--src/irrlicht/RezLoader.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/irrlicht/RezLoader.cpp b/src/irrlicht/RezLoader.cpp
new file mode 100644
index 0000000..118a96d
--- /dev/null
+++ b/src/irrlicht/RezLoader.cpp
@@ -0,0 +1,56 @@
+#include <RezLoader.h>
+#include <RezArchive.h>
+#include <rez.h>
+#include <irrlicht.h>
+#include <cstring>
+
+bool RezLoader::isALoadableFileFormat(const irr::io::path &filename) const
+{
+ return irr::core::hasFileExtension(filename, "rez");
+}
+
+bool RezLoader::isALoadableFileFormat(irr::io::IReadFile *file) const
+{
+ char buf[sizeof rez::ball::title], *p = buf;
+ size_t rem = sizeof buf;
+
+ while (rem)
+ {
+ irr::s32 n = file->read(p, rem);
+
+ if (n < 0)
+ return false;
+
+ p += n;
+ rem -= n;
+ }
+
+ return !strcmp(buf, rez::ball::title);
+}
+
+bool RezLoader::isALoadableFileFormat(irr::io::E_FILE_ARCHIVE_TYPE fileType) const
+{
+ return fileType == static_cast<irr::io::E_FILE_ARCHIVE_TYPE>
+ (MAKE_IRR_ID('r', 'e', 'z', 0));
+}
+
+irr::io::IFileArchive *RezLoader::createArchive(const irr::io::path &filename,
+ bool ignoreCase, bool ignorePaths) const
+{
+ RezArchive *archive = new RezArchive(filename);
+
+ if (archive->parse())
+ {
+ delete archive;
+ return nullptr;
+ }
+
+ return archive;
+}
+
+irr::io::IFileArchive *RezLoader::createArchive(irr::io::IReadFile *file,
+ bool ignoreCase, bool ignorePaths) const
+{
+ // TODO: how to do that?
+ return nullptr;
+}