View Single Post
  #1 (permalink)  
Old 08-22-2007, 12:50 PM
SWFKit SWFKit is offline
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Creating zip files by using SWFKit Pro

By using the LiteZip, you can create zip files in swfkit pro.

First, add the LiteZip.dll into the "Resources" panel in swfkit pro

Second, in the "initialize" script, define the functions in LiteZip.dll
Code:
var LiteZip = getAdditionalFile("LiteZip.dll");
// creates a new zip file
// 	handle - returns a handle to the newly created zip file.
//		With the handle we can add files into the zip file
//	filename - the name of the zip file to create
//	password - password for the zip file to create
dllimport LiteZip stdcall long ZipCreateFileA(long* handle, String filename, String password) as zipCreate;
// closes a zip file
dllimport LiteZip stdcall long ZipClose(long handle) as zipClose;
// adds a file into the zip file
//	handle - the handle of the created zip file
//	nameInZip - the name of the file after added into the zip file
//	fileToAdd - the path name of a disk file to add
dllimport LiteZip stdcall long ZipAddFileA(long handle, String nameInZip, String fileToAdd) as zipAddFile;
// adds a folder to a zip file
dllimport LiteZip stdcall long ZipAddFolderA(long handle, String folderName) as zipAddFolder; 
// adds a folder on disk into a zip file
//	handle - the handle of the zip file to operate
//	dirName - name of the directory on disk
//	offset - from where the sub string of a file name on disk will be
//		the name in the zip file. For example, to add the directory
//		"c:\flash\test", in which there is a file "sample.pdf", if 
//		offset is length of the string "c:\flash\test\", the "sample.pdf" 
//		in the zip file will still be "sample.pdf"; however, if the
//		offset is length of string "c:\flash\", the name of "sample.pdf" in 
//		zip file will be "test\sample.pdf", that is, it is in the "test"
//		folder. Say the full path name of a disk file is strFullName, its
//		name in zip is strZipName, then
//		
//		strZipName = strFullName.substring(offset);
dllimport LiteZip stdcall long ZipAddDirA(long handle, String dirName, long offset) as zipAddDir;
Third, call the functions in ffish script to create a zip file
Code:
// creates a new zip file to get a handle
var handle = new Object;
handle.value = 0;
zipCreate(handle, "c:\\flash\\1.zip", "");
// adds files
zipAddFile(handle.value, "hi.txt", "c:\\flash\\hi.txt");
zipAddFile(handle.value, "myfiles\\readme.txt", "c:\\flash\\1.txt");
// adds an empty folder
zipAddFolder(handle.value, "newfolder");
// adds files in a directory
zipAddDir(handle.value, "c:\\flash\\test", "c:\\flash\\".length);
// closes and saves the zip file
zipClose(handle.value);
The attached file is the "LiteZip.dll".
Reply With Quote