libwz 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/binding.gyp +149 -0
- package/deps/tiny-aes/.github/workflows/c-cpp.yml +27 -0
- package/deps/tiny-aes/CMakeLists.txt +17 -0
- package/deps/tiny-aes/Makefile +61 -0
- package/deps/tiny-aes/README.md +83 -0
- package/deps/tiny-aes/aes.c +572 -0
- package/deps/tiny-aes/aes.h +91 -0
- package/deps/tiny-aes/aes.hpp +12 -0
- package/deps/tiny-aes/conanfile.py +73 -0
- package/deps/tiny-aes/library.json +19 -0
- package/deps/tiny-aes/library.properties +11 -0
- package/deps/tiny-aes/test.c +316 -0
- package/deps/tiny-aes/test.cpp +2 -0
- package/deps/tiny-aes/test_package/CMakeLists.txt +11 -0
- package/deps/tiny-aes/test_package/conanfile.py +17 -0
- package/deps/tiny-aes/unlicense.txt +24 -0
- package/deps/zlib/.cmake-format.yaml +245 -0
- package/deps/zlib/.github/workflows/c-std.yml +268 -0
- package/deps/zlib/.github/workflows/cmake.yml +147 -0
- package/deps/zlib/.github/workflows/configure.yml +146 -0
- package/deps/zlib/.github/workflows/contribs.yml +64 -0
- package/deps/zlib/.github/workflows/fuzz.yml +25 -0
- package/deps/zlib/.github/workflows/msys-cygwin.yml +92 -0
- package/deps/zlib/.github/workflows/others.yml +153 -0
- package/deps/zlib/BUILD.bazel +134 -0
- package/deps/zlib/CMakeLists.txt +310 -0
- package/deps/zlib/ChangeLog +1669 -0
- package/deps/zlib/FAQ +371 -0
- package/deps/zlib/INDEX +67 -0
- package/deps/zlib/LICENSE +22 -0
- package/deps/zlib/MODULE.bazel +9 -0
- package/deps/zlib/Makefile.in +426 -0
- package/deps/zlib/README +115 -0
- package/deps/zlib/README-cmake.md +79 -0
- package/deps/zlib/adler32.c +164 -0
- package/deps/zlib/amiga/Makefile.pup +69 -0
- package/deps/zlib/amiga/Makefile.sas +68 -0
- package/deps/zlib/compress.c +99 -0
- package/deps/zlib/configure +1078 -0
- package/deps/zlib/contrib/CMakeLists.txt +61 -0
- package/deps/zlib/contrib/README.contrib +57 -0
- package/deps/zlib/contrib/ada/CMakeLists.txt +217 -0
- package/deps/zlib/contrib/ada/buffer_demo.adb +106 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADACompiler.cmake.in +23 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADAInformation.cmake +133 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeDetermineADACompiler.cmake +33 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeTestADACompiler.cmake +46 -0
- package/deps/zlib/contrib/ada/cmake/binder_helper.cmake +47 -0
- package/deps/zlib/contrib/ada/cmake/compile_helper.cmake +32 -0
- package/deps/zlib/contrib/ada/cmake/exe_link_helper.cmake +53 -0
- package/deps/zlib/contrib/ada/cmake/shared_link_helper.cmake +52 -0
- package/deps/zlib/contrib/ada/cmake/static_link_helper.cmake +25 -0
- package/deps/zlib/contrib/ada/mtest.adb +156 -0
- package/deps/zlib/contrib/ada/read.adb +156 -0
- package/deps/zlib/contrib/ada/readme.txt +65 -0
- package/deps/zlib/contrib/ada/test.adb +463 -0
- package/deps/zlib/contrib/ada/zlib-streams.adb +225 -0
- package/deps/zlib/contrib/ada/zlib-streams.ads +114 -0
- package/deps/zlib/contrib/ada/zlib-thin.adb +142 -0
- package/deps/zlib/contrib/ada/zlib-thin.ads +450 -0
- package/deps/zlib/contrib/ada/zlib.adb +701 -0
- package/deps/zlib/contrib/ada/zlib.ads +328 -0
- package/deps/zlib/contrib/ada/zlib.gpr +20 -0
- package/deps/zlib/contrib/blast/CMakeLists.txt +166 -0
- package/deps/zlib/contrib/blast/Makefile +14 -0
- package/deps/zlib/contrib/blast/README +4 -0
- package/deps/zlib/contrib/blast/blast-test.c +42 -0
- package/deps/zlib/contrib/blast/blast.c +422 -0
- package/deps/zlib/contrib/blast/blast.h +84 -0
- package/deps/zlib/contrib/blast/blastConfig.cmake.in +18 -0
- package/deps/zlib/contrib/blast/test/CMakeLists.txt +193 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/blast/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test.pk +0 -0
- package/deps/zlib/contrib/blast/test.txt +1 -0
- package/deps/zlib/contrib/blast/tester.cmake +28 -0
- package/deps/zlib/contrib/crc32vx/CMakeLists.txt +67 -0
- package/deps/zlib/contrib/crc32vx/README +9 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx.c +254 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx_hooks.h +9 -0
- package/deps/zlib/contrib/delphi/ZLib.pas +557 -0
- package/deps/zlib/contrib/delphi/ZLibConst.pas +11 -0
- package/deps/zlib/contrib/delphi/readme.txt +76 -0
- package/deps/zlib/contrib/delphi/zlibd32.mak +99 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.build +33 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.chm +0 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.sln +21 -0
- package/deps/zlib/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- package/deps/zlib/contrib/dotzlib/readme.txt +58 -0
- package/deps/zlib/contrib/gcc_gvmat64/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/gcc_gvmat64/gvmat64.S +570 -0
- package/deps/zlib/contrib/infback9/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/infback9/README +1 -0
- package/deps/zlib/contrib/infback9/infback9.c +603 -0
- package/deps/zlib/contrib/infback9/infback9.h +37 -0
- package/deps/zlib/contrib/infback9/inffix9.h +107 -0
- package/deps/zlib/contrib/infback9/inflate9.h +47 -0
- package/deps/zlib/contrib/infback9/inftree9.c +319 -0
- package/deps/zlib/contrib/infback9/inftree9.h +61 -0
- package/deps/zlib/contrib/iostream/test.cpp +24 -0
- package/deps/zlib/contrib/iostream/zfstream.cpp +329 -0
- package/deps/zlib/contrib/iostream/zfstream.h +128 -0
- package/deps/zlib/contrib/iostream2/zstream.h +306 -0
- package/deps/zlib/contrib/iostream2/zstream_test.cpp +25 -0
- package/deps/zlib/contrib/iostream3/CMakeLists.txt +200 -0
- package/deps/zlib/contrib/iostream3/README +35 -0
- package/deps/zlib/contrib/iostream3/TODO +17 -0
- package/deps/zlib/contrib/iostream3/iostream3Config.cmake.in +23 -0
- package/deps/zlib/contrib/iostream3/test/CMakeLists.txt +191 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/iostream3/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test.cc +50 -0
- package/deps/zlib/contrib/iostream3/zfstream.cc +479 -0
- package/deps/zlib/contrib/iostream3/zfstream.h +466 -0
- package/deps/zlib/contrib/minizip/CMakeLists.txt +387 -0
- package/deps/zlib/contrib/minizip/LICENSE.Info-Zip +58 -0
- package/deps/zlib/contrib/minizip/Makefile +33 -0
- package/deps/zlib/contrib/minizip/Makefile.am +45 -0
- package/deps/zlib/contrib/minizip/MiniZip64_Changes.txt +6 -0
- package/deps/zlib/contrib/minizip/MiniZip64_info.txt +69 -0
- package/deps/zlib/contrib/minizip/configure.ac +32 -0
- package/deps/zlib/contrib/minizip/crypt.h +125 -0
- package/deps/zlib/contrib/minizip/ints.h +57 -0
- package/deps/zlib/contrib/minizip/ioapi.c +231 -0
- package/deps/zlib/contrib/minizip/ioapi.h +183 -0
- package/deps/zlib/contrib/minizip/iowin32.c +447 -0
- package/deps/zlib/contrib/minizip/iowin32.h +27 -0
- package/deps/zlib/contrib/minizip/make_vms.com +25 -0
- package/deps/zlib/contrib/minizip/miniunz.c +647 -0
- package/deps/zlib/contrib/minizip/miniunzip.1 +63 -0
- package/deps/zlib/contrib/minizip/minizip.1 +46 -0
- package/deps/zlib/contrib/minizip/minizip.c +511 -0
- package/deps/zlib/contrib/minizip/minizip.pc.in +13 -0
- package/deps/zlib/contrib/minizip/minizip.pc.txt +13 -0
- package/deps/zlib/contrib/minizip/minizipConfig.cmake.in +27 -0
- package/deps/zlib/contrib/minizip/mztools.c +294 -0
- package/deps/zlib/contrib/minizip/mztools.h +37 -0
- package/deps/zlib/contrib/minizip/skipset.h +366 -0
- package/deps/zlib/contrib/minizip/test/CMakeLists.txt +176 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/contrib/minizip/test/find_package_no_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_wrong_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/test_helper.cm +32 -0
- package/deps/zlib/contrib/minizip/unzip.c +1984 -0
- package/deps/zlib/contrib/minizip/unzip.h +442 -0
- package/deps/zlib/contrib/minizip/zip.c +2246 -0
- package/deps/zlib/contrib/minizip/zip.h +371 -0
- package/deps/zlib/contrib/nuget/nuget.csproj +45 -0
- package/deps/zlib/contrib/nuget/nuget.sln +22 -0
- package/deps/zlib/contrib/pascal/example.pas +599 -0
- package/deps/zlib/contrib/pascal/readme.txt +76 -0
- package/deps/zlib/contrib/pascal/zlibd32.mak +99 -0
- package/deps/zlib/contrib/pascal/zlibpas.pas +276 -0
- package/deps/zlib/contrib/puff/CMakeLists.txt +154 -0
- package/deps/zlib/contrib/puff/Makefile +42 -0
- package/deps/zlib/contrib/puff/README +63 -0
- package/deps/zlib/contrib/puff/bin-writer.c +26 -0
- package/deps/zlib/contrib/puff/puff.c +840 -0
- package/deps/zlib/contrib/puff/puff.h +35 -0
- package/deps/zlib/contrib/puff/puffConfig.cmake.in +18 -0
- package/deps/zlib/contrib/puff/pufftest.c +168 -0
- package/deps/zlib/contrib/puff/test/CMakeLists.txt +262 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_exclude_test.cmake.in +26 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/puff/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/tester-cov.cmake +58 -0
- package/deps/zlib/contrib/puff/test/tester.cmake +16 -0
- package/deps/zlib/contrib/puff/zeros.raw +0 -0
- package/deps/zlib/contrib/testzlib/CMakeLists.txt +44 -0
- package/deps/zlib/contrib/testzlib/testzlib.c +275 -0
- package/deps/zlib/contrib/testzlib/testzlib.txt +10 -0
- package/deps/zlib/contrib/vstudio/readme.txt +22 -0
- package/deps/zlib/contrib/zlib1-dll/CMakeLists.txt +196 -0
- package/deps/zlib/contrib/zlib1-dll/readme.txt +21 -0
- package/deps/zlib/crc32.c +983 -0
- package/deps/zlib/crc32.h +9446 -0
- package/deps/zlib/deflate.c +2185 -0
- package/deps/zlib/deflate.h +383 -0
- package/deps/zlib/doc/algorithm.txt +209 -0
- package/deps/zlib/doc/crc-doc.1.0.pdf +0 -0
- package/deps/zlib/doc/rfc1950.txt +619 -0
- package/deps/zlib/doc/rfc1951.txt +955 -0
- package/deps/zlib/doc/rfc1952.txt +675 -0
- package/deps/zlib/doc/txtvsbin.txt +107 -0
- package/deps/zlib/examples/README.examples +54 -0
- package/deps/zlib/examples/enough.c +597 -0
- package/deps/zlib/examples/fitblk.c +233 -0
- package/deps/zlib/examples/gun.c +702 -0
- package/deps/zlib/examples/gzappend.c +504 -0
- package/deps/zlib/examples/gzjoin.c +449 -0
- package/deps/zlib/examples/gzlog.c +1061 -0
- package/deps/zlib/examples/gzlog.h +91 -0
- package/deps/zlib/examples/gznorm.c +474 -0
- package/deps/zlib/examples/zlib_how.html +550 -0
- package/deps/zlib/examples/zpipe.c +206 -0
- package/deps/zlib/examples/zran.c +546 -0
- package/deps/zlib/examples/zran.h +53 -0
- package/deps/zlib/gzclose.c +23 -0
- package/deps/zlib/gzguts.h +216 -0
- package/deps/zlib/gzlib.c +609 -0
- package/deps/zlib/gzread.c +668 -0
- package/deps/zlib/gzwrite.c +700 -0
- package/deps/zlib/infback.c +581 -0
- package/deps/zlib/inffast.c +321 -0
- package/deps/zlib/inffast.h +11 -0
- package/deps/zlib/inffixed.h +94 -0
- package/deps/zlib/inflate.c +1413 -0
- package/deps/zlib/inflate.h +126 -0
- package/deps/zlib/inftrees.c +424 -0
- package/deps/zlib/inftrees.h +64 -0
- package/deps/zlib/make_vms.com +867 -0
- package/deps/zlib/msdos/Makefile.bor +115 -0
- package/deps/zlib/msdos/Makefile.dj2 +104 -0
- package/deps/zlib/msdos/Makefile.emx +69 -0
- package/deps/zlib/msdos/Makefile.msc +112 -0
- package/deps/zlib/msdos/Makefile.tc +100 -0
- package/deps/zlib/os400/README400 +48 -0
- package/deps/zlib/os400/bndsrc +144 -0
- package/deps/zlib/os400/make.sh +383 -0
- package/deps/zlib/os400/zlibfixed.rpgle +578 -0
- package/deps/zlib/os400/zlibfree.rpgle +634 -0
- package/deps/zlib/qnx/package.qpg +141 -0
- package/deps/zlib/test/CMakeLists.txt +318 -0
- package/deps/zlib/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/test/example.c +552 -0
- package/deps/zlib/test/find_package_no_components_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_wrong_components_test.cmake.in +27 -0
- package/deps/zlib/test/infcover.c +672 -0
- package/deps/zlib/test/minigzip.c +592 -0
- package/deps/zlib/treebuild.xml +116 -0
- package/deps/zlib/trees.c +1119 -0
- package/deps/zlib/trees.h +128 -0
- package/deps/zlib/uncompr.c +101 -0
- package/deps/zlib/watcom/watcom_f.mak +43 -0
- package/deps/zlib/watcom/watcom_l.mak +43 -0
- package/deps/zlib/win32/DLL_FAQ.txt +381 -0
- package/deps/zlib/win32/Makefile.bor +109 -0
- package/deps/zlib/win32/Makefile.gcc +177 -0
- package/deps/zlib/win32/Makefile.msc +159 -0
- package/deps/zlib/win32/README-WIN32.txt +103 -0
- package/deps/zlib/win32/VisualC.txt +3 -0
- package/deps/zlib/win32/zlib.def +104 -0
- package/deps/zlib/win32/zlib1.rc +37 -0
- package/deps/zlib/zconf.h.in +551 -0
- package/deps/zlib/zlib.3 +149 -0
- package/deps/zlib/zlib.3.pdf +0 -0
- package/deps/zlib/zlib.h +2057 -0
- package/deps/zlib/zlib.map +116 -0
- package/deps/zlib/zlib.pc.cmakein +14 -0
- package/deps/zlib/zlib.pc.in +14 -0
- package/deps/zlib/zlibConfig.cmake.in +18 -0
- package/deps/zlib/zutil.c +313 -0
- package/deps/zlib/zutil.h +331 -0
- package/dist/index.d.ts +266 -0
- package/dist/index.js +1146 -0
- package/dist/libwz.js +5632 -0
- package/dist/libwz.wasm +0 -0
- package/include/wz/CRC32.h +182 -0
- package/include/wz/PngUtility.h +72 -0
- package/include/wz/PortalType.h +124 -0
- package/include/wz/Properties/WzBinaryProperty.h +70 -0
- package/include/wz/Properties/WzCanvasProperty.h +55 -0
- package/include/wz/Properties/WzConvexProperty.h +34 -0
- package/include/wz/Properties/WzDoubleProperty.h +32 -0
- package/include/wz/Properties/WzFloatProperty.h +30 -0
- package/include/wz/Properties/WzIntProperty.h +30 -0
- package/include/wz/Properties/WzLongProperty.h +30 -0
- package/include/wz/Properties/WzLuaProperty.h +31 -0
- package/include/wz/Properties/WzNullProperty.h +15 -0
- package/include/wz/Properties/WzPngProperty.h +53 -0
- package/include/wz/Properties/WzRawDataProperty.h +46 -0
- package/include/wz/Properties/WzShortProperty.h +31 -0
- package/include/wz/Properties/WzStringProperty.h +32 -0
- package/include/wz/Properties/WzSubProperty.h +35 -0
- package/include/wz/Properties/WzUOLProperty.h +44 -0
- package/include/wz/Properties/WzVectorProperty.h +40 -0
- package/include/wz/Properties/WzVideoProperty.h +43 -0
- package/include/wz/Result.h +58 -0
- package/include/wz/Util/Defines.h +16 -0
- package/include/wz/Util/ListFileParser.h +20 -0
- package/include/wz/Util/WzBinaryReader.h +95 -0
- package/include/wz/Util/WzBinaryWriter.h +72 -0
- package/include/wz/Util/WzBlobDataSource.h +30 -0
- package/include/wz/Util/WzDataSource.h +49 -0
- package/include/wz/Util/WzKeyGenerator.h +28 -0
- package/include/wz/Util/WzMutableKey.h +39 -0
- package/include/wz/Util/WzPath.h +37 -0
- package/include/wz/Util/WzStream.h +86 -0
- package/include/wz/Util/WzTool.h +42 -0
- package/include/wz/WzAESConstant.h +17 -0
- package/include/wz/WzDirectory.h +97 -0
- package/include/wz/WzEnums.h +76 -0
- package/include/wz/WzFile.h +99 -0
- package/include/wz/WzHeader.h +47 -0
- package/include/wz/WzImage.h +97 -0
- package/include/wz/WzImageProperty.h +92 -0
- package/include/wz/WzObject.h +55 -0
- package/include/wz/WzPropertyCollection.h +115 -0
- package/include/wz/wz.h +41 -0
- package/include/wz/wz_api.h +432 -0
- package/package.json +93 -0
- package/src/PngUtility.cpp +328 -0
- package/src/Properties/WzBinaryProperty.cpp +183 -0
- package/src/Properties/WzCanvasProperty.cpp +262 -0
- package/src/Properties/WzConvexProperty.cpp +159 -0
- package/src/Properties/WzDoubleProperty.cpp +12 -0
- package/src/Properties/WzFloatProperty.cpp +17 -0
- package/src/Properties/WzIntProperty.cpp +12 -0
- package/src/Properties/WzLongProperty.cpp +12 -0
- package/src/Properties/WzLuaProperty.cpp +37 -0
- package/src/Properties/WzNullProperty.cpp +11 -0
- package/src/Properties/WzPngProperty.cpp +637 -0
- package/src/Properties/WzRawDataProperty.cpp +116 -0
- package/src/Properties/WzShortProperty.cpp +12 -0
- package/src/Properties/WzStringProperty.cpp +44 -0
- package/src/Properties/WzSubProperty.cpp +129 -0
- package/src/Properties/WzUOLProperty.cpp +136 -0
- package/src/Properties/WzVectorProperty.cpp +22 -0
- package/src/Properties/WzVideoProperty.cpp +115 -0
- package/src/Util/ListFileParser.cpp +48 -0
- package/src/Util/WzBinaryReader.cpp +368 -0
- package/src/Util/WzBinaryWriter.cpp +305 -0
- package/src/Util/WzBlobDataSource.cpp +47 -0
- package/src/Util/WzDataSource.cpp +61 -0
- package/src/Util/WzKeyGenerator.cpp +43 -0
- package/src/Util/WzMutableKey.cpp +59 -0
- package/src/Util/WzStream.cpp +196 -0
- package/src/Util/WzTool.cpp +266 -0
- package/src/WzAESConstant.cpp +12 -0
- package/src/WzDirectory.cpp +669 -0
- package/src/WzEnums.cpp +20 -0
- package/src/WzFile.cpp +450 -0
- package/src/WzImage.cpp +350 -0
- package/src/WzImageProperty.cpp +469 -0
- package/src/WzObject.cpp +174 -0
- package/src/WzPropertyCollection.cpp +84 -0
- package/src/capi/wz_api.cpp +1996 -0
- package/src/node/binding.cpp +1776 -0
package/src/WzFile.cpp
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
#include "wz/WzFile.h"
|
|
2
|
+
#include <algorithm>
|
|
3
|
+
#include <cctype>
|
|
4
|
+
#include <cstring>
|
|
5
|
+
#include <filesystem>
|
|
6
|
+
#include <limits>
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include "wz/Properties/WzCanvasProperty.h"
|
|
9
|
+
#include "wz/Properties/WzConvexProperty.h"
|
|
10
|
+
#include "wz/Properties/WzSubProperty.h"
|
|
11
|
+
#include "wz/Properties/WzVectorProperty.h"
|
|
12
|
+
#include "wz/Util/WzBinaryReader.h"
|
|
13
|
+
#include "wz/Util/WzBinaryWriter.h"
|
|
14
|
+
#include "wz/Util/WzPath.h"
|
|
15
|
+
#include "wz/Util/WzTool.h"
|
|
16
|
+
#include "wz/WzAESConstant.h"
|
|
17
|
+
#include "wz/WzDirectory.h"
|
|
18
|
+
#include "wz/WzImage.h"
|
|
19
|
+
|
|
20
|
+
namespace wz {
|
|
21
|
+
|
|
22
|
+
WzFile::WzFile(int16_t gameVersion, WzMapleVersion version)
|
|
23
|
+
: mapleStoryPatchVersion_(gameVersion), maplepLocalVersion_(version) {
|
|
24
|
+
header_ = WzHeader::GetDefault();
|
|
25
|
+
wz_iv_ = WzTool::GetIvByMapleVersion(version);
|
|
26
|
+
wzDir_ = std::make_unique<WzDirectory>(nullptr, "", 0, wz_iv_, this);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
WzFile::WzFile(const std::string& filePath, WzMapleVersion version)
|
|
30
|
+
: WzFile(filePath, -1, version) {}
|
|
31
|
+
|
|
32
|
+
WzFile::WzFile(const std::string& filePath,
|
|
33
|
+
int16_t gameVersion,
|
|
34
|
+
WzMapleVersion version)
|
|
35
|
+
: path_(filePath),
|
|
36
|
+
mapleStoryPatchVersion_(gameVersion),
|
|
37
|
+
maplepLocalVersion_(version) {
|
|
38
|
+
name_ = wz::to_path(filePath).filename().string();
|
|
39
|
+
wz_iv_ = WzTool::GetIvByMapleVersion(version);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
WzFile::WzFile(const std::string& fileName,
|
|
43
|
+
std::shared_ptr<WzDataSource> source,
|
|
44
|
+
int16_t gameVersion,
|
|
45
|
+
WzMapleVersion version)
|
|
46
|
+
: source_(std::move(source)),
|
|
47
|
+
mapleStoryPatchVersion_(gameVersion),
|
|
48
|
+
maplepLocalVersion_(version) {
|
|
49
|
+
name_ = fileName;
|
|
50
|
+
wz_iv_ = WzTool::GetIvByMapleVersion(version);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
WzFile::WzFile(const std::string& filePath, const std::array<uint8_t, 4>& wzIv)
|
|
54
|
+
: path_(filePath), wz_iv_(wzIv) {
|
|
55
|
+
name_ = wz::to_path(filePath).filename().string();
|
|
56
|
+
mapleStoryPatchVersion_ = -1;
|
|
57
|
+
maplepLocalVersion_ = WzMapleVersion::CUSTOM;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
WzFile::WzFile(const std::string& fileName,
|
|
61
|
+
std::shared_ptr<WzDataSource> source,
|
|
62
|
+
const std::array<uint8_t, 4>& wzIv)
|
|
63
|
+
: source_(std::move(source)), wz_iv_(wzIv) {
|
|
64
|
+
name_ = fileName;
|
|
65
|
+
mapleStoryPatchVersion_ = -1;
|
|
66
|
+
maplepLocalVersion_ = WzMapleVersion::CUSTOM;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
WzFile::~WzFile() {
|
|
70
|
+
isUnloaded_ = true;
|
|
71
|
+
wzDir_.reset();
|
|
72
|
+
if (fileReader_.has_value()) {
|
|
73
|
+
fileReader_->Close();
|
|
74
|
+
fileReader_.reset();
|
|
75
|
+
}
|
|
76
|
+
fileStream_.Close();
|
|
77
|
+
source_.reset();
|
|
78
|
+
path_.clear();
|
|
79
|
+
name_.clear();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
uint32_t WzFile::CheckAndGetVersionHash(int wzVersionHeader,
|
|
83
|
+
int maplestoryPatchVersion) {
|
|
84
|
+
std::string verStr = std::to_string(maplestoryPatchVersion);
|
|
85
|
+
int32_t versionHash = 0;
|
|
86
|
+
for (char ch : verStr) {
|
|
87
|
+
versionHash = (versionHash * 32) + static_cast<uint8_t>(ch) + 1;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (wzVersionHeader == 770) return static_cast<uint32_t>(versionHash);
|
|
91
|
+
|
|
92
|
+
int decryptedVersionNumber = static_cast<uint8_t>(
|
|
93
|
+
~(((versionHash >> 24) & 0xFF) ^ ((versionHash >> 16) & 0xFF) ^
|
|
94
|
+
((versionHash >> 8) & 0xFF) ^ (versionHash & 0xFF)));
|
|
95
|
+
|
|
96
|
+
if (wzVersionHeader == decryptedVersionNumber)
|
|
97
|
+
return static_cast<uint32_t>(versionHash);
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void WzFile::CreateWZVersionHash() {
|
|
102
|
+
std::string verStr = std::to_string(mapleStoryPatchVersion_);
|
|
103
|
+
uint32_t versionHash = 0;
|
|
104
|
+
for (char ch : verStr) {
|
|
105
|
+
versionHash = (versionHash * 32) + static_cast<uint8_t>(ch) + 1;
|
|
106
|
+
}
|
|
107
|
+
versionHash_ = versionHash;
|
|
108
|
+
wzVersionHeader_ = static_cast<uint8_t>(
|
|
109
|
+
~(((versionHash >> 24) & 0xFF) ^ ((versionHash >> 16) & 0xFF) ^
|
|
110
|
+
((versionHash >> 8) & 0xFF) ^ (versionHash & 0xFF)));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
void WzFile::Check64BitClient(WzBinaryReader* reader) {
|
|
114
|
+
if (header_.FSize() >= 2) {
|
|
115
|
+
reader->SetPosition(header_.FStart());
|
|
116
|
+
int encver = reader->ReadUInt16();
|
|
117
|
+
if (encver > 0xff) {
|
|
118
|
+
wz_withEncryptVersionHeader_ = false;
|
|
119
|
+
} else if (encver == 0x80) {
|
|
120
|
+
if (header_.FSize() >= 5) {
|
|
121
|
+
reader->SetPosition(header_.FStart());
|
|
122
|
+
int propCount = reader->ReadInt32();
|
|
123
|
+
if (propCount > 0 && (propCount & 0xff) == 0 && propCount <= 0xffff) {
|
|
124
|
+
wz_withEncryptVersionHeader_ = false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
reader->SetPosition(header_.FStart());
|
|
129
|
+
} else {
|
|
130
|
+
wz_withEncryptVersionHeader_ = false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
bool WzFile::TryDecodeWithWZVersionNumber(WzBinaryReader* reader,
|
|
135
|
+
int useWzVersionHeader,
|
|
136
|
+
int useMapleStoryPatchVersion) {
|
|
137
|
+
mapleStoryPatchVersion_ = static_cast<int16_t>(useMapleStoryPatchVersion);
|
|
138
|
+
versionHash_ =
|
|
139
|
+
CheckAndGetVersionHash(useWzVersionHeader, mapleStoryPatchVersion_);
|
|
140
|
+
if (versionHash_ == 0) return false;
|
|
141
|
+
|
|
142
|
+
reader->SetHash(versionHash_);
|
|
143
|
+
int64_t fallbackOffsetPosition = reader->Position();
|
|
144
|
+
|
|
145
|
+
std::unique_ptr<WzDirectory> testDirectory =
|
|
146
|
+
std::make_unique<WzDirectory>(reader, name_, versionHash_, wz_iv_, this);
|
|
147
|
+
auto parseResult = testDirectory->ParseDirectory();
|
|
148
|
+
if (!parseResult.has_value()) {
|
|
149
|
+
reader->SetPosition(fallbackOffsetPosition);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Check first image to validate
|
|
154
|
+
if (!testDirectory->WzImages().empty()) {
|
|
155
|
+
auto* testImage = testDirectory->WzImages()[0];
|
|
156
|
+
reader->SetPosition(testImage->Offset());
|
|
157
|
+
uint8_t checkByte = reader->ReadByte();
|
|
158
|
+
reader->SetPosition(fallbackOffsetPosition);
|
|
159
|
+
|
|
160
|
+
if (checkByte == 0x73 || checkByte == 0x1b) {
|
|
161
|
+
wzDir_ = std::move(testDirectory);
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
// C# returns true for any checkByte (0x30, 0x6C, 0xBC, etc.)
|
|
165
|
+
reader->SetPosition(fallbackOffsetPosition);
|
|
166
|
+
wzDir_ = std::move(testDirectory);
|
|
167
|
+
return true;
|
|
168
|
+
} else {
|
|
169
|
+
// No images - might be Base.wz
|
|
170
|
+
if (Is64BitWzFile() && mapleStoryPatchVersion_ == 113) {
|
|
171
|
+
reader->SetPosition(fallbackOffsetPosition);
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
wzDir_ = std::move(testDirectory);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
WzFileParseStatus WzFile::ParseMainWzDirectory() {
|
|
180
|
+
if (path_.empty() && !source_) {
|
|
181
|
+
return WzFileParseStatus::Path_Is_Null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
wzDir_.reset();
|
|
185
|
+
fileReader_.reset();
|
|
186
|
+
if (!source_) {
|
|
187
|
+
fileStream_.Close();
|
|
188
|
+
|
|
189
|
+
const auto filePath = wz::to_path(path_);
|
|
190
|
+
std::error_code ec;
|
|
191
|
+
if (!std::filesystem::is_regular_file(filePath, ec) || ec) {
|
|
192
|
+
return WzFileParseStatus::Failed_Unknown;
|
|
193
|
+
}
|
|
194
|
+
const auto actualFileSize = std::filesystem::file_size(filePath, ec);
|
|
195
|
+
if (ec || actualFileSize < 17U) {
|
|
196
|
+
return WzFileParseStatus::Failed_Unknown;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (!fileStream_.Open(wz::to_path(path_), "rb")) {
|
|
200
|
+
return WzFileParseStatus::Failed_Unknown;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
fileReader_.emplace(std::make_shared<WzFileDataSource>(&fileStream_),
|
|
204
|
+
wz_iv_);
|
|
205
|
+
} else {
|
|
206
|
+
fileReader_.emplace(source_, wz_iv_);
|
|
207
|
+
}
|
|
208
|
+
WzBinaryReader& fileReader = *fileReader_;
|
|
209
|
+
|
|
210
|
+
if (fileReader.SourceSize() < 17U) {
|
|
211
|
+
return WzFileParseStatus::Failed_Unknown;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
header_.SetIdent(fileReader.ReadString(4));
|
|
215
|
+
header_.SetFSize(fileReader.ReadUInt64());
|
|
216
|
+
header_.SetFStart(fileReader.ReadUInt32());
|
|
217
|
+
if (header_.FStart() < 17U || header_.FStart() > fileReader.SourceSize()) {
|
|
218
|
+
return WzFileParseStatus::Failed_Unknown;
|
|
219
|
+
}
|
|
220
|
+
header_.SetCopyright(
|
|
221
|
+
fileReader.ReadString(static_cast<size_t>(header_.FStart() - 17U)));
|
|
222
|
+
|
|
223
|
+
fileReader.ReadByte(); // unk1
|
|
224
|
+
fileReader.ReadBytes(static_cast<int>(
|
|
225
|
+
header_.FStart() - static_cast<uint64_t>(fileReader.Position())));
|
|
226
|
+
fileReader.SetHeader(&header_);
|
|
227
|
+
|
|
228
|
+
Check64BitClient(&fileReader);
|
|
229
|
+
wzVersionHeader_ = wz_withEncryptVersionHeader_ ? fileReader.ReadUInt16()
|
|
230
|
+
: wzVersionHeader64bit_start;
|
|
231
|
+
|
|
232
|
+
if (mapleStoryPatchVersion_ == -1) {
|
|
233
|
+
// Try version range
|
|
234
|
+
if (!wz_withEncryptVersionHeader_) {
|
|
235
|
+
for (uint16_t v = wzVersionHeader64bit_start;
|
|
236
|
+
v < wzVersionHeader64bit_start + 10;
|
|
237
|
+
v++) {
|
|
238
|
+
if (TryDecodeWithWZVersionNumber(&fileReader, wzVersionHeader_, v)) {
|
|
239
|
+
return WzFileParseStatus::Success;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Brute-force versions
|
|
244
|
+
const int16_t MAX_PATCH_VERSION = 2000;
|
|
245
|
+
for (int j = 0; j < MAX_PATCH_VERSION; j++) {
|
|
246
|
+
if (TryDecodeWithWZVersionNumber(&fileReader, wzVersionHeader_, j)) {
|
|
247
|
+
return WzFileParseStatus::Success;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return WzFileParseStatus::Error_Game_Ver_Hash;
|
|
251
|
+
} else {
|
|
252
|
+
versionHash_ =
|
|
253
|
+
CheckAndGetVersionHash(wzVersionHeader_, mapleStoryPatchVersion_);
|
|
254
|
+
fileReader.SetHash(versionHash_);
|
|
255
|
+
|
|
256
|
+
wzDir_ = std::make_unique<WzDirectory>(
|
|
257
|
+
&fileReader, name_, versionHash_, wz_iv_, this);
|
|
258
|
+
auto parseResult = wzDir_->ParseDirectory();
|
|
259
|
+
if (!parseResult.has_value()) {
|
|
260
|
+
wzDir_.reset();
|
|
261
|
+
return WzFileParseStatus::Failed_Unknown;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return WzFileParseStatus::Success;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
WzFileParseStatus WzFile::ParseWzFile() {
|
|
269
|
+
return ParseMainWzDirectory();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
Result<void> WzFile::SaveToDisk(const std::string& path,
|
|
273
|
+
std::optional<bool> saveAs64Bit,
|
|
274
|
+
WzMapleVersion preferredVersion) {
|
|
275
|
+
if (!wzDir_) {
|
|
276
|
+
return std::unexpected(
|
|
277
|
+
Error::InvalidArgument("Cannot save WZ file without a directory"));
|
|
278
|
+
}
|
|
279
|
+
if (path.empty()) {
|
|
280
|
+
return std::unexpected(
|
|
281
|
+
Error::InvalidArgument("Cannot save WZ file to an empty path"));
|
|
282
|
+
}
|
|
283
|
+
if (mapleStoryPatchVersion_ < 0) {
|
|
284
|
+
return std::unexpected(Error::InvalidArgument(
|
|
285
|
+
"Cannot save WZ file before a version has been resolved"));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const std::array<uint8_t, 4> saveIv =
|
|
289
|
+
preferredVersion == WzMapleVersion::UNKNOWN
|
|
290
|
+
? wz_iv_
|
|
291
|
+
: WzTool::GetIvByMapleVersion(preferredVersion);
|
|
292
|
+
const bool isSameIv = saveIv == wzDir_->WzIv();
|
|
293
|
+
const bool isDefaultUserKey = true;
|
|
294
|
+
bool saveAs64 = !wz_withEncryptVersionHeader_;
|
|
295
|
+
if (saveAs64Bit.has_value()) {
|
|
296
|
+
saveAs64 = saveAs64Bit.value();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
CreateWZVersionHash();
|
|
300
|
+
wzDir_->SetHash(versionHash_);
|
|
301
|
+
|
|
302
|
+
WzMemoryStream tempStream;
|
|
303
|
+
WzTool::ClearWzObjectValueLengthCache();
|
|
304
|
+
auto generateResult = wzDir_->GenerateDataFile(
|
|
305
|
+
isSameIv ? nullptr : &saveIv, isDefaultUserKey, &tempStream);
|
|
306
|
+
if (!generateResult.has_value()) {
|
|
307
|
+
return std::unexpected(generateResult.error());
|
|
308
|
+
}
|
|
309
|
+
wzDir_->SetWzIv(saveIv);
|
|
310
|
+
|
|
311
|
+
WzTool::ClearWzObjectValueLengthCache();
|
|
312
|
+
const uint32_t directoryStart =
|
|
313
|
+
header_.FStart() + (saveAs64 ? 0u : sizeof(uint16_t));
|
|
314
|
+
auto directoryEnd = wzDir_->GetOffsets(directoryStart);
|
|
315
|
+
if (!directoryEnd.has_value()) {
|
|
316
|
+
return std::unexpected(directoryEnd.error());
|
|
317
|
+
}
|
|
318
|
+
auto totalLength = wzDir_->GetImgOffsets(directoryEnd.value());
|
|
319
|
+
if (!totalLength.has_value()) {
|
|
320
|
+
return std::unexpected(totalLength.error());
|
|
321
|
+
}
|
|
322
|
+
if (totalLength.value() < header_.FStart()) {
|
|
323
|
+
return std::unexpected(
|
|
324
|
+
Error::DataError("WZ total length precedes file start"));
|
|
325
|
+
}
|
|
326
|
+
const uint64_t fileSize =
|
|
327
|
+
static_cast<uint64_t>(totalLength.value()) - header_.FStart();
|
|
328
|
+
if (fileSize > std::numeric_limits<uint32_t>::max()) {
|
|
329
|
+
return std::unexpected(Error::DataError("WZ file size exceeds 32-bit"));
|
|
330
|
+
}
|
|
331
|
+
header_.SetFSize(fileSize);
|
|
332
|
+
|
|
333
|
+
WzFileStream output;
|
|
334
|
+
if (!output.Open(wz::to_path(path), "wb")) {
|
|
335
|
+
return std::unexpected(Error::IoError("Failed to open WZ output file"));
|
|
336
|
+
}
|
|
337
|
+
WzBinaryWriter writer(output, saveIv, versionHash_);
|
|
338
|
+
|
|
339
|
+
for (char ch : header_.Ident()) {
|
|
340
|
+
writer.WriteByte(static_cast<uint8_t>(ch));
|
|
341
|
+
}
|
|
342
|
+
writer.WriteUInt64(header_.FSize());
|
|
343
|
+
writer.WriteUInt32(header_.FStart());
|
|
344
|
+
writer.WriteNullTerminatedString(header_.Copyright());
|
|
345
|
+
|
|
346
|
+
const int64_t extraHeaderLength =
|
|
347
|
+
static_cast<int64_t>(header_.FStart()) - writer.Position();
|
|
348
|
+
if (extraHeaderLength < 0) {
|
|
349
|
+
return std::unexpected(
|
|
350
|
+
Error::DataError("WZ header is longer than its file start offset"));
|
|
351
|
+
}
|
|
352
|
+
for (int64_t i = 0; i < extraHeaderLength; ++i) {
|
|
353
|
+
writer.WriteByte(0);
|
|
354
|
+
}
|
|
355
|
+
if (!saveAs64) {
|
|
356
|
+
writer.WriteUInt16(wzVersionHeader_);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
writer.SetHeader(header_);
|
|
360
|
+
auto saveDirResult = wzDir_->SaveDirectory(&writer);
|
|
361
|
+
if (!saveDirResult.has_value()) {
|
|
362
|
+
return std::unexpected(saveDirResult.error());
|
|
363
|
+
}
|
|
364
|
+
writer.ClearStringCache();
|
|
365
|
+
|
|
366
|
+
if (!tempStream.Seek(0, WzSeekOrigin::Begin)) {
|
|
367
|
+
return std::unexpected(
|
|
368
|
+
Error::IoError("Failed to rewind temporary WZ image data"));
|
|
369
|
+
}
|
|
370
|
+
auto saveImagesResult = wzDir_->SaveImages(&writer, &tempStream);
|
|
371
|
+
if (!saveImagesResult.has_value()) {
|
|
372
|
+
return std::unexpected(saveImagesResult.error());
|
|
373
|
+
}
|
|
374
|
+
writer.ClearStringCache();
|
|
375
|
+
|
|
376
|
+
if (!output.Flush()) {
|
|
377
|
+
return std::unexpected(Error::IoError("Failed to write WZ output file"));
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
wz_iv_ = saveIv;
|
|
381
|
+
if (preferredVersion != WzMapleVersion::UNKNOWN) {
|
|
382
|
+
maplepLocalVersion_ = preferredVersion;
|
|
383
|
+
}
|
|
384
|
+
wz_withEncryptVersionHeader_ = !saveAs64;
|
|
385
|
+
return {};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
WzObject* WzFile::GetObjectFromPath(const std::string& path,
|
|
389
|
+
bool checkFirstDirectoryName) {
|
|
390
|
+
if (!wzDir_) return nullptr;
|
|
391
|
+
|
|
392
|
+
WzObject* curObj = wzDir_.get();
|
|
393
|
+
std::string remaining = path;
|
|
394
|
+
|
|
395
|
+
if (checkFirstDirectoryName) {
|
|
396
|
+
size_t firstSep = remaining.find('/');
|
|
397
|
+
std::string firstComponent = firstSep == std::string::npos
|
|
398
|
+
? remaining
|
|
399
|
+
: remaining.substr(0, firstSep);
|
|
400
|
+
if (firstComponent == wzDir_->Name() || firstComponent == Name()) {
|
|
401
|
+
remaining =
|
|
402
|
+
firstSep == std::string::npos ? "" : remaining.substr(firstSep + 1);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
while (!remaining.empty()) {
|
|
407
|
+
size_t pos = remaining.find('/');
|
|
408
|
+
std::string component;
|
|
409
|
+
if (pos == std::string::npos) {
|
|
410
|
+
component = remaining;
|
|
411
|
+
remaining.clear();
|
|
412
|
+
} else {
|
|
413
|
+
component = remaining.substr(0, pos);
|
|
414
|
+
remaining = remaining.substr(pos + 1);
|
|
415
|
+
}
|
|
416
|
+
if (component.empty()) continue;
|
|
417
|
+
curObj = TraverseComponent(curObj, component);
|
|
418
|
+
if (!curObj) return nullptr;
|
|
419
|
+
}
|
|
420
|
+
return curObj;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
WzObject* WzFile::TraverseComponent(WzObject* curObj,
|
|
424
|
+
const std::string& component) {
|
|
425
|
+
if (!curObj) return nullptr;
|
|
426
|
+
WzObjectType type = curObj->ObjectType();
|
|
427
|
+
if (type == WzObjectType::Directory) {
|
|
428
|
+
return (*static_cast<WzDirectory*>(curObj))[component];
|
|
429
|
+
} else if (type == WzObjectType::Image) {
|
|
430
|
+
return (*static_cast<WzImage*>(curObj))[component];
|
|
431
|
+
} else if (type == WzObjectType::Property) {
|
|
432
|
+
auto* prop = static_cast<WzImageProperty*>(curObj);
|
|
433
|
+
auto pt = prop->PropertyType();
|
|
434
|
+
if (pt == WzPropertyType::Canvas) {
|
|
435
|
+
return (*static_cast<WzCanvasProperty*>(prop))[component];
|
|
436
|
+
} else if (pt == WzPropertyType::Convex) {
|
|
437
|
+
return (*static_cast<WzConvexProperty*>(prop))[component];
|
|
438
|
+
} else if (pt == WzPropertyType::SubProperty) {
|
|
439
|
+
return (*static_cast<WzSubProperty*>(prop))[component];
|
|
440
|
+
} else if (pt == WzPropertyType::Vector) {
|
|
441
|
+
// C# boxes int to WzObject; in C++ we cannot return int as WzObject*.
|
|
442
|
+
// Use direct getter: static_cast<WzVectorProperty*>(prop)->X() / Y()
|
|
443
|
+
return nullptr;
|
|
444
|
+
}
|
|
445
|
+
return nullptr;
|
|
446
|
+
}
|
|
447
|
+
return nullptr;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
} // namespace wz
|