Skip to content

Commit

Permalink
Can't make a release without shit breaking apparently
Browse files Browse the repository at this point in the history
  • Loading branch information
XorTroll committed Aug 20, 2023
1 parent f9c3013 commit 7a29e66
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
9 changes: 4 additions & 5 deletions emuiigen/src/Utils.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.xortroll.emuiibo.emuiigen

import org.apache.commons.io.FileUtils
import org.apache.commons.io.FilenameUtils
import org.apache.commons.io.IOUtils
import org.apache.commons.net.ftp.FTPClient
import org.apache.commons.net.ftp.FTPReply
import java.net.URL
import java.io.File
import java.io.FileOutputStream
import java.nio.charset.StandardCharsets
import java.nio.channels.Channels
import java.text.Normalizer
import java.io.FileOutputStream

class Utils {
companion object {
Expand All @@ -33,10 +35,7 @@ class Utils {
}

fun netDownloadFile(url: String, path: String) {
val url_v = URL(url);
val ch = Channels.newChannel(url_v.openStream());
val fos = FileOutputStream(path);
fos.getChannel().transferFrom(ch, 0, Long.MAX_VALUE);
FileUtils.copyURLToFile(URL(url), File(path), 10000, 10000);
}

fun unaccentString(str: String) : String {
Expand Down
33 changes: 30 additions & 3 deletions emuiigen/src/ui/MainController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,21 @@ class MainController {
FileUtils.deleteDirectory(Paths.get(TemporaryFtpDirectory).toAbsolutePath().toFile());
}

fun processFtpPort(is_ftp: Boolean, port_str: String) : Int? {
if(is_ftp) {
try {
return port_str.toInt();
}
catch(ex: Exception) {
this.showError("Invalid FTP port: " + ex.toString());
return null;
}
}
else {
return 0;
}
}

fun chooseBaseAmiiboPath(is_ftp: Boolean) : Pair<String, String>? {
val path = if(is_ftp) {
Paths.get(TemporaryFtpDirectory).toAbsolutePath()
Expand Down Expand Up @@ -451,7 +466,11 @@ class MainController {

val is_ftp = this@MainController.GenerateOneFtpCheck.isSelected();
val ftp_addr = this@MainController.GenerateOneFtpAddress.getText();
val ftp_port = this@MainController.GenerateOneFtpPort.getText().toInt();
val ftp_port = this@MainController.processFtpPort(is_ftp, this@MainController.GenerateOneFtpPort.getText());
if(ftp_port == null) {
return;
}

val use_random_uuid = this@MainController.GenerateOneUseRandomUuidCheck.isSelected();
val save_image = this@MainController.GenerateOneImageSaveCheck.isSelected();

Expand Down Expand Up @@ -489,7 +508,11 @@ class MainController {

val is_ftp = this@MainController.GenerateAllFtpCheck.isSelected();
val ftp_addr = this@MainController.GenerateAllFtpAddress.getText();
val ftp_port = this@MainController.GenerateAllFtpPort.getText().toInt();
val ftp_port = this@MainController.processFtpPort(is_ftp, this@MainController.GenerateAllFtpPort.getText());
if(ftp_port == null) {
return;
}

val use_random_uuid = this@MainController.GenerateAllUseRandomUuidCheck.isSelected();
val save_image = this@MainController.GenerateAllImageSaveCheck.isSelected();

Expand Down Expand Up @@ -529,7 +552,11 @@ class MainController {

val is_ftp = this@MainController.GenerateSeriesFtpCheck.isSelected();
val ftp_addr = this@MainController.GenerateSeriesFtpAddress.getText();
val ftp_port = this@MainController.GenerateSeriesFtpPort.getText().toInt();
val ftp_port = this@MainController.processFtpPort(is_ftp, this@MainController.GenerateSeriesFtpPort.getText());
if(ftp_port == null) {
return;
}

val use_random_uuid = this@MainController.GenerateSeriesUseRandomUuidCheck.isSelected();
val save_image = this@MainController.GenerateSeriesImageSaveCheck.isSelected();

Expand Down

0 comments on commit 7a29e66

Please sign in to comment.