Remove file.path and file.lastpath and add RProject ##projects

This commit is contained in:
pancake 2021-01-02 12:25:28 +01:00 committed by pancake
parent 020c3056d0
commit cf91324937
12 changed files with 163 additions and 94 deletions

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2019 - pancake, nibble */ /* radare - LGPL - Copyright 2009-2020 - pancake, nibble */
#include <r_anal.h> #include <r_anal.h>
#include <r_util.h> #include <r_util.h>

View File

@ -11,7 +11,7 @@ OBJS+=fortune.o hack.o vasm.o patch.o cbin.o corelog.o rtr.o cmd_api.o
OBJS+=carg.o canal.o project.o gdiff.o casm.o disasm.o cplugin.o OBJS+=carg.o canal.o project.o gdiff.o casm.o disasm.o cplugin.o
OBJS+=vmenus.o vmenus_graph.o vmenus_zigns.o zdiff.o citem.o OBJS+=vmenus.o vmenus_graph.o vmenus_zigns.o zdiff.o citem.o
OBJS+=task.o panels.o pseudo.o vmarks.o anal_tp.o anal_objc.o blaze.o cundo.o OBJS+=task.o panels.o pseudo.o vmarks.o anal_tp.o anal_objc.o blaze.o cundo.o
OBJS+=cannotated_code.o OBJS+=cannotated_code.o cproject.o
CFLAGS+=-I../../shlr/heap/include CFLAGS+=-I../../shlr/heap/include
CFLAGS+=-I../../shlr/tree-sitter/lib/include -I../../shlr/radare2-shell-parser/src/tree_parser CFLAGS+=-I../../shlr/tree-sitter/lib/include -I../../shlr/radare2-shell-parser/src/tree_parser

View File

@ -2135,24 +2135,6 @@ static bool cb_io_oxff(void *user, void *data) {
return true; return true;
} }
static bool cb_filepath(void *user, void *data) {
RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data;
char *pikaboo = strstr (node->value, "://");
if (pikaboo) {
if (pikaboo[3] == '/') {
r_config_set (core->config, "file.lastpath", node->value);
char *ovalue = node->value;
node->value = strdup (pikaboo + 3);
free (ovalue);
return true;
}
return false;
}
r_config_set (core->config, "file.lastpath", node->value);
return true;
}
static bool cb_ioautofd(void *user, void *data) { static bool cb_ioautofd(void *user, void *data) {
RCore *core = (RCore *) user; RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data; RConfigNode *node = (RConfigNode *) data;
@ -2553,6 +2535,37 @@ static bool cb_binverbose(void *user, void *data) {
return true; return true;
} }
static bool cb_prjname(void *user, void *data) {
RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data;
const char *prjname = node->value;
if (*prjname == '?') {
r_core_project_list (core, 0);
return false;
}
if (r_project_is_loaded (core->prj)) {
if (*prjname) {
if (!strcmp (prjname, core->prj->name)) {
return false;
}
if (r_project_rename (core->prj, prjname)) {
return true;
}
eprintf ("Cannot rename project.\n");
} else {
r_project_close (core->prj);
}
} else {
if (*prjname) {
if (r_project_open (core->prj, prjname, NULL)) {
return true;
}
eprintf ("Cannot open project.\n");
}
}
return false;
}
static bool cb_rawstr(void *user, void *data) { static bool cb_rawstr(void *user, void *data) {
RCore *core = (RCore *) user; RCore *core = (RCore *) user;
RConfigNode *node = (RConfigNode *) data; RConfigNode *node = (RConfigNode *) data;
@ -3365,7 +3378,7 @@ R_API int r_core_config_init(RCore *core) {
SETCB ("bin.verbose", "false", &cb_binverbose, "Show RBin warnings when loading binaries"); SETCB ("bin.verbose", "false", &cb_binverbose, "Show RBin warnings when loading binaries");
/* prj */ /* prj */
SETPREF ("prj.name", "", "Name of current project"); SETCB ("prj.name", "", &cb_prjname, "Name of current project");
SETBPREF ("prj.files", "false", "Save the target binary inside the project directory"); SETBPREF ("prj.files", "false", "Save the target binary inside the project directory");
{ {
char *p = r_file_path ("git"); char *p = r_file_path ("git");
@ -3860,8 +3873,6 @@ R_API int r_core_config_init(RCore *core) {
/* file */ /* file */
SETBPREF ("file.info", "true", "RBin info loaded"); SETBPREF ("file.info", "true", "RBin info loaded");
SETPREF ("file.offset", "", "Offset where the file will be mapped at"); SETPREF ("file.offset", "", "Offset where the file will be mapped at");
SETCB ("file.path", "", &cb_filepath, "Path of current file");
SETPREF ("file.lastpath", "", "Path of current file");
SETPREF ("file.type", "", "Type of current file"); SETPREF ("file.type", "", "Type of current file");
SETI ("file.loadalign", 1024, "Alignment of load addresses"); SETI ("file.loadalign", 1024, "Alignment of load addresses");
SETI ("file.openmany", 1, "Maximum number of files opened at once"); SETI ("file.openmany", 1, "Maximum number of files opened at once");

View File

@ -925,9 +925,6 @@ R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int flags, ut64 lo
if (cp && *cp) { if (cp && *cp) {
r_core_cmd (r, cp, 0); r_core_cmd (r, cp, 0);
} }
char *absfile = r_file_abspath (file);
r_config_set (r->config, "file.path", absfile);
free (absfile);
} }
// check load addr to make sure its still valid // check load addr to make sure its still valid
r_bin_bind (r->bin, &(fh->binb)); r_bin_bind (r->bin, &(fh->binb));

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2017 - pancake */ /* radare - LGPL - Copyright 2009-2020 - pancake */
#include "r_config.h" #include "r_config.h"
#include "r_core.h" #include "r_core.h"

View File

@ -2599,7 +2599,7 @@ static void __init_autocomplete_default (RCore* core) {
} }
} }
static void __init_autocomplete (RCore* core) { static void __init_autocomplete(RCore* core) {
int i; int i;
core->autocomplete = R_NEW0 (RCoreAutocomplete); core->autocomplete = R_NEW0 (RCoreAutocomplete);
if (core->autocomplete_type == AUTOCOMPLETE_DEFAULT) { if (core->autocomplete_type == AUTOCOMPLETE_DEFAULT) {
@ -2699,7 +2699,7 @@ static RFlagItem *core_flg_fcn_set(RFlag *f, const char *name, ut64 addr, ut32 s
return res; return res;
} }
R_API void r_core_autocomplete_reload (RCore *core) { R_API void r_core_autocomplete_reload(RCore *core) {
r_return_if_fail (core); r_return_if_fail (core);
r_core_autocomplete_free (core->autocomplete); r_core_autocomplete_free (core->autocomplete);
__init_autocomplete (core); __init_autocomplete (core);
@ -2763,6 +2763,7 @@ R_API bool r_core_init(RCore *core) {
core->cmdremote = 0; core->cmdremote = 0;
core->incomment = false; core->incomment = false;
core->config = NULL; core->config = NULL;
core->prj = r_project_new ();
core->http_up = false; core->http_up = false;
core->use_tree_sitter_r2cmd = false; core->use_tree_sitter_r2cmd = false;
ZERO_FILL (core->root_cmd_descriptor); ZERO_FILL (core->root_cmd_descriptor);
@ -3008,6 +3009,7 @@ R_API void r_core_fini(RCore *c) {
free (c->cmdqueue); free (c->cmdqueue);
free (c->lastcmd); free (c->lastcmd);
free (c->stkcmd); free (c->stkcmd);
r_project_free (c->prj);
r_list_free (c->visual.tabs); r_list_free (c->visual.tabs);
free (c->block); free (c->block);
r_core_autocomplete_free (c->autocomplete); r_core_autocomplete_free (c->autocomplete);

58
libr/core/cproject.c Normal file
View File

@ -0,0 +1,58 @@
/* radare - LGPL - Copyright 2020 - pancake */
// project class definition to be used by project.c
#include <r_core.h>
R_API RProject *r_project_new(void) {
RProject *p = R_NEW0 (RProject);
return p;
}
R_API bool r_project_rename(RProject *p, const char *newname) {
// check if the newname is available
// move directory
// update path and file fields in p
return false;
}
R_API bool r_project_is_git(RProject *p) {
char *f = r_str_newf ("%s"R_SYS_DIR".git", p->path);
bool ig = r_file_is_directory (f);
free (f);
return ig;
}
R_API void r_project_close(RProject *p) {
// close the current project
R_FREE (p->name);
R_FREE (p->path);
}
R_API bool r_project_open(RProject *p, const char *name, const char *path) {
r_return_val_if_fail (p && !R_STR_ISEMPTY (name), false);
if (r_project_is_loaded (p)) {
return false;
}
p->name = strdup (name);
if (path) {
p->path = strdup (path);
}
return true;
}
R_API void r_project_save(RProject *p) {
// must call r_core_project_save()
}
R_API void r_project_free(RProject *p) {
if (p) {
free (p->name);
free (p->path);
free (p);
}
}
R_API bool r_project_is_loaded(RProject *p) {
return !R_STR_ISEMPTY (p->name);
}

View File

@ -2,6 +2,7 @@ r_core_sources = [
'anal_tp.c', 'anal_tp.c',
'anal_objc.c', 'anal_objc.c',
'casm.c', 'casm.c',
'cproject.c',
'blaze.c', 'blaze.c',
'citem.c', 'citem.c',
'canal.c', 'canal.c',

View File

@ -7,6 +7,8 @@
#define USE_R2 1 #define USE_R2 1
#include <spp/spp.h> #include <spp/spp.h>
// project apis to be used from cmd_project.c
static bool is_valid_project_name(const char *name) { static bool is_valid_project_name(const char *name) {
int i; int i;
if (r_str_endswith (name, ".zip")) { if (r_str_endswith (name, ".zip")) {
@ -33,6 +35,7 @@ static bool is_valid_project_name(const char *name) {
} }
static char *get_project_script_path(RCore *core, const char *file) { static char *get_project_script_path(RCore *core, const char *file) {
r_return_val_if_fail (core && !R_STR_ISEMPTY (file), NULL);
const char *magic = "# r2 rdb project file"; const char *magic = "# r2 rdb project file";
char *data, *prjfile; char *data, *prjfile;
if (r_file_is_abspath (file)) { if (r_file_is_abspath (file)) {
@ -45,7 +48,7 @@ static char *get_project_script_path(RCore *core, const char *file) {
prjfile = r_str_append (prjfile, R_SYS_DIR); prjfile = r_str_append (prjfile, R_SYS_DIR);
prjfile = r_str_append (prjfile, file); prjfile = r_str_append (prjfile, file);
if (!r_file_exists (prjfile) || r_file_is_directory (prjfile)) { if (!r_file_exists (prjfile) || r_file_is_directory (prjfile)) {
prjfile = r_str_append (prjfile, R_SYS_DIR "rc"); prjfile = r_str_append (prjfile, R_SYS_DIR "rc.r2");
} }
} }
data = r_file_slurp (prjfile, NULL); data = r_file_slurp (prjfile, NULL);
@ -75,7 +78,7 @@ R_API bool r_core_is_project(RCore *core, const char *name) {
if (!path) { if (!path) {
return false; return false;
} }
if (r_str_endswith (path, R_SYS_DIR "rc") && r_file_exists (path)) { if (r_str_endswith (path, R_SYS_DIR "rc.r2") && r_file_exists (path)) {
ret = true; ret = true;
} else { } else {
path = r_str_append (path, ".d"); path = r_str_append (path, ".d");
@ -142,45 +145,44 @@ R_API int r_core_project_list(RCore *core, int mode) {
} }
static inline void remove_project_file(char * path) { static inline void remove_project_file(char * path) {
if (r_file_exists (path)) { if (r_file_exists (path)) {
r_file_rm (path); r_file_rm (path);
eprintf ("rm %s\n", path); eprintf ("rm %s\n", path);
} }
} }
static inline void remove_notes_file(const char *pd) { static inline void remove_notes_file(const char *pd) {
char *notes_txt = r_str_newf ("%s%s%s", pd, R_SYS_DIR, "notes.txt"); char *notes_txt = r_file_new (pd, "notes.txt", NULL);
if (r_file_exists (notes_txt)) { if (r_file_exists (notes_txt)) {
r_file_rm (notes_txt); r_file_rm (notes_txt);
eprintf ("rm %s\n", notes_txt); eprintf ("rm %s\n", notes_txt);
} }
free(notes_txt); free (notes_txt);
} }
static inline void remove_rop_directory(const char *prj_dir) { static inline void remove_rop_directory(const char *prj_dir) {
char *rop_d = r_str_newf ("%s%s%s", prj_dir, R_SYS_DIR, "rop.d"); char *rop_d = r_file_new (prj_dir, "rop.d", NULL);
if (r_file_is_directory (rop_d)) { if (r_file_is_directory (rop_d)) {
char *f; char *f;
RListIter *iter; RListIter *iter;
RList *files = r_sys_dir (rop_d); RList *files = r_sys_dir (rop_d);
r_list_foreach (files, iter, f) { r_list_foreach (files, iter, f) {
char *filepath = r_str_append (strdup (rop_d), R_SYS_DIR); char *filepath = r_str_append (strdup (rop_d), R_SYS_DIR);
filepath = r_str_append (filepath, f); filepath = r_str_append (filepath, f);
if (!r_file_is_directory (filepath)) { if (!r_file_is_directory (filepath)) {
eprintf ("rm %s\n", filepath); eprintf ("rm %s\n", filepath);
r_file_rm (filepath); r_file_rm (filepath);
}
free (filepath);
} }
r_file_rm (rop_d); free (filepath);
eprintf ("rm %s\n", rop_d);
r_list_free (files);
} }
r_file_rm (rop_d);
eprintf ("rm %s\n", rop_d);
r_list_free (files);
}
free (rop_d); free (rop_d);
} }
R_API int r_core_project_delete(RCore *core, const char *prjfile) { R_API int r_core_project_delete(RCore *core, const char *prjfile) {
if (r_sandbox_enable (0)) { if (r_sandbox_enable (0)) {
@ -211,15 +213,12 @@ R_API int r_core_project_delete(RCore *core, const char *prjfile) {
} }
static bool load_project_rop(RCore *core, const char *prjfile) { static bool load_project_rop(RCore *core, const char *prjfile) {
r_return_val_if_fail (core && !R_STR_ISEMPTY (prjfile), false);
char *path, *db = NULL, *path_ns; char *path, *db = NULL, *path_ns;
bool found = 0; bool found = 0;
SdbListIter *it; SdbListIter *it;
SdbNs *ns; SdbNs *ns;
if (!prjfile || !*prjfile) {
return false;
}
Sdb *rop_db = sdb_ns (core->sdb, "rop", false); Sdb *rop_db = sdb_ns (core->sdb, "rop", false);
Sdb *nop_db = sdb_ns (rop_db, "nop", false); Sdb *nop_db = sdb_ns (rop_db, "nop", false);
Sdb *mov_db = sdb_ns (rop_db, "mov", false); Sdb *mov_db = sdb_ns (rop_db, "mov", false);
@ -230,12 +229,12 @@ static bool load_project_rop(RCore *core, const char *prjfile) {
char *rc_path = get_project_script_path (core, prjfile); char *rc_path = get_project_script_path (core, prjfile);
char *prj_dir = r_file_dirname (rc_path); char *prj_dir = r_file_dirname (rc_path);
if (r_str_endswith (prjfile, R_SYS_DIR "rc")) { if (r_str_endswith (prjfile, R_SYS_DIR "rc.r2")) {
// XXX // XXX
eprintf ("ENDS WITH\n"); eprintf ("ENDS WITH\n");
path = strdup (prjfile); path = strdup (prjfile);
path[strlen (path) - 3] = 0; path[strlen (path) - 3] = 0;
} else if (r_file_fexists ("%s%s%src", R_SYS_DIR, prj_dir, prjfile)) { } else if (r_file_fexists ("%s%s%src.r2", R_SYS_DIR, prj_dir, prjfile)) {
path = r_str_newf ("%s%s%s", R_SYS_DIR, prj_dir, prjfile); path = r_str_newf ("%s%s%s", R_SYS_DIR, prj_dir, prjfile);
} else { } else {
if (*prjfile == R_SYS_DIR[0]) { if (*prjfile == R_SYS_DIR[0]) {
@ -371,14 +370,12 @@ R_API RThread *r_core_project_load_bg(RCore *core, const char *prj_name, const c
return th; return th;
} }
/*** ^^^ thready ***/
static ut64 get_project_laddr(RCore *core, const char *prjfile) { static ut64 get_project_laddr(RCore *core, const char *prjfile) {
ut64 laddr = 0; ut64 laddr = 0;
char *buf = r_file_slurp (prjfile, NULL); char *buf = r_file_slurp (prjfile, NULL);
char *pos; char *pos;
if (buf) { if (buf) {
if ((pos = strstr(buf, "\"e bin.laddr = "))) { if ((pos = strstr (buf, "\"e bin.laddr = "))) {
laddr = r_num_math (NULL, pos + 15); laddr = r_num_math (NULL, pos + 15);
} }
free (buf); free (buf);
@ -507,19 +504,8 @@ R_API char *r_core_project_info(RCore *core, const char *prjfile) {
if (feof (fd)) { if (feof (fd)) {
break; break;
} }
if (!strncmp (buf, "\"e file.path = ", 15)) { if (!strncmp (buf, "\"e prj.name = ", 14)) {
buf[strlen (buf) - 2] = 0; buf[strlen (buf) - 2] = 0;
file = r_str_new (buf + 15);
break;
}
if (!strncmp (buf, "\"e file.lastpath = ", 19)) {
buf[strlen (buf) - 2] = 0;
file = r_str_new (buf + 19);
break;
}
// TODO: deprecate before 1.0
if (!strncmp (buf, "e file.path = ", 14)) {
buf[strlen (buf) - 1] = 0;
file = r_str_new (buf + 14); file = r_str_new (buf + 14);
break; break;
} }
@ -619,7 +605,6 @@ static bool simple_project_save_script(RCore *core, const char *file, int opts)
r_cons_flush (); r_cons_flush ();
} }
r_cons_singleton ()->fdout = fdold; r_cons_singleton ()->fdout = fdold;
r_cons_singleton ()->context->is_interactive = true; r_cons_singleton ()->context->is_interactive = true;
@ -671,10 +656,7 @@ static bool project_save_script(RCore *core, const char *file, int opts) {
} }
} }
} }
// Set file.path and file.lastpath to empty string to signal
// new behaviour to project load routine (see io maps below). // new behaviour to project load routine (see io maps below).
r_config_set (core->config, "file.path", "");
r_config_set (core->config, "file.lastpath", "");
if (opts & R_CORE_PRJ_EVAL) { if (opts & R_CORE_PRJ_EVAL) {
r_str_write (fd, "# eval\n"); r_str_write (fd, "# eval\n");
r_config_list (core->config, NULL, true); r_config_list (core->config, NULL, true);

View File

@ -238,9 +238,24 @@ typedef struct r_core_tasks_t {
bool oneshot_running; bool oneshot_running;
} RCoreTaskScheduler; } RCoreTaskScheduler;
typedef struct r_core_project_t {
char *name;
char *path;
} RProject;
R_API RProject *r_project_new(void);
R_API bool r_project_rename(RProject *p, const char *newname);
R_API bool r_project_is_git(RProject *p);
R_API void r_project_close(RProject *p);
R_API bool r_project_open(RProject *p, const char *prjname, const char *path);
R_API void r_project_save(RProject *p);
R_API void r_project_free(RProject *p);
R_API bool r_project_is_loaded(RProject *p);
struct r_core_t { struct r_core_t {
RBin *bin; RBin *bin;
RConfig *config; RConfig *config;
RProject *prj;
ut64 offset; // current seek ut64 offset; // current seek
ut64 prompt_offset; // temporarily set to offset to have $$ in expressions always stay the same during temp seeks ut64 prompt_offset; // temporarily set to offset to have $$ in expressions always stay the same during temp seeks
ut32 blocksize; ut32 blocksize;
@ -530,8 +545,10 @@ R_API void r_core_fortune_list(RCore *core);
R_API void r_core_fortune_print_random(RCore *core); R_API void r_core_fortune_print_random(RCore *core);
/* project */ /* project */
#if 0
R_API bool r_core_project_load(RCore *core, const char *prjfile, const char *rcfile); R_API bool r_core_project_load(RCore *core, const char *prjfile, const char *rcfile);
R_API RThread *r_core_project_load_bg(RCore *core, const char *prjfile, const char *rcfile); R_API RThread *r_core_project_load_bg(RCore *core, const char *prjfile, const char *rcfile);
#endif
R_API void r_core_project_execute_cmds(RCore *core, const char *prjfile); R_API void r_core_project_execute_cmds(RCore *core, const char *prjfile);
#define R_CORE_FOREIGN_ADDR -1 #define R_CORE_FOREIGN_ADDR -1
@ -681,13 +698,13 @@ R_API int r_core_zdiff(RCore *c, RCore *c2);
R_API int r_core_gdiff(RCore *core1, RCore *core2); R_API int r_core_gdiff(RCore *core1, RCore *core2);
R_API int r_core_gdiff_fcn(RCore *c, ut64 addr, ut64 addr2); R_API int r_core_gdiff_fcn(RCore *c, ut64 addr, ut64 addr2);
R_API bool r_core_project_open(RCore *core, const char *file, bool thready); R_API bool r_core_project_open(RCore *core, const char *file);
R_API int r_core_project_cat(RCore *core, const char *name); R_API int r_core_project_cat(RCore *core, const char *name);
R_API int r_core_project_delete(RCore *core, const char *prjfile); R_API int r_core_project_delete(RCore *core, const char *prjfile);
R_API int r_core_project_list(RCore *core, int mode); R_API int r_core_project_list(RCore *core, int mode);
R_API bool r_core_project_save_script(RCore *core, const char *file, int opts); R_API bool r_core_project_save_script(RCore *core, const char *file, int opts);
R_API bool r_core_project_save(RCore *core, const char *file); R_API bool 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_project_name(RCore *core, const char *file);
R_API char *r_core_project_notes_file (RCore *core, const char *file); R_API char *r_core_project_notes_file (RCore *core, const char *file);
R_API char *r_core_sysenv_begin(RCore *core, const char *cmd); R_API char *r_core_sysenv_begin(RCore *core, const char *cmd);

View File

@ -1148,7 +1148,7 @@ R_API int r_main_radare2(int argc, const char **argv) {
} else { } else {
const char *prj = r_config_get (r->config, "prj.name"); const char *prj = r_config_get (r->config, "prj.name");
if (prj && *prj) { if (prj && *prj) {
pfile = r_core_project_info (r, prj); pfile = r_core_project_name (r, prj);
if (pfile) { if (pfile) {
if (!fh) { if (!fh) {
fh = r_core_file_open (r, pfile, perms, mapaddr); fh = r_core_file_open (r, pfile, perms, mapaddr);
@ -1303,12 +1303,12 @@ R_API int r_main_radare2(int argc, const char **argv) {
} }
r_core_seek (r, r->offset, true); // read current block r_core_seek (r, r->offset, true); // read current block
#if 0
/* check if file.path has changed */ /* check if file.path has changed */
if (iod && !strstr (iod->uri, "://")) { if (iod && !strstr (iod->uri, "://")) {
const char *npath; const char *npath;
char *path = strdup (r_config_get (r->config, "file.path")); char *path = strdup (r_config_get (r->config, "file.path"));
has_project = r_core_project_open (r, r_config_get (r->config, "prj.name"), false); has_project = r_core_project_open (r, r_config_get (r->config, "prj.name"));
iod = r->io ? r_io_desc_get (r->io, fh->fd) : NULL; iod = r->io ? r_io_desc_get (r->io, fh->fd) : NULL;
if (has_project) { if (has_project) {
r_config_set (r->config, "bin.strings", "false"); r_config_set (r->config, "bin.strings", "false");
@ -1319,6 +1319,7 @@ R_API int r_main_radare2(int argc, const char **argv) {
} }
free (path); free (path);
} }
#endif
r_list_foreach (evals, iter, cmdn) { r_list_foreach (evals, iter, cmdn) {
r_config_eval (r->config, cmdn, false); r_config_eval (r->config, cmdn, false);

View File

@ -27,7 +27,7 @@
#define BS 1024 #define BS 1024
static int file_stat (const char *file, struct stat* const pStat) { static int file_stat(const char *file, struct stat* const pStat) {
r_return_val_if_fail (file && pStat, -1); r_return_val_if_fail (file && pStat, -1);
#if __WINDOWS__ #if __WINDOWS__
wchar_t *wfile = r_utf8_to_utf16 (file); wchar_t *wfile = r_utf8_to_utf16 (file);
@ -1046,7 +1046,7 @@ R_API void r_file_mmap_free(RMmap *m) {
free (m); free (m);
} }
R_API char *r_file_temp (const char *prefix) { R_API char *r_file_temp(const char *prefix) {
if (!prefix) { if (!prefix) {
prefix = ""; prefix = "";
} }
@ -1181,7 +1181,7 @@ R_API char *r_file_tmpdir(void) {
return path; return path;
} }
R_API bool r_file_copy (const char *src, const char *dst) { R_API bool r_file_copy(const char *src, const char *dst) {
/* TODO: implement in C */ /* TODO: implement in C */
/* TODO: Use NO_CACHE for iOS dyldcache copying */ /* TODO: Use NO_CACHE for iOS dyldcache copying */
#if HAVE_COPYFILE_H #if HAVE_COPYFILE_H
@ -1212,7 +1212,7 @@ R_API bool r_file_copy (const char *src, const char *dst) {
#endif #endif
} }
static void recursive_search_glob (const char *path, const char *glob, RList* list, int depth) { static void recursive_search_glob(const char *path, const char *glob, RList* list, int depth) {
if (depth < 1) { if (depth < 1) {
return; return;
} }
@ -1239,7 +1239,7 @@ static void recursive_search_glob (const char *path, const char *glob, RList* li
r_list_free (dir); r_list_free (dir);
} }
R_API RList* r_file_globsearch (const char *_globbed_path, int maxdepth) { R_API RList* r_file_globsearch(const char *_globbed_path, int maxdepth) {
char *globbed_path = strdup (_globbed_path); char *globbed_path = strdup (_globbed_path);
RList *files = r_list_newf (free); RList *files = r_list_newf (free);
char *glob = strchr (globbed_path, '*'); char *glob = strchr (globbed_path, '*');