From 4d6e8b975fe655c070ebb5e9f8154936070c62e9 Mon Sep 17 00:00:00 2001 From: Cametendo Date: Mon, 9 Feb 2026 11:58:37 +0100 Subject: [PATCH] create devicecheck, filepathcheck and blocksize --- .gitignore | 6 ++++++ BlockSize.java | 34 ++++++++++++++++++++++++++++++++++ FilePathAdd.java | 9 +++++++++ Greeting.java | 2 +- Main.java | 9 ++++++--- StorageDeviceLister.java | 27 +++++++++++++++++++++++++++ 6 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 BlockSize.java create mode 100644 FilePathAdd.java create mode 100644 StorageDeviceLister.java diff --git a/.gitignore b/.gitignore index 524f096..2d00de4 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/BlockSize.java b/BlockSize.java new file mode 100644 index 0000000..df320e3 --- /dev/null +++ b/BlockSize.java @@ -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; + } + } +} diff --git a/FilePathAdd.java b/FilePathAdd.java new file mode 100644 index 0000000..fc8d79c --- /dev/null +++ b/FilePathAdd.java @@ -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); + } +} diff --git a/Greeting.java b/Greeting.java index 3c8be62..5c286c2 100644 --- a/Greeting.java +++ b/Greeting.java @@ -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)"); } diff --git a/Main.java b/Main.java index 5c64a51..18a79c7 100644 --- a/Main.java +++ b/Main.java @@ -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); + } diff --git a/StorageDeviceLister.java b/StorageDeviceLister.java new file mode 100644 index 0000000..26c7b20 --- /dev/null +++ b/StorageDeviceLister.java @@ -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); + } +}