mkpack.hsp

sample\misc\mkpack.hsp » Plain Format

#packopt name "mkpack"
#include "hspcmp.as"
#include "hspext.as"

	randomize

	title "mkdpm v1.0"
	screen 0,480,240
	sdim fname,256
	sdim dname,256
	dname="data"
	deckey=0

	syscolor 15:boxf
	color 0,0,0
	mes "指定ディレクトリの内容をDPMファイルに変換します"

	pos 0,30
	sysfont 17
	mes "ディレクトリ:"
	objsize 400,24
	input fname
	objsize 64,24
	pos 408,41:button "参照...",*seldir

	objsize 120,24
	pos 0,80
	mes "暗号化キー: (0の場合は標準DPMを作成します)"
	input deckey
	obj_deckey=stat

	objsize 60,24
	pos 124,92
	button "生成",*mkkey

	objsize 160,24
	pos 240,90
	chkbox "全体を暗号化する",enc

	pos 0,140
	mes "DPMファイル名: (拡張子はいりません)"
	input dname

	pos 0,180
	button "DPM作成",*mkdpm
	button "終了",*owari
	stop

*owari
	end

*seldir
	selfolder fname,""
	if stat=0 : objprm 0,fname
	stop

*mkkey
	a1=rnd(255)+1
	a2=rnd(255)+1
	a3=rnd(255)+1
	a4=rnd(255)+1
	deckey=(a4<<24)+(a3<<16)+(a2<<8)+a1
	objprm obj_deckey, deckey
	stop

*mkdpm
	sname = "packfile"
	chdir fname
	dirlist s1,"*.*",0
	notesel s1

	repeat notemax
	noteget ff,cnt

	hed=""
	if enc : hed="+"

	if ff="packfile" : hed=";"
	if getpath(ff,2)=".dpm" : hed=";"

	if hed!="" : noteadd hed+ff,cnt,1	

	loop

	noteadd "; packfile generated by mkpack",0
	notesave sname			; テキストファイルをセーブ

	title "Building DPM..."

	hsc_ini ""
	pack_ini dname+".dpm"
	pack_make 1,deckey

	title "Complete."
	stop