This commit is contained in:
baidwwy 2021-04-26 05:55:05 +08:00
parent 63e29af813
commit 366497f082
1 changed files with 7 additions and 22 deletions

View File

@ -1,7 +1,7 @@
--[[
@Author : baidwwy
@Date : 2021-02-11 11:49:09
@LastEditTime : 2021-04-14 08:39:32
@LastEditTime : 2021-04-26 05:53:28
--]]
local GGE资源包
local _ENV = require("SDL")
@ -111,27 +111,15 @@ end
local db3 = require("lsqlite3")
local function prepare_value0(db,sql)
local vm = db:prepare(sql)
if vm and vm:step()==db3.ROW then
return vm:get_value(0)
end
return 0
end
GGE资源包 = class("GGE资源包")
function GGE资源包:初始化(file,psd)
local db = db3.open(file)
local db = require("lib.sqlite3")(file,psd)
if db then
if psd then
local psd = string.format("PRAGMA key = '%s';", psd)
db:exec(psd)
end
local r = prepare_value0(db,"select count(*) from sqlite_master where name='file';")
local r = db:("select count(*) from sqlite_master where name='file';")
if r==0 then
db:exec[[
db:[[
CREATE TABLE "main"."file" (
"path" TEXT,
"md5" TEXT,
@ -162,15 +150,12 @@ function GGE资源包:初始化(file,psd)
end
function GGE资源包:是否存在(path)
if prepare_value0(self._db,string.format("select count(*) from file where path = '%s'; ", path))~=0 then
return true
end
return false
return self._db:("select count(*) from file where path = '%s'; ", path)~=0
end
function GGE资源包:读数据(path)
local data = prepare_value0(self._db,string.format("SELECT data FROM data WHERE md5 = (SELECT md5 FROM file WHERE path = '%s');",path))
return data~=0 and data or nil
local t = self._db:("SELECT data FROM data WHERE md5 = (SELECT md5 FROM file WHERE path = '%s');",path)
return t and t.data
end
function GGE资源包:写数据(path,data)