dir.projects becomes abspath when set ##projects

This commit is contained in:
pancake 2021-01-03 03:05:48 +01:00 committed by pancake
parent d7a4aedf5a
commit 7a849f26ef
4 changed files with 21 additions and 8 deletions

View File

@ -1296,10 +1296,25 @@ static bool cb_dirhome(void *user, void *data) {
return true;
}
static bool cb_dir_projects(void *user, void *data) {
RConfigNode *node = (RConfigNode *)data;
char *value = R_STR_ISNOTEMPTY (node->value)? node->value: NULL;
if (value) {
char *newva = r_file_abspath (value);
free (node->value);
node->value = newva;
}
return true;
}
static bool cb_dirtmp(void *user, void *data) {
RConfigNode *node = (RConfigNode *)data;
char *value = R_STR_ISNOTEMPTY (node->value)? node->value: NULL;
r_sys_setenv (R_SYS_TMP, value);
if (value) {
char *newva = r_file_abspath (value);
free (node->value);
node->value = newva;
}
return true;
}
@ -3492,9 +3507,9 @@ R_API int r_core_config_init(RCore *core) {
SETCB ("dir.tmp", r_str_get (p), &cb_dirtmp, "Path of the tmp directory");
free (p);
#if __ANDROID__
SETPREF ("dir.projects", "/data/data/org.radare.radare2installer/radare2/projects", "Default path for projects");
SETCB ("dir.projects", "/data/data/org.radare.radare2installer/radare2/projects", &cb_dir_projects, "Default path for projects");
#else
SETPREF ("dir.projects", R_JOIN_2_PATHS ("~", R2_HOME_PROJECTS), "Default path for projects");
SETCB ("dir.projects", R_JOIN_2_PATHS ("~", R2_HOME_PROJECTS), &cb_dir_projects, "Default path for projects");
#endif
SETCB ("dir.zigns", R_JOIN_2_PATHS ("~", R2_HOME_ZIGNS), &cb_dirzigns, "Default path for zignatures (see zo command)");
SETPREF ("stack.reg", "SP", "Which register to use as stack pointer in the visual debug");

View File

@ -7210,9 +7210,9 @@ R_API int r_core_cmd_lines(RCore *core, const char *lines) {
}
*nl = '\0';
r = r_core_cmd (core, data, 0);
if (r < 0) { //== -1) {
if (r < 0) {
data = nl + 1;
ret = -1; //r; //false;
ret = -1;
break;
}
r_cons_flush ();

View File

@ -63,7 +63,7 @@ static int cmd_project(void *data, const char *input) {
}
file = arg;
switch (input[0]) {
case 'c':
case 'c': // "Pc"
if (input[1] == ' ') {
r_core_project_cat (core, input + 2);
} else {

View File

@ -401,7 +401,6 @@ R_API bool r_core_project_open(RCore *core, const char *prj_path) {
eprintf ("There's a project already opened\n");
bool ccs = r_cons_yesno ('y', "Close current session? (Y/n)");
if (ccs) {
// r_core_cmd0 (core, "e prj.name=;o--");
r_core_cmd0 (core, "o--");
} else {
eprintf ("Project not loaded.\n");
@ -847,4 +846,3 @@ R_API char *r_core_project_notes_file(RCore *core, const char *prj_name) {
free (prjpath);
return notes_txt;
}