ll_libload unzip32, "UnZip32.dll"
ll_getproc UnZipCloseArchive, "UnZipCloseArchive", unzip32
ll_getproc UnZipFindFirst, "UnZipFindFirst", unzip32
ll_getproc UnZipFindNext, "UnZipFindNext", unzip32
ll_getproc UnZipGetFileCount, "UnZipGetFileCount", unzip32
ll_getproc UnZipGetFileName, "UnZipGetFileName", unzip32
ll_getproc UnZipGetOriginalSize, "UnZipGetOriginalSize", unzip32
ll_getproc UnZipGetRunning, "UnZipGetRunning", unzip32
ll_getproc UnZipGetVersion, "UnZipGetVersion", unzip32
ll_getproc UnZipOpenArchive, "UnZipOpenArchive", unzip32
#module
#deffunc zip_init
mref stt, 64
zipver = 0
if UnZipGetVersion@ {
ll_callfnv UnZipGetVersion@ : ll_ret zipver
poke zipver, 2
stt = zipver ! 0
}
return
#deffunc zip_wait
mref stt, 64
repeat 0xFFFF
ll_callfnv UnZipGetRunning@ : ll_ret prm
if prm = 0 : stt = 1 : break
wait 10
loop
stt = (stt ! 1) * -1
return
#deffunc zip_getcount val, int
mref count, 16 : mref type, 1
mref stt, 64
if zipver = 0 : stt = -1 : return : else : stt = 0
if type {
notesel filelist
notemax count
} else {
ll_getptr zipfile : ll_ret prm
ll_callfunc prm, 1, UnZipGetFileCount@ : ll_ret count
}
return
#deffunc zip_findfile str
mref extension, 32
mref stt, 64
if zipver = 0 : stt = -1 : return
zip_wait
if stat : stt = -1 : return
sdim s, 256
zip_getcount prm
if prm > 0 {
sdim filelist, prm * 256
dim sizelist, prm
} else : stt = -1 : return
prm = 0
ll_getptr zipfile : ll_ret prm.1
prm.2 = 0x02800000
ll_callfunc prm, 2, UnZipOpenArchive@ : ll_ret harc
notesel filelist
j = 0
repeat
if cnt {
ll_callfunc, harc, 1, UnZipFindNext@
} else {
prm = harc
ll_getptr extension : ll_ret prm.1
ll_callfunc, prm, 2, UnZipFindFirst@
}
ll_ret prm.3
if prm.3 = -1 : break
ll_getptr s : ll_ret prm.1
prm.2 = 256
ll_callfunc, prm, 3, UnZipGetFileName@
ll_callfunc, prm, 1, UnZipGetOriginalSize@ : ll_ret prm.3
if prm.3 > 0 : sizelist.j = prm.3 : noteadd s
loop
ll_callfunc, harc, 1, UnZipCloseArchive@
notemax prm
stt = ((prm ! 0) = 0) * -1
return
#deffunc zip_sel str
mref file, 32
mref stt, 64
if zipver = 0 : stt = -1 : return
zipfile = file
zip_findfile "*"
if stat ! -1 : strlen stt, filelist
return
#deffunc zip_getfilename val, int
mref file, 24 : mref no, 1
mref stt, 64 : mref rstr, 65
notesel filelist
notemax prm
if prm <= no : stt = -1 : else : stt = 0 : noteget file, no
return
#deffunc zip_getfilesize val, int
mref size, 16 : mref no, 1
mref stt, 64
size = sizelist.no
return
#global
gosub *open
objsize 100, 25
button "選択", *change
combox index, , item
button "情報表示", *show
stop
*open
dialog "zip", 16, "zipファイル"
if stat = 0 : end
zip_init
zip_sel refstr
if stat = -1 : dialog "取得に失敗しました" : end
zip_getcount i, 1
sdim item, i * 4
repeat i
if cnt : item += "\n"
item += "" + cnt
loop
return
*change
gosub *open
objprm 1, item
objprm 1, 0
stop
*show
zip_getfilename filename, index
zip_getfilesize filesize, index
dialog "Item No. " + index + "\n\nFile Name\t" + filename + "\nFile Size\t" + filesize
stop
|