mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-23 14:28:07 +00:00
Fixes for the R2_FORTUENS system and home paths ##shell
This commit is contained in:
parent
3c4a17a558
commit
740c5fef9f
@ -4,19 +4,19 @@
|
||||
#include <r_util.h>
|
||||
|
||||
static char *getFortuneFile(RCore *core, const char *type) {
|
||||
char *home = r_sys_getenv (R_SYS_HOME);
|
||||
if (!home) {
|
||||
return NULL;
|
||||
}
|
||||
char *path = r_str_newf (R_JOIN_3_PATHS ("%s", R2_HOME_FORTUNES, "fortunes.%s"),
|
||||
home, type);
|
||||
free (home);
|
||||
char *ft = r_str_newf (".cache/radare2/fortunes.%s", type);
|
||||
char *path = r_str_home (ft);
|
||||
free (ft);
|
||||
if (path && r_file_exists (path)) {
|
||||
return path;
|
||||
}
|
||||
free (path);
|
||||
return r_str_newf (R_JOIN_3_PATHS ("%s", R2_FORTUNES, "fortunes.%s"),
|
||||
path = r_str_newf (R_JOIN_3_PATHS ("%s", R2_FORTUNES, "fortunes.%s"),
|
||||
r_sys_prefix (NULL), type);
|
||||
if (path && r_file_exists (path)) {
|
||||
return path;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool _push_types(RList *type_list, char *fortune_dir) {
|
||||
@ -105,12 +105,14 @@ static char *getrandomline(RCore *core) {
|
||||
if (strstr (types, fortunes)) {
|
||||
int lines = 0;
|
||||
char *file = getFortuneFile (core, fortunes);
|
||||
templine = r_file_slurp_random_line_count (file, &lines);
|
||||
if (templine && *templine) {
|
||||
free (line);
|
||||
line = templine;
|
||||
if (file) {
|
||||
templine = r_file_slurp_random_line_count (file, &lines);
|
||||
if (templine && *templine) {
|
||||
free (line);
|
||||
line = templine;
|
||||
}
|
||||
free (file);
|
||||
}
|
||||
free (file);
|
||||
}
|
||||
}
|
||||
r_list_free (ftypes);
|
||||
|
@ -35,7 +35,7 @@
|
||||
#define R2_SDB "@SDB@"
|
||||
#define R2_ZIGNS "@ZIGNS@"
|
||||
#define R2_THEMES "@THEMES@"
|
||||
#define R2_FORTUNES "@FORTUNES@"
|
||||
#define R2_FORTUNES R_JOIN_3_PATHS ("@DATADIR@", "doc", "radare2")
|
||||
#define R2_FLAGS "@FLAGS@"
|
||||
#define R2_HUD "@HUD@"
|
||||
#else
|
||||
|
@ -214,7 +214,8 @@ R_API char *r_str_utf16_encode(const char *s, int len);
|
||||
R_API char *r_str_escape_utf8_for_json(const char *s, int len);
|
||||
R_API char *r_str_escape_utf8_for_json_strip(const char *buf, int buf_size);
|
||||
R_API char *r_str_encoded_json(const char *buf, int buf_size, int encoding);
|
||||
R_API char *r_str_home(const char *str);
|
||||
R_API char *r_str_home(const char *str); // R2_580 : rename to r_file_home() ?
|
||||
// R2_580: implement r_file_homef() for format string purposes
|
||||
R_API char *r_str_r2_prefix(const char *str);
|
||||
R_API size_t r_str_nlen(const char *s, int n);
|
||||
R_API size_t r_str_nlen_w(const char *s, int n);
|
||||
|
@ -42,7 +42,7 @@ static int file_stat(const char *file, struct stat* const pStat) {
|
||||
if (!wfile) {
|
||||
return -1;
|
||||
}
|
||||
int ret = _wstat (wfile, pStat);
|
||||
int ret = _wstat (wfile, (struct _stat64i32 *)pStat);
|
||||
free (wfile);
|
||||
return ret;
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user