示例#1
0
int lziparchive_fileinsert(lua_State* L) {
	ZipArchive* archive = lziparchive_check(L, 1);
	const char* srcFileName = luaL_checkstring(L, 2);
	const char* destFileName = luaL_checkstring(L, 3);
    int compressionMethod = (int)luaL_optnumber(L, 4, ZipArchive::DEFLATED);
    int compressionLevel = (int)luaL_optnumber(L, 5, Z_DEFAULT_COMPRESSION);

	DiskFile file;
    if (!file.Open(srcFileName, File::MODE_READONLY)) {
		lua_pushboolean(L, false);
		return 1;
	}

	time_t fileTime = (UINT)luaL_optnumber(L, 5, (lua_Number)file.GetLastWriteTime());

	lua_pushboolean(L, archive->FileCopy(file, destFileName, compressionMethod, compressionLevel, &fileTime) != 0);
	return 1;
}
示例#2
0
int LS_VirtualDrive_FileInsert(LuaState* state, LuaStackObject* args)
{
	VirtualDrive* drive = VirtualDriveFromLua(state, args[1]);
	const char* srcFileName = luaL_checkstring(*state, 2);
	const char* destFileName = luaL_checkstring(*state, 3);
    int compressionMethod = (UINT)luaL_optnumber(*state, 4, VirtualDrive::COMPRESSED);

	DiskFile file;
    if (!file.Open(srcFileName, File::MODE_READONLY))
	{
		state->PushBoolean(false);
		return 1;
	}

	time_t fileTime = (UINT)luaL_optnumber(*state, 5, (lua_Number)file.GetLastWriteTime());

	state->PushBoolean(drive->FileCopy(file, destFileName, compressionMethod, &fileTime) != 0);
	return 1;
}