mkdir working (at least on windows)

master
Allen Webster 2017-11-21 16:47:40 -05:00
parent edd941b5fd
commit 59872d0b38
3 changed files with 38 additions and 4 deletions

View File

@ -1126,6 +1126,37 @@ CUSTOM_DOC("Queries the user for a new name and renames the file of the current
} }
} }
CUSTOM_COMMAND_SIG(make_directory_query)
CUSTOM_DOC("Queries the user for a name and creates a new directory with the given name.")
{
char hot_space[2048];
int32_t hot_length = directory_get_hot(app, hot_space, sizeof(hot_space));
if (hot_length < sizeof(hot_space)){
String hot = make_string(hot_space, hot_length);
// Query the user
Query_Bar bar;
char prompt_space[4096];
bar.prompt = make_fixed_width_string(prompt_space);
append(&bar.prompt, "Make directory at '");
append(&bar.prompt, hot);
append(&bar.prompt, "': ");
char name_space[4096];
bar.string = make_fixed_width_string(name_space);
if (!query_user_string(app, &bar)) return;
if (bar.string.size == 0) return;
char cmd_space[4096];
String cmd = make_fixed_width_string(cmd_space);
append(&cmd, "mkdir ");
if (append_checked(&cmd, bar.string)){
exec_system_command(app, 0, buffer_identifier(0), hot.str, hot.size, cmd.str, cmd.size, 0);
}
}
}
// //
// cmdid wrappers // cmdid wrappers
// //

View File

@ -725,6 +725,9 @@ CUSTOM_DOC("Execute a 'long form' command.")
else if (match_ss(bar.string, make_lit_string("rename file"))){ else if (match_ss(bar.string, make_lit_string("rename file"))){
rename_file_query(app); rename_file_query(app);
} }
else if (match_ss(bar.string, make_lit_string("mkdir"))){
make_directory_query(app);
}
else{ else{
print_message(app, literal("unrecognized command\n")); print_message(app, literal("unrecognized command\n"));
} }

View File

@ -2604,10 +2604,10 @@ DOC_SEE(Theme_Color)
API_EXPORT int32_t API_EXPORT int32_t
Directory_Get_Hot(Application_Links *app, char *out, int32_t capacity) Directory_Get_Hot(Application_Links *app, char *out, int32_t capacity)
/* /*
DOC_PARAM(out, This parameter provides a character buffer that receives the 4coder 'hot directory'.) DOC_PARAM(out, On success this character buffer is filled with the 4coder 'hot directory'.)
DOC_PARAM(capacity, This parameter specifies the maximum size to be output to the out buffer.) DOC_PARAM(capacity, Specifies the capacity in bytes of the of the out buffer.)
DOC_RETURN(This call returns the size of the string written into the buffer.) DOC(4coder has a concept of a 'hot directory' which is the directory most recently accessed in the GUI. Whenever the GUI is opened it shows the hot directory. In the future this will be deprecated and eliminated in favor of more flexible hot directories created and controlled in the custom layer.)
DOC(4coder has a concept of a 'hot directory' which is the directory most recently accessed in the GUI. Whenever the GUI is opened it shows the hot directory. In the future this will be deprecated and eliminated in favor of more flexible directories controlled on the custom side.) DOC_RETURN(This call returns the length of the hot directory string whether or not it was successfully copied into the output buffer. The call is successful if and only if capacity is greater than or the return size.)
DOC_SEE(directory_set_hot) DOC_SEE(directory_set_hot)
*/{ */{
Command_Data *cmd = (Command_Data*)app->cmd_context; Command_Data *cmd = (Command_Data*)app->cmd_context;