one day we will end up with gradle
This commit is contained in:
parent
f56c25d7f6
commit
6fa138f3c1
|
@ -0,0 +1,4 @@
|
|||
package com.rusefi;
|
||||
|
||||
public class ConnectionAndMeta {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package com.rusefi.shared;
|
||||
|
||||
public class FileUtil {
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
<module fileurl="file://$PROJECT_DIR$/models/models.iml" filepath="$PROJECT_DIR$/models/models.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/opensr5/opensr5.iml" filepath="$PROJECT_DIR$/opensr5/opensr5.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/romraider/romraider.iml" filepath="$PROJECT_DIR$/romraider/romraider.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/shared_io/shared_io.iml" filepath="$PROJECT_DIR$/shared_io/shared_io.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/shared_ui/shared_ui.iml" filepath="$PROJECT_DIR$/shared_ui/shared_ui.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/tools/tools.iml" filepath="$PROJECT_DIR$/tools/tools.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/ui/ui.iml" filepath="$PROJECT_DIR$/ui/ui.iml" />
|
||||
|
|
|
@ -8,5 +8,6 @@
|
|||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="annotations" level="project" />
|
||||
<orderEntry type="module" module-name="shared_io" />
|
||||
</component>
|
||||
</module>
|
|
@ -1,6 +1,7 @@
|
|||
package com.rusefi.autoupdate;
|
||||
|
||||
import com.rusefi.shared.ConnectionAndMeta;
|
||||
import com.rusefi.shared.FileUtil;
|
||||
import com.rusefi.ui.util.FrameHelper;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -14,8 +15,6 @@ import java.net.URLClassLoader;
|
|||
import java.util.Date;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||
|
||||
|
@ -93,7 +92,7 @@ public class Autoupdate {
|
|||
file.setLastModified(lastModified);
|
||||
System.out.println("Downloaded " + file.length() + " bytes");
|
||||
|
||||
unzip(zipFileName, "..");
|
||||
FileUtil.unzip(zipFileName, "..");
|
||||
} catch (Exception e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
|
@ -193,48 +192,6 @@ public class Autoupdate {
|
|||
}
|
||||
}
|
||||
|
||||
private static void unzip(String zipFileName, String destPath) throws IOException {
|
||||
File destDir = new File(destPath);
|
||||
byte[] buffer = new byte[1024];
|
||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName));
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
while (zipEntry != null) {
|
||||
File newFile = newFile(destDir, zipEntry);
|
||||
if (newFile.isDirectory()) {
|
||||
System.out.println("Nothing to do for directory " + newFile);
|
||||
} else {
|
||||
unzipFile(buffer, zis, newFile);
|
||||
}
|
||||
zipEntry = zis.getNextEntry();
|
||||
}
|
||||
zis.closeEntry();
|
||||
zis.close();
|
||||
System.out.println("Unzip " + zipFileName + " to " + destPath + " worked!");
|
||||
}
|
||||
|
||||
private static void unzipFile(byte[] buffer, ZipInputStream zis, File newFile) throws IOException {
|
||||
System.out.println("Unzipping " + newFile);
|
||||
FileOutputStream fos = new FileOutputStream(newFile);
|
||||
int len;
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len);
|
||||
}
|
||||
fos.close();
|
||||
}
|
||||
|
||||
private static File newFile(File destinationDir, ZipEntry zipEntry) throws IOException {
|
||||
File destFile = new File(destinationDir, zipEntry.getName());
|
||||
|
||||
String destDirPath = destinationDir.getCanonicalPath();
|
||||
String destFilePath = destFile.getCanonicalPath();
|
||||
|
||||
if (!destFilePath.startsWith(destDirPath + File.separator)) {
|
||||
throw new IOException("Entry is outside of the target dir: " + zipEntry.getName());
|
||||
}
|
||||
|
||||
return destFile;
|
||||
}
|
||||
|
||||
enum UpdateMode {
|
||||
ALWAYS,
|
||||
NEVER,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
classpath="lib/annotations.jar"
|
||||
>
|
||||
<src path="autoupdate/src"/>
|
||||
<src path="shared_io/src/main/java"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
|
@ -47,6 +48,7 @@
|
|||
<src path="models/src"/>
|
||||
<src path="inifile/src"/>
|
||||
<src path="shared_ui/src"/>
|
||||
<src path="shared_io/src/main/java"/>
|
||||
<src path="ui/src/main/java"/>
|
||||
<src path="ui/src/test/java"/>
|
||||
<src path="romraider/src"/>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,52 @@
|
|||
package com.rusefi.shared;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class FileUtil {
|
||||
public static void unzip(String zipFileName, String destPath) throws IOException {
|
||||
File destDir = new File(destPath);
|
||||
byte[] buffer = new byte[1024];
|
||||
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName));
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
while (zipEntry != null) {
|
||||
File newFile = newFile(destDir, zipEntry);
|
||||
if (newFile.isDirectory()) {
|
||||
System.out.println("Nothing to do for directory " + newFile);
|
||||
} else {
|
||||
unzipFile(buffer, zis, newFile);
|
||||
}
|
||||
zipEntry = zis.getNextEntry();
|
||||
}
|
||||
zis.closeEntry();
|
||||
zis.close();
|
||||
System.out.println("Unzip " + zipFileName + " to " + destPath + " worked!");
|
||||
}
|
||||
|
||||
private static void unzipFile(byte[] buffer, ZipInputStream zis, File newFile) throws IOException {
|
||||
System.out.println("Unzipping " + newFile);
|
||||
FileOutputStream fos = new FileOutputStream(newFile);
|
||||
int len;
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len);
|
||||
}
|
||||
fos.close();
|
||||
}
|
||||
|
||||
private static File newFile(File destinationDir, ZipEntry zipEntry) throws IOException {
|
||||
File destFile = new File(destinationDir, zipEntry.getName());
|
||||
|
||||
String destDirPath = destinationDir.getCanonicalPath();
|
||||
String destFilePath = destFile.getCanonicalPath();
|
||||
|
||||
if (!destFilePath.startsWith(destDirPath + File.separator)) {
|
||||
throw new IOException("Entry is outside of the target dir: " + zipEntry.getName());
|
||||
}
|
||||
|
||||
return destFile;
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
>
|
||||
<src path="${console_path}/shared_ui/src"/>
|
||||
<src path="${console_path}/autoupdate/src"/>
|
||||
<src path="${console_path}/shared_io/src/main/java"/>
|
||||
<src path="${console_path}/inifile/src"/>
|
||||
<src path="${console_path}/logging/src"/>
|
||||
<src path="${console_path}/models/src"/>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
classpath="${console_path}/lib/junit.jar:${console_path}/lib/annotations.jar:lib/TunerStudioPluginAPI.jar:${console_path}/lib/httpclient.jar:${console_path}/lib/httpmime.jar:${console_path}/lib/httpcore.jar"
|
||||
>
|
||||
<src path="${console_path}/autoupdate/src"/>
|
||||
<src path="${console_path}/shared_io/src/main/java"/>
|
||||
<src path="src"/>
|
||||
</javac>
|
||||
|
||||
|
|
Loading…
Reference in New Issue