X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Ffile-archive.cpp;fp=src%2Ffile-archive.cpp;h=97d842bbe02b6978e3960992dac937cdddeba0a1;hb=bdd3bebca0131db5ecaf7219b6019ee267468538;hp=0000000000000000000000000000000000000000;hpb=f215da151462c3d0fe9bacc535083529ba43e716;p=guile-irrlicht.git diff --git a/src/file-archive.cpp b/src/file-archive.cpp new file mode 100644 index 0000000..97d842b --- /dev/null +++ b/src/file-archive.cpp @@ -0,0 +1,81 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + This file is part of guile-irrlicht. + + guile-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. + + guile-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 +#include "file-archive.h" + +extern "C" { + + void + init_file_archive (void) + { + init_file_archive_type (); + } + + DEFINE_WRAPPED_TYPE (irr::io::IFileArchive*, "file-archive", + init_file_archive_type, file_archive_p, + wrap_file_archive, unwrap_file_archive); + + irr::io::E_FILE_ARCHIVE_TYPE + scm_to_file_archive_type (SCM file_archive_type) + { + char* type = scm_to_utf8_stringn (scm_symbol_to_string (file_archive_type), NULL); + if (!strcmp (type, "zip")) + { + return irr::io::EFAT_ZIP; + } + else if (!strcmp (type, "gzip")) + { + return irr::io::EFAT_GZIP; + } + else if (!strcmp (type, "folder")) + { + return irr::io::EFAT_FOLDER; + } + else if (!strcmp (type, "pak")) + { + return irr::io::EFAT_PAK; + } + else if (!strcmp (type, "npk")) + { + return irr::io::EFAT_NPK; + } + else if (!strcmp (type, "tar")) + { + return irr::io::EFAT_TAR; + } + else if (!strcmp (type, "wad")) + { + return irr::io::EFAT_WAD; + } + else if (!strcmp (type, "unknown")) + { + return irr::io::EFAT_UNKNOWN; + } + else + { + scm_error (scm_arg_type_key, NULL, "Wrong file archive type: ~S", + scm_list_1 (file_archive_type), scm_list_1 (file_archive_type)); + } + } + +}