CE add mkdir command, implement create_dir () syscall
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m1s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m1s
This commit is contained in:
27
ce/interp.c
27
ce/interp.c
@@ -49,6 +49,30 @@ static void mkfile (struct context* context, char** file_paths, size_t files_cou
|
||||
}
|
||||
}
|
||||
|
||||
static void mkdir (struct context* context, char** dir_paths, size_t dirs_count) {
|
||||
char volume[VOLUME_MAX];
|
||||
const char* path;
|
||||
int ret;
|
||||
|
||||
for (size_t i = 0; i < dirs_count; i++) {
|
||||
const char* dir_path = dir_paths[i];
|
||||
|
||||
if (!path_parse (dir_path, volume, &path)) {
|
||||
cprintf (context, "ERROR bad path '%s'\n", dir_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ret = volume_open (volume)) < 0) {
|
||||
cprintf (context, "ERROR could not open volume '%s': %s\n", volume, str_status[-ret]);
|
||||
continue;
|
||||
}
|
||||
|
||||
create_dir (path);
|
||||
|
||||
volume_close ();
|
||||
}
|
||||
}
|
||||
|
||||
static void cat (struct context* context, char** file_paths, size_t files_count) {
|
||||
char volume[VOLUME_MAX];
|
||||
const char* path;
|
||||
@@ -153,6 +177,7 @@ static void help (struct context* context) {
|
||||
cprintf (context, "cat <file path>\n");
|
||||
cprintf (context, "ls <directory path>\n");
|
||||
cprintf (context, "mkfile <file path>\n");
|
||||
cprintf (context, "mkdir <directory path>\n");
|
||||
cprintf (context, "quit\n");
|
||||
}
|
||||
|
||||
@@ -185,6 +210,8 @@ static void execute_cmd (struct ast_cmd* cmd, struct context* context) {
|
||||
quit1 (context);
|
||||
} else if (strcmp (cmd->name, "mkfile") == 0) {
|
||||
mkfile (context, cmd->args, cmd->arg_count);
|
||||
} else if (strcmp (cmd->name, "mkdir") == 0) {
|
||||
mkdir (context, cmd->args, cmd->arg_count);
|
||||
} else {
|
||||
/* cprintf (context, "ERROR unknown command '%s'\n", cmd->name); */
|
||||
char volume[VOLUME_MAX];
|
||||
|
||||
Reference in New Issue
Block a user