Posts Tagged ‘airxzip’

ZipFileReader class can NOT make directory or file.
So you should make directory or file according to ZipEntry.isDirectory() method.

var file:File = File.desktopDirectory.resolvePath("sample.zip");
			
var reader:ZipFileReader = new ZipFileReader();
reader.open(file);
var fileList:Array = reader.getEntries();
var baseDir:File = File.documentsDirectory();

for each(var entry:ZipEntry in fileList){
	var filename:String = entry.getFilename();
	
	if(entry.isDirectory()){
		//  If entry is directory 
		var dir:File = baseDir.resolvePath(filename);
		dir.createDirectory();
	}
	else{
		var unzippedBytes:ByteArray = reader.unzip(entry);
		var file:File = baseDir.resolvePath(filename);
		var fs:FileStream = new FileStream(FileMode.WRITE);
		fs.writeBytes(unzippedBytes,0,unzippedBytes.length);
		fs.close();
	}
}
reader.close();

var zipReader:ZipFileReader = new ZipFileReader();
zipReader.addEventListener(ZipEvent.ZIP_DATA_UNCOMPRESS,uncompressData);
zipReader.open(file);
var entries:Array = zipReader.getEntries();
for(var i:int = 0; i

The last time I introduced the features of “Airxzip”, this post says one of the features.

Change file system and set filemode and directory mode

var writer:ZipFileWriter = new ZipFileWriter(ZipFileWriter.HOST_UNIX);
writer.open(File.desktopDirectory.resolvePath("airxzip_unix.zip"));
	
writer.setDirMode("0700");
writer.setFileMode("0700");

writer.addDirectory("Foo1");
writer.addFile(File.desktopDirectory.resolvePath("image.jpg"),"Foo2/image.jpg");

writer.setFileMode("0766");
writer.addFile(File.desktopDirectory.resolvePath("image.jpg"),"Foo3/image.jpg");
writer.close();
unzip -Z airxzip_unix.zip 
Archive:  airxzip_unix.zip   1550668 bytes   3 files
drwx------  1.0 unx        0 b- stor  6-May-10 20:11 Foo1/
-rwx------  2.0 unx   777835 b- defN 14-Jul-09 14:32 Foo2/image.jpg
-rwxrw-rw-  2.0 unx   777835 b- defN 14-Jul-09 14:32 Foo3/image.jpg

Default filetype is “ZipFileWriter.HOST_WIN”.
So If you want to create zip file for Mac or Unix/Linux , Please set “ZipFileWriter.HOST_UNIX”.

var writer:ZipFileWriter = new ZipFileWriter(ZipFileWriter.HOST_UNIX);

Default file system

 unzip -Z async_airxzip.zip 
Archive:  async_airxzip.zip   775492 bytes   3 files
-rw-a--     2.0 fat        6 b- defN  6-May-10 20:12 sample.txt
drwx---     1.0 fat        0 b- stor  6-May-10 20:12 Foo1/
-rw-a--     2.0 fat   777835 b- defN 14-Jul-09 14:32 Foo1/image.jpg
RSS
Add to Google
2017年5月
« 2月    
 123456
78910111213
14151617181920
21222324252627
28293031