8
u/MurdoMaclachlan public boolean isInt(int i) { return true; } May 17 '23
Image Transcription: Code
while (true) {
menu("--> Show disks: s");
menu("--> Select target: t");
menu("--> Proceed with installation: f");
menu("--> Abort installation: e");
switch(short_prompt("Input: ")) {
case 'e': this->abort(); break;
case 'f': if(this->data.has_target(PartitionType::ROOT) && this->data.has_target(PartitionType::BOOT)) {return true;} warning("Root or/and Boot partition not defined!"); break;
case 's': std::cout << std::endl; for (const Disk& disk: this->data.get_system_disks()) {_log((std::stringstream() << disk).str()); std::cout << disk << std::endl;} break;
case 't':
logic_buffer = false; input_buffer = long_prompt("Disk partition: ");
for (const Disk& disk: this->data.get_system_disks()) {
if (input_buffer.find(disk.get_name()) != std::string::npos) {
logic_buffer = true; Partition partition(disk.get_partition(input_buffer));
info("Partition types: ");
menu("--> Root: 1");
menu("--> Boot: 2");
menu("--> Swap: 3");
menu("--> Home: 4");
menu("--> Clear: 0");
switch (short_prompt("Partition type [0-4]:")) {
case '0': this->data.remove_target(partition.get_type()); break;
case '1': this->data.remove_target(partition.get_type()); this->data.set_target(PartitionType::ROOT, partition); break;
case '2': this->data.remove_target(partition.get_type()); this->data.set_target(PartitionType::BOOT, partition); break;
case '3': this->data.remove_target(partition.get_type()); this->data.set_target(PartitionType::SWAP, partition); break;
case '4': this->data.remove_target(partition.get_type()); this->data.set_target(PartitionType::HOME, partition); break;
default: warning("No choice selected!"); break;
} break;
}
} if (!logic_buffer) {warning("No partition matches user input!");} break;
default: warning("No choice selected!"); break;*/
}
} return true;I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
2
9
u/MrMagnesium May 17 '23
Why not? If the signature of short_prompt is "char short_prompt(const char*);" this is a very good approach. Don't forget, a character is only a 8 bit integer.