Inflate (decompress) a buffer * A lua error is raised is on error * * @name zlib.inflate * @param buf [type:string] buffer to inflate * @return buf [type:string] inflated buffer * @examples * * ```lua * local data = "\120\94\11\201\200\44\86\0\162\68\133\226\146\162\204\188\116\133\242\204\146\12\133\210\188\228\252\220\130\162\212\226\226\212\20\133\14
| 71 | * ``` |
| 72 | */ |
| 73 | int Zlib_Inflate(lua_State* L) |
| 74 | { |
| 75 | dmArray<uint8_t> out; |
| 76 | out.SetCapacity(32 * 1024); |
| 77 | const char* in = luaL_checkstring(L, 1); |
| 78 | int in_len = lua_strlen(L, 1); |
| 79 | dmZlib::Result r = dmZlib::InflateBuffer(in, in_len, &out, Writer); |
| 80 | if (r == dmZlib::RESULT_OK) |
| 81 | { |
| 82 | lua_pushlstring(L, (const char*) out.Begin(), out.Size()); |
| 83 | return 1; |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | out.SetCapacity(0); // Required as the destructor isn't run |
| 88 | luaL_error(L, "Failed to inflate buffer (%d)", r); |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | assert(0); // never reached |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | /*# Deflate (compress) a buffer |
| 97 | * A lua error is raised is on error |
nothing calls this directly
no test coverage detected