Latest Changes

Differences between version #14372 and #14373

25c25
< 
---
> Please note that we can freelyh create the internal directory structure of our zip file by defining the desired path to the content file.
30c30
< var entries:List<Entry> = new List();
---
> var entries:List<format.zip.Data.Entry> = new List();
51a52,82
> ====== Reading a zip file ======
> Here's how we can read the content from our newly created **test.zip**.
> ===== 4. Grabbing the list of entries out of the zip file =====
> We start by reading the zip file and let the format.zip.reader get our entries out of it:
> <code haxe>
> // Read our zip file and get the bytes into a BytesInput stream
> var zipfileBytes = File.getBytes("test.zip");
> var bytesInput = new BytesInput(zipfileBytes);
> // use a format.zip.Reader to grab the zip entries
> var reader = new format.zip.Reader(bytesInput);
> var entries:List<format.zip.Data.Entry> = reader.read();		
> </code>
> 
> As a result we have the same kind of list of entries as we saw in step 2 above.
> ===== 5. Grabbing the data out of the zip entry =====
> Now we can simply iterate our list of entries to search for the entry filename that we want to extract.
> In step 1. above, we saved our string with the internal entry filename **path/to/textfile.txt**, so we have to search for this one among the entry filenames.
> Here's a simplistic way of doing it:
> <code haxe>
> var searchEntryFileName = "path/to/textfile.txt";
> for (entry in entries ) {
> 	if (entry.fileName == searchEntryFileName) {
> 		// Get the bytes out of the entry
> 		var bytes:Bytes = entry.data;
> 		// Convert the bytes to a string
> 		var string = bytes.toString();
> 		// Should trace "Hello zip!"
> 		trace(string);
> 	}
> }
> </code>
\ No newline at end of file

	
Ver Date Entry Lg User Action
#19344 2013-05-08 11:28:55 api/flash/display/graphics kr api View | Diff
#19343 2013-05-08 11:28:36 api/flash kr api View | Diff
#19342 2013-05-08 11:28:03 api kr api View | Diff
#19341 2013-05-08 11:27:08 api ro api View | Diff
#19340 2013-05-08 11:26:50 api/array cn api View | Diff
#19339 2013-05-08 11:26:09 api cn api View | Diff
#19338 2013-05-08 11:25:57 api/math pt api View | Diff
#19337 2013-05-08 11:25:51 api/date pt api View | Diff
#19336 2013-05-08 11:25:47 api/array pt api View | Diff
#19335 2013-05-08 11:25:09 api pt api View | Diff
#19334 2013-05-08 11:24:06 api it api View | Diff
#19333 2013-05-08 11:23:02 api es api View | Diff
#19332 2013-05-08 11:22:44 api/array de api View | Diff
#19331 2013-05-08 11:22:09 api de api View | Diff
#19330 2013-05-08 11:21:09 api nl api View | Diff
#19329 2013-05-08 11:21:00 api/sys jp api View | Diff
#19328 2013-05-08 11:21:00 api/sys jp api Set title to Sys
#19327 2013-05-08 11:20:41 api/sys jp api View | Diff
#19326 2013-05-08 11:20:41 api/sys jp api Removed title Sys
#19325 2013-05-08 11:20:39 api/php/web jp api View | Diff

Previous | Next