MCPcopy Create free account
hub / github.com/DFHack/dfhack / internal_md5file

Function internal_md5file

library/LuaApi.cpp:4274–4312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4272}
4273
4274static int internal_md5file(lua_State *L)
4275{
4276 const char *s = luaL_checkstring(L, 1);
4277 uint32_t len;
4278 char *first_kb_raw = nullptr;
4279 vector<char> first_kb;
4280 if (lua_toboolean(L, 2))
4281 first_kb_raw = new char[1024];
4282
4283 string hash = md5_wrap.getHashFromFile(s, len, first_kb_raw);
4284 bool err = (hash.find("file") != string::npos);
4285
4286 if (first_kb_raw)
4287 {
4288 first_kb.assign(first_kb_raw, first_kb_raw + 1024);
4289 delete[] first_kb_raw;
4290 }
4291
4292 if (err)
4293 {
4294 lua_pushnil(L);
4295 lua_pushstring(L, hash.c_str());
4296 return 2;
4297 }
4298 else
4299 {
4300 lua_pushstring(L, hash.c_str());
4301 lua_pushinteger(L, len);
4302 if (!first_kb.empty())
4303 {
4304 Lua::PushVector(L, first_kb);
4305 return 3;
4306 }
4307 else
4308 {
4309 return 2;
4310 }
4311 }
4312}
4313
4314static int internal_getSuppressDuplicateKeyboardEvents(lua_State *L) {
4315 Lua::Push(L, Core::getInstance().getSuppressDuplicateKeyboardEvents());

Callers

nothing calls this directly

Calls 9

lua_tobooleanFunction · 0.85
lua_pushnilFunction · 0.85
lua_pushstringFunction · 0.85
lua_pushintegerFunction · 0.85
PushVectorFunction · 0.85
getHashFromFileMethod · 0.80
c_strMethod · 0.80
findMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected