local function pgus() if panel then panel.GetUserScreen() end end local function psus() if panel then panel.SetUserScreen() end end local function fread(f) local x,h = nil,io.open(f,"rb") if h then x=h:read("*all") io.close(h) end return x end local function fwrite(f,s) local x,h = nil,io.open(f,"wb") if h then x=h:write(s or "") io.close(h) end return x end local function GetPage(x) pgus() local s="" if x then s=io.popen('curl.exe '..x,'rb'):read('*all') end psus() return s end local tmp=win.GetEnv("TEMP").."\\" local home=[[C:\Program Files\Basilisk Portable\]] local urlh='http://o.rthost.win/basilisk/' local period=7 -- days for update local bastime=win.GetFileTimes(home..'Basilisk\\basilisk.exe').LastAccessTime/10000000/3600/24 -- in 100ns/sec/hour/day local systime=win.GetSystemTimeAsFileTime()/1000/3600/24 -- in ms/sec/hour/day if systime-bastime>period then -- wait period days local text=GetPage(urlh) local lname,lyear,lmonth,lday --basilisk52-g4.8.win32-git-20220611-3219d2d-uxp-fec5435ab-xpmod.7z --http://o.rthost.win/basilisk/basilisk52-g4.8.win32-git-20220611-3219d2d-uxp-fec5435ab-xpmod.7z for fname,year,month,day in text:gmatch('(basilisk52%-g[%d%.]+win32%-git%-(%d%d%d%d)(%d%d)(%d%d)%-%x+%-uxp%-%x+%-xpmod%.7z)') do if fname then lname,lyear,lmonth,lday = fname,year,month,day end end if lname then pgus() win.system('curl.exe -g -L --location-trusted "'..urlh..lname..'" -o "'..tmp..lname..'"') win.system('7z.exe x -aoa -o"'..home..'" "'..tmp..lname..'"') psus() local f=home..'Basilisk\\dependentlibs.list' local l=fread(f) if not l:find'^portable32%.dll\r\n' then fwrite(f,'portable32.dll\r\n'..l) end print("\nBasilisk has been updated") end else print("\nBasilisk was updated less than "..period.." days ago") end |