Guidance
指路人
g.yi.org
Software / Reginald / Examples / zipexams / ZipMem.rex

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
/* This script shows how to use the RxZip add-on DLL to create a ZIP archive
 * in memory.
 */

OPTIONS "C_CALL LABELCHECK"

/* Register the Rxzip add-on DLL */
LIBRARY rxzip

/* Tell RxZip to raise SYNTAX condition for any failure with a Zip function */
ziperr = "SYNTAX"
zipheading = 1

/* Here are some variables which we'll compress into our zip file */
data1 =	"This is some data." || "0D0A0D0A"x || "This is line two."|| "0D0A"x
data2 =	"This is a test of the RxZip add-on dll." || "0D0A0D0A"x || "Hopefully this worked!"|| "0D0A"x

DO
	/* Create a ZIP archive in memory. Set a maximum limit of 500K. Store the ZIP handle
	 * in a variable named "ZipHandle"
	 */
	zipcreate("ZipHandle", 500000, 'MEMORY')

	/* Add the contents of the Data1 to the ZIP, and give it the name "data1.txt". */
	zipadd(ziphandle,  data1, "MEMORY", "data1.txt")

	/* Add the contents of the Data2 to the ZIP, and give it the name "data2.txt". */
	zipadd(ziphandle,  data2, "MEMORY", "data2.txt")

	/* Here we could call ZipAdd to add disk files, the contents of more variables,
	 * or the output of a pipe, to the ZIP archive in memory.
	 */

	/* Now let's stuff that ZIP archive into a REXX variable named "Data1". */
	zipgetmemory(ziphandle,  "Data1")

	/* Here you can do something with the ZIP archive stored in Data1. Here we'll
	 * just write it to a disk file named "test.zip". Note that it would be more
	 * memory-friendly if we had instead created a ZIP archive on disk to begin
	 * with. But this is just a demonstration.
	 */
	CHAROUT("test.zip", data1) 
	LINEOUT("test.zip")

	/* We're done with our ZIP in memory, so just let the FINALLY section close it. */

	CATCH SYNTAX
		CONDITION('M')

	FINALLY
		/* Make sure any ZIP archive we created above is closed, and the memory freed. */
		IF EXISTS("ZIPHANDLE") THEN zipclose(ziphandle)
END
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2024-12-11  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2010-07-16 20:49:38