mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-12 14:10:36 -04:00
Prepare prototypes for mkdir command
This commit is contained in:
parent
4a3910fe05
commit
ce86d48d6b
@ -66,6 +66,7 @@ void unmount();
|
||||
std::vector<file> ls();
|
||||
uint64_t free_size();
|
||||
|
||||
bool mkdir(const std::string& directory);
|
||||
std::string read_file(const std::string& file);
|
||||
|
||||
const disk_descriptor* mounted_disk();
|
||||
|
@ -20,6 +20,8 @@ typedef const disks::disk_descriptor& dd;
|
||||
uint64_t free_size(dd disk, const disks::partition_descriptor& partition);
|
||||
std::vector<disks::file> ls(dd disk, const disks::partition_descriptor& partition, const std::vector<std::string>& path);
|
||||
std::string read_file(dd disk, const disks::partition_descriptor& partition, const std::vector<std::string>& path, const std::string& file);
|
||||
bool mkdir(dd disk, const disks::partition_descriptor& partition, const std::vector<std::string>& path, const std::string& directory);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -237,3 +237,11 @@ std::string disks::read_file(const std::string& file){
|
||||
|
||||
return fat32::read_file(*_mounted_disk, *_mounted_partition, pwd, file);
|
||||
}
|
||||
|
||||
bool disks::mkdir(const std::string& directory){
|
||||
if(!_mounted_disk || !_mounted_partition){
|
||||
return false;
|
||||
}
|
||||
|
||||
return fat32::mkdir(*_mounted_disk, *_mounted_partition, pwd, directory);
|
||||
}
|
||||
|
@ -456,3 +456,11 @@ std::string fat32::read_file(dd disk, const disks::partition_descriptor& partiti
|
||||
|
||||
return std::move(content);
|
||||
}
|
||||
|
||||
bool fat32::mkdir(dd disk, const disks::partition_descriptor& partition, const std::vector<std::string>& path, const std::string& directory){
|
||||
if(!cache_disk_partition(disk, partition)){
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ void cd_command(const std::vector<std::string>& params);
|
||||
void pwd_command(const std::vector<std::string>& params);
|
||||
void free_command(const std::vector<std::string>& params);
|
||||
void cat_command(const std::vector<std::string>& params);
|
||||
void mkdir_command(const std::vector<std::string>& params);
|
||||
void shutdown_command(const std::vector<std::string>& params);
|
||||
|
||||
struct command_definition {
|
||||
@ -65,7 +66,7 @@ struct command_definition {
|
||||
void (*function)(const std::vector<std::string>&);
|
||||
};
|
||||
|
||||
command_definition commands[21] = {
|
||||
command_definition commands[22] = {
|
||||
{"reboot", reboot_command},
|
||||
{"help", help_command},
|
||||
{"uptime", uptime_command},
|
||||
@ -86,6 +87,7 @@ command_definition commands[21] = {
|
||||
{"pwd", pwd_command},
|
||||
{"sysinfo", sysinfo_command},
|
||||
{"cat", cat_command},
|
||||
{"mkdir", mkdir_command},
|
||||
{"shutdown", shutdown_command},
|
||||
};
|
||||
|
||||
@ -578,6 +580,29 @@ void cat_command(const std::vector<std::string>& params){
|
||||
}
|
||||
}
|
||||
|
||||
void mkdir_command(const std::vector<std::string>& params){
|
||||
if(!disks::mounted_partition() || !disks::mounted_disk()){
|
||||
k_print_line("Nothing is mounted");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(params.size() == 1){
|
||||
k_print_line("No directory provided");
|
||||
} else {
|
||||
auto& directory_name = params[1];
|
||||
auto directory = find_file(directory_name);
|
||||
|
||||
if(directory){
|
||||
k_printf("mkdir: Cannot create directory '%s': File exists\n", directory_name.c_str());
|
||||
} else {
|
||||
if(!disks::mkdir(directory_name)){
|
||||
k_print_line("Directory creation failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void shutdown_command(const std::vector<std::string>&){
|
||||
if(!acpi::init()){
|
||||
k_print_line("Unable to init ACPI");
|
||||
|
Loading…
x
Reference in New Issue
Block a user