mirror of
https://github.com/Cametendo/cflash.git
synced 2026-03-18 04:50:19 +01:00
create devicecheck, filepathcheck and blocksize
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -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
34
BlockSize.java
Normal 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
9
FilePathAdd.java
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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)");
|
||||
}
|
||||
|
||||
@@ -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
27
StorageDeviceLister.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user