mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-04 04:28:20 +00:00
Implement Pl and Plj commands to list project files
This commit is contained in:
parent
5e82babac8
commit
c8a5b8049c
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2013 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2015 - pancake */
|
||||
|
||||
static int cmd_project(void *data, const char *input) {
|
||||
RCore *core = (RCore *)data;
|
||||
@ -11,6 +11,9 @@ static int cmd_project(void *data, const char *input) {
|
||||
// if (r_file_is_regular (file))
|
||||
r_core_project_open (core, file);
|
||||
break;
|
||||
case 'l':
|
||||
r_core_project_list (core, input[1]);
|
||||
break;
|
||||
case 's':
|
||||
r_core_project_save (core, file);
|
||||
r_config_set (core->config, "file.project", file);
|
||||
@ -25,6 +28,7 @@ static int cmd_project(void *data, const char *input) {
|
||||
"Po", " [file]", "open project",
|
||||
"Ps", " [file]", "save project",
|
||||
"Pi", " [file]", "show project information",
|
||||
"Pl", "", "list all projects",
|
||||
"NOTE:", "", "See 'e file.project'",
|
||||
"NOTE:", "", "project files are stored in ~/.config/radare2/projects",
|
||||
NULL};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2010-2014 - pancake */
|
||||
/* radare - LGPL - Copyright 2010-2015 - pancake */
|
||||
|
||||
#include <r_types.h>
|
||||
#include <r_list.h>
|
||||
@ -24,6 +24,51 @@ static int r_core_project_init(RCore *core) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int r_core_is_project(RCore *core, const char *name) {
|
||||
int ret = 0;
|
||||
if (name && *name && *name!='.') {
|
||||
char *path = r_core_project_file (core, name);
|
||||
path = r_str_concat (path, ".d");
|
||||
if (r_file_is_directory (path))
|
||||
ret = 1;
|
||||
free (path);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
R_API int r_core_project_list(RCore *core, int mode) {
|
||||
RListIter *iter;
|
||||
RList *list;
|
||||
int isfirst = 1;
|
||||
char *foo, *path = r_file_abspath (r_config_get (core->config, "dir.projects"));
|
||||
if (!path)
|
||||
return 0;
|
||||
list = r_sys_dir (path);
|
||||
switch (mode) {
|
||||
case 'j':
|
||||
r_cons_printf ("[");
|
||||
r_list_foreach (list, iter, foo) {
|
||||
// todo. escape string
|
||||
if (r_core_is_project (core, foo)) {
|
||||
r_cons_printf ("%s\"%s\"",
|
||||
isfirst?"":",", foo);
|
||||
isfirst = 0;
|
||||
}
|
||||
}
|
||||
r_cons_printf ("]\n");
|
||||
break;
|
||||
default:
|
||||
r_list_foreach (list, iter, foo) {
|
||||
if (r_core_is_project (core, foo))
|
||||
r_cons_printf ("%s\n", foo);
|
||||
}
|
||||
break;
|
||||
}
|
||||
r_list_free (list);
|
||||
free (path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API int r_core_project_open(RCore *core, const char *prjfile) {
|
||||
int ret;
|
||||
char *prj;
|
||||
|
@ -349,6 +349,7 @@ R_API int r_core_gdiff(RCore *core1, RCore *core2, int anal_all);
|
||||
R_API int r_core_gdiff_fcn(RCore *c, ut64 addr, ut64 addr2);
|
||||
|
||||
R_API int r_core_project_open(RCore *core, const char *file);
|
||||
R_API int r_core_project_list(RCore *core, int mode);
|
||||
R_API int r_core_project_save(RCore *core, const char *file);
|
||||
R_API char *r_core_project_info(RCore *core, const char *file);
|
||||
R_API char *r_core_sysenv_begin(RCore *core, const char *cmd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user