create devicecheck, filepathcheck and blocksize

This commit is contained in:
Cametendo
2026-02-09 11:58:37 +01:00
parent baab63f846
commit 4d6e8b975f
6 changed files with 83 additions and 4 deletions

6
.gitignore vendored
View File

@@ -22,3 +22,9 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
# IDE Stuff
.vscode/*
.vscode/
*.vscode
.vscode

34
BlockSize.java Normal file
View File

@@ -0,0 +1,34 @@
import java.util.Scanner;
public class BlockSize {
public static void blockSize(Scanner UserInput) {
System.out.println("Choose a block size (Default: 4M)");
System.out.println("512KB (1), 1M (2), 2M (3), 4M (4), 8M (5), 16M (6)");
String blockSizeInput = UserInput.nextLine();
String blockSizeString;
switch (blockSizeInput) {
case "1":
blockSizeString = "512KB";
break;
case "2":
blockSizeString = "1M";
break;
case "3":
blockSizeString = "2M";
break;
case "4":
blockSizeString = "4M";
break;
case "5":
blockSizeString = "8M";
break;
case "6":
blockSizeString = "16M";
break;
default:
blockSizeString = "4M";
break;
}
}
}

9
FilePathAdd.java Normal file
View File

@@ -0,0 +1,9 @@
import java.util.Scanner;
public class FilePathAdd {
public static void filePath(Scanner UserInput) {
System.out.println("Please enter the FULL Path of your ISO / Image. ()");
String Path = UserInput.nextLine();
System.out.println("Using File: " + Path);
}
}

View File

@@ -1,5 +1,5 @@
public class Greeting {
public void greeting() {
public static void greeting() {
System.out.println("Welcome to cflash!");
System.out.println("Would you like to flash an image (Y/n)");
}

View File

@@ -1,18 +1,21 @@
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
public static void main(String[] args) throws InterruptedException {
Scanner UserInput = new Scanner(System.in);
greeting();
Greeting.greeting();
String input = UserInput.nextLine();
if (YesNo.check(input)) {
System.out.println("Please choose a device");
System.out.println("Please choose the to be flashed device (f. e. sda)");
} else {
System.out.println("Canceling...");
System.exit(0);
}
StorageDeviceLister.deviceList(UserInput);
FilePathAdd.filePath(UserInput);
}

27
StorageDeviceLister.java Normal file
View File

@@ -0,0 +1,27 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class StorageDeviceLister {
static void deviceList(Scanner UserInput) {
try {
ProcessBuilder pb = new ProcessBuilder("lsblk");
Process process = pb.start();
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream())
);
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
String device = UserInput.nextLine();
System.out.println("Using device: " + device);
}
}