117 TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
118 ? null
119 : TimeZone.getDefault();
120
121 try {
122 Utils.currentInstance.set(this);
123 if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
124 final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
125 BufferedInputStream in0 = new BufferedInputStream(in);
126 if (Utils.isJarMagic(Utils.readMagic(in0))) {
127 if (verbose > 0)
128 Utils.log.info("Copying unpacked JAR file...");
129 Utils.copyJarFile(new JarInputStream(in0), out);
130 } else if (props.getBoolean(Utils.DEBUG_DISABLE_NATIVE)) {
131 (new DoUnpack()).run(in0, out);
132 in0.close();
133 Utils.markJarFile(out);
134 } else {
135 try {
136 (new NativeUnpack(this)).run(in0, out);
137 } catch (UnsatisfiedLinkError ule) {
138 // failover to java implementation
139 (new DoUnpack()).run(in0, out);
140 }
141 in0.close();
142 Utils.markJarFile(out);
143 }
144 } finally {
145 _nunp = null;
146 Utils.currentInstance.set(null);
147 if (tz != null) TimeZone.setDefault(tz);
148 }
149 }
150
151 /**
152 * Takes an input File containing the pack file, and generates a JarOutputStream.
153 * <p>
154 * Does not close its output. (The output can accumulate more elements.)
155 * @param in a File.
156 * @param out a JarOutputStream.
157 * @exception IOException if an error is encountered.
|
117 TimeZone tz = (props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))
118 ? null
119 : TimeZone.getDefault();
120
121 try {
122 Utils.currentInstance.set(this);
123 if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
124 final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
125 BufferedInputStream in0 = new BufferedInputStream(in);
126 if (Utils.isJarMagic(Utils.readMagic(in0))) {
127 if (verbose > 0)
128 Utils.log.info("Copying unpacked JAR file...");
129 Utils.copyJarFile(new JarInputStream(in0), out);
130 } else if (props.getBoolean(Utils.DEBUG_DISABLE_NATIVE)) {
131 (new DoUnpack()).run(in0, out);
132 in0.close();
133 Utils.markJarFile(out);
134 } else {
135 try {
136 (new NativeUnpack(this)).run(in0, out);
137 } catch (UnsatisfiedLinkError | NoClassDefFoundError ex) {
138 // failover to java implementation
139 (new DoUnpack()).run(in0, out);
140 }
141 in0.close();
142 Utils.markJarFile(out);
143 }
144 } finally {
145 _nunp = null;
146 Utils.currentInstance.set(null);
147 if (tz != null) TimeZone.setDefault(tz);
148 }
149 }
150
151 /**
152 * Takes an input File containing the pack file, and generates a JarOutputStream.
153 * <p>
154 * Does not close its output. (The output can accumulate more elements.)
155 * @param in a File.
156 * @param out a JarOutputStream.
157 * @exception IOException if an error is encountered.
|