001 package railo.commons.io.compress; 002 003 import java.io.IOException; 004 import java.util.zip.ZipOutputStream; 005 006 import railo.commons.cli.Command; 007 import railo.commons.io.CompressUtil; 008 import railo.commons.io.res.Resource; 009 010 public final class ZipUtil { 011 012 public static void unzip(Resource zip, Resource dir) throws IOException { 013 if(zip.length()>0 && (dir.exists() || dir.mkdirs())) { 014 if("Mac OS X".equalsIgnoreCase(System.getProperty("os.name"))) { 015 try { 016 //Command.execute("unzip "+zip+" -d "+dir); 017 Command.execute("unzip",new String[]{"-o",zip.getAbsolutePath(),"-d",dir.getAbsolutePath()}); 018 } 019 catch (InterruptedException e) {} 020 return; 021 } 022 CompressUtil.extract(CompressUtil.FORMAT_ZIP, zip, dir); 023 } 024 } 025 026 public static void cloeseEL(ZipOutputStream zos) { 027 if(zos==null) return; 028 try { 029 zos.close(); 030 } 031 catch (IOException e) {} 032 } 033 }