From ccbe283bd39927b18cf17bb8dc778b9ddb449168 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Sun, 20 Oct 2019 16:38:29 +0200 Subject: [PATCH] IFileSystem and IFileArchive --- Makefile.am | 3 +++ include/IFileArchive.h | 56 ++++++++++++++++++++++++++++++++++++++++ include/IFileSystem.h | 45 ++++++++++++++++++++++++++++++++ include/IrrlichtDevice.h | 4 +++ include/cirrlicht.h | 2 ++ src/IFileSystem.cpp | 43 ++++++++++++++++++++++++++++++ src/IrrlichtDevice.cpp | 6 +++++ 7 files changed, 159 insertions(+) create mode 100644 include/IFileArchive.h create mode 100644 include/IFileSystem.h create mode 100644 src/IFileSystem.cpp diff --git a/Makefile.am b/Makefile.am index b2da572..336eacd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,7 @@ lib_LTLIBRARIES = libCIrrlicht.la libCIrrlicht_la_SOURCES = \ src/CIrrlicht.cpp \ src/IAnimatedMeshSceneNode.cpp \ + src/IFileSystem.cpp \ src/IGUIEnvironment.cpp \ src/IrrlichtDevice.cpp \ src/ISceneManager.cpp \ @@ -19,6 +20,8 @@ pkginclude_HEADERS = \ include/IAnimatedMeshMD2.h \ include/IAnimatedMeshSceneNode.h \ include/ICameraSceneNode.h \ + include/IFileArchive.h \ + include/IFileSystem.h \ include/IGUIElement.h \ include/IGUIEnvironment.h \ include/IGUIStaticText.h \ diff --git a/include/IFileArchive.h b/include/IFileArchive.h new file mode 100644 index 0000000..b3bcc2f --- /dev/null +++ b/include/IFileArchive.h @@ -0,0 +1,56 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + This file is part of c-irrlicht. + + c-irrlicht is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + c-irrlicht is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with guile-irrlicht. If not, see + . +*/ + +#ifndef __C_I_FILE_ARCHIVE_H_INCLUDED__ +#define __C_I_FILE_ARCHIVE_H_INCLUDED__ + +#include + +typedef enum + { + //! A PKZIP archive + EFAT_ZIP = MAKE_IRR_ID('Z','I','P', 0), + + //! A gzip archive + EFAT_GZIP = MAKE_IRR_ID('g','z','i','p'), + + //! A virtual directory + EFAT_FOLDER = MAKE_IRR_ID('f','l','d','r'), + + //! An ID Software PAK archive + EFAT_PAK = MAKE_IRR_ID('P','A','K', 0), + + //! A Nebula Device archive + EFAT_NPK = MAKE_IRR_ID('N','P','K', 0), + + //! A Tape ARchive + EFAT_TAR = MAKE_IRR_ID('T','A','R', 0), + + //! A wad Archive, Quake2, Halflife + EFAT_WAD = MAKE_IRR_ID('W','A','D', 0), + + //! The type of this archive is unknown + EFAT_UNKNOWN = MAKE_IRR_ID('u','n','k','n') + } irr_io_E_FILE_ARCHIVE_TYPE; + +typedef void irr_io_IFileArchive; + +#endif diff --git a/include/IFileSystem.h b/include/IFileSystem.h new file mode 100644 index 0000000..7b278d0 --- /dev/null +++ b/include/IFileSystem.h @@ -0,0 +1,45 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + This file is part of c-irrlicht. + + c-irrlicht is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + c-irrlicht is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with guile-irrlicht. If not, see + . +*/ + +#ifndef __C_I_FILE_SYSTEM_H_INCLUDED__ +#define __C_I_FILE_SYSTEM_H_INCLUDED__ + +#include "IFileArchive.h" + +typedef void irr_io_IFileSystem; + +#ifdef __cplusplus +extern "C" { +#endif + + int irr_io_addFileArchive(irr_io_IFileSystem* filesystem, + const char* filename, + int ignoreCase, + int ignorePaths, + irr_io_E_FILE_ARCHIVE_TYPE archiveType, + const char* password, + irr_io_IFileArchive** retArchive); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/IrrlichtDevice.h b/include/IrrlichtDevice.h index df717e7..72620c6 100644 --- a/include/IrrlichtDevice.h +++ b/include/IrrlichtDevice.h @@ -22,6 +22,7 @@ #ifndef __C_IRRLICHT_DEVICE_H_INCLUDED__ #define __C_IRRLICHT_DEVICE_H_INCLUDED__ +#include "IFileSystem.h" #include "IGUIEnvironment.h" #include "ISceneManager.h" #include "IVideoDriver.h" @@ -32,6 +33,9 @@ typedef void irr_IrrlichtDevice; extern "C" { #endif + irr_io_IFileSystem* + irr_getFileSystem(irr_IrrlichtDevice* device); + irr_gui_IGUIEnvironment* irr_getGUIEnvironment(irr_IrrlichtDevice* device); diff --git a/include/cirrlicht.h b/include/cirrlicht.h index a7a4622..3901e08 100644 --- a/include/cirrlicht.h +++ b/include/cirrlicht.h @@ -28,6 +28,8 @@ #include "IAnimatedMeshMD2.h" #include "IAnimatedMeshSceneNode.h" #include "ICameraSceneNode.h" +#include "IFileArchive.h" +#include "IFileSystem.h" #include "IGUIEnvironment.h" #include "IGUIElement.h" #include "IGUIStaticText.h" diff --git a/src/IFileSystem.cpp b/src/IFileSystem.cpp new file mode 100644 index 0000000..1cc7689 --- /dev/null +++ b/src/IFileSystem.cpp @@ -0,0 +1,43 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + This file is part of c-irrlicht. + + c-irrlicht is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + c-irrlicht is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with guile-irrlicht. If not, see + . +*/ + +#include +#include "IFileSystem.h" + +extern "C" { + int irr_io_addFileArchive(irr_io_IFileSystem* filesystem, + const char* filename, + int ignoreCase, + int ignorePaths, + irr_io_E_FILE_ARCHIVE_TYPE archiveType, + const char* password, + irr_io_IFileArchive** retArchive) + { + return ((irr::io::IFileSystem*)filesystem) + ->addFileArchive(filename, + ignoreCase, + ignorePaths, + (irr::io::E_FILE_ARCHIVE_TYPE)archiveType, + password, + (irr::io::IFileArchive**)retArchive); + } + +} diff --git a/src/IrrlichtDevice.cpp b/src/IrrlichtDevice.cpp index b877d25..98c4afb 100644 --- a/src/IrrlichtDevice.cpp +++ b/src/IrrlichtDevice.cpp @@ -24,6 +24,12 @@ #include "IrrlichtDevice.h" extern "C" { + irr_io_IFileSystem* + irr_getFileSystem(irr_IrrlichtDevice* device) + { + return ((irr::IrrlichtDevice*)device)->getFileSystem(); + } + irr_gui_IGUIEnvironment* irr_getGUIEnvironment(irr_IrrlichtDevice* device) { -- 2.39.2