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 // UnZip32.DLLの稼働状況取得
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 // 2000000:M_BAR_WINDOW_OFF, 800000:M_ERROR_MESSAGE_OFF
ll_callfunc prm, 2, UnZipOpenArchive@ : ll_ret harc // Zipファイルにアクセスできるようオープン
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@ // Zipファイルをクローズ
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_getlist val
mref list, 24
list = filelist // 参照変数が変わるので dup だとうまく行かない
return
#global
dialog "zip", 16, "zipファイル"
if stat = 0 : end
zip_init
zip_sel refstr
if stat = -1 : dialog "取得に失敗しました" : end
sdim data, stat + 1
zip_getlist data
mesbox data, winx, winy
stop
|