mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-27 23:20:40 +00:00
Add fs.cwd to define default path in ms
##fs
* Remove unnecessary global variable
This commit is contained in:
parent
d77eb85476
commit
a297b27773
@ -3917,7 +3917,8 @@ R_API int r_core_config_init(RCore *core) {
|
||||
/* filesystem */
|
||||
n = NODECB ("fs.view", "normal", &cb_fsview);
|
||||
SETDESC (n, "set visibility options for filesystems");
|
||||
SETOPTIONS (n, "all", "deleted", "special", NULL);
|
||||
SETOPTIONS (n, "all", "normal", "deleted", "special", NULL);
|
||||
n = SETPREF ("fs.cwd", "/", "current working directory (see 'ms' command)");
|
||||
|
||||
/* hexdump */
|
||||
SETCB ("hex.header", "true", &cb_hex_header, "show header in hexdump");
|
||||
|
@ -54,7 +54,6 @@ static int cmd_mv(void *data, const char *input) {
|
||||
return r_syscmd_mv (input)? 1: 0;
|
||||
}
|
||||
|
||||
static R_TH_LOCAL char *cwd = NULL;
|
||||
#define av_max 1024
|
||||
|
||||
static const char *t2s(const char ch) {
|
||||
@ -475,6 +474,7 @@ static int cmd_mount(void *data, const char *_input) {
|
||||
input = (char *)r_str_trim_head_ro (input + 1);
|
||||
r_cons_set_raw (false);
|
||||
{
|
||||
char *cwd = strdup (r_config_get (core->config, "fs.cwd"));
|
||||
RFSShell shell = {
|
||||
.cwd = &cwd,
|
||||
.set_prompt = r_line_set_prompt,
|
||||
@ -487,6 +487,7 @@ static int cmd_mount(void *data, const char *_input) {
|
||||
r_fs_shell_prompt (&shell, core->fs, input);
|
||||
core->autocomplete_type = AUTOCOMPLETE_DEFAULT;
|
||||
r_core_autocomplete_reload (core);
|
||||
r_config_set (core->config, "fs.cwd", cwd);
|
||||
R_FREE (cwd);
|
||||
}
|
||||
break;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare2 - LGPL - Copyright 2018-2021 - pancake */
|
||||
/* radare2 - LGPL - Copyright 2018-2022 - pancake */
|
||||
|
||||
#include <r_fs.h>
|
||||
|
||||
@ -36,12 +36,11 @@ R_API int r_fs_shell_prompt(RFSShell* shell, RFS* fs, const char* root) {
|
||||
char prompt[PROMPT_PATH_BUFSIZE];
|
||||
char str[2048];
|
||||
char* input;
|
||||
const char* ptr;
|
||||
RList* list = NULL;
|
||||
RListIter* iter;
|
||||
RFSFile* file = NULL;
|
||||
|
||||
if (root && *root) {
|
||||
if (R_STR_ISNOTEMPTY (root)) {
|
||||
strncpy (buf, root, sizeof (buf) - 1);
|
||||
r_str_trim_path (buf);
|
||||
list = r_fs_root (fs, buf);
|
||||
@ -52,7 +51,11 @@ R_API int r_fs_shell_prompt(RFSShell* shell, RFS* fs, const char* root) {
|
||||
}
|
||||
r_str_ncpy (path, buf, sizeof (path) - 1);
|
||||
} else {
|
||||
strcpy (path, "/");
|
||||
if (R_STR_ISNOTEMPTY (shell->cwd)) {
|
||||
r_str_ncpy (path, *shell->cwd, sizeof (path) - 1);
|
||||
} else {
|
||||
strcpy (path, "/");
|
||||
}
|
||||
}
|
||||
|
||||
PrintfCallback cb_printf = fs->csb.cb_printf;
|
||||
@ -65,7 +68,8 @@ R_API int r_fs_shell_prompt(RFSShell* shell, RFS* fs, const char* root) {
|
||||
shell->set_prompt (prompt);
|
||||
}
|
||||
if (shell->readline) {
|
||||
if ((ptr = shell->readline ()) == NULL) {
|
||||
const char* ptr = shell->readline ();
|
||||
if (!ptr) {
|
||||
break;
|
||||
}
|
||||
r_str_ncpy (buf, ptr, sizeof (buf) - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user