home *** CD-ROM | disk | FTP | other *** search
- package com.zerog.ia.download.utility;
-
- import java.io.IOException;
- import java.io.InputStream;
-
- public class ZGProcess {
- // $FF: renamed from: p java.lang.Process
- Process field_0;
- // $FF: renamed from: is java.io.InputStream
- InputStream field_1;
- int maxWait;
- int totalSleepTime;
-
- public ZGProcess(String var1) throws IOException {
- this(var1, 3000);
- }
-
- public ZGProcess(String var1, int var2) throws IOException {
- this.field_0 = null;
- this.field_1 = null;
- this.maxWait = 3000;
- this.totalSleepTime = 0;
-
- try {
- this.field_0 = Runtime.getRuntime().exec(var1);
- } catch (IOException var4) {
- }
-
- this.field_1 = this.field_0.getInputStream();
- this.maxWait = var2;
- }
-
- public InputStream getInputStream() {
- return this.field_1;
- }
-
- private int getChar() {
- byte var1 = 50;
- char var2 = 0;
-
- while(!this.dataWaiting() && this.totalSleepTime < this.maxWait) {
- try {
- Thread.sleep((long)var1);
- this.totalSleepTime += var1;
- } catch (Exception var5) {
- }
- }
-
- if (!this.dataWaiting()) {
- return -1;
- } else {
- try {
- var2 = (char)this.field_1.read();
- } catch (Exception var4) {
- }
-
- return var2;
- }
- }
-
- public String getLine() {
- boolean var1 = false;
- StringBuffer var2 = new StringBuffer();
- if (this.isDone() && !this.dataWaiting()) {
- return null;
- } else {
- for(int var3 = this.getChar(); this.totalSleepTime < this.maxWait && var3 > 0 && var3 != 10; var3 = this.getChar()) {
- var2.append((char)var3);
- }
-
- return var2.toString();
- }
- }
-
- private boolean dataWaiting() {
- try {
- if (this.field_1.available() > 0) {
- return true;
- }
- } catch (IOException var2) {
- }
-
- return false;
- }
-
- private boolean isDone() {
- try {
- this.field_0.exitValue();
- return true;
- } catch (IllegalThreadStateException var2) {
- return false;
- }
- }
-
- private int exitValue() throws IllegalThreadStateException {
- return this.field_0.exitValue();
- }
-
- private static String concatenateCmdLine(String[] var0) {
- int var1 = var0.length;
- StringBuffer var2 = new StringBuffer();
- Object var3 = null;
-
- for(int var4 = 0; var4 < var1; ++var4) {
- var2.append(var0[var4] + " ");
- }
-
- String var5 = var2.toString();
- return var5.substring(0, var5.length() - 1);
- }
- }
-