mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 13:51:31 +00:00
Move help and stats tmp files to home
This commit is contained in:
parent
d0b59e8c15
commit
d6e824352d
50
nnn.c
50
nnn.c
|
@ -175,6 +175,7 @@ disabledbg()
|
||||||
#define _ALIGNMENT 0x10
|
#define _ALIGNMENT 0x10
|
||||||
#define _ALIGNMENT_MASK 0xF
|
#define _ALIGNMENT_MASK 0xF
|
||||||
#define SYMLINK_TO_DIR 0x1
|
#define SYMLINK_TO_DIR 0x1
|
||||||
|
#define MAX_HOME_LEN 64
|
||||||
|
|
||||||
/* Macros to define process spawn behaviour as flags */
|
/* Macros to define process spawn behaviour as flags */
|
||||||
#define F_NONE 0x00 /* no flag set */
|
#define F_NONE 0x00 /* no flag set */
|
||||||
|
@ -339,7 +340,11 @@ static const char messages[][16] = {
|
||||||
static char g_buf[MAX_CMD_LEN] __attribute__ ((aligned));
|
static char g_buf[MAX_CMD_LEN] __attribute__ ((aligned));
|
||||||
|
|
||||||
/* Buffer for file path copy file */
|
/* Buffer for file path copy file */
|
||||||
static char g_cppath[48] __attribute__ ((aligned));
|
static char g_cppath[MAX_HOME_LEN] __attribute__ ((aligned));
|
||||||
|
|
||||||
|
/* Buffer to store HOME path, for help and file details */
|
||||||
|
static char g_homepath[MAX_HOME_LEN] __attribute__ ((aligned));
|
||||||
|
static size_t g_homelen;
|
||||||
|
|
||||||
/* Forward declarations */
|
/* Forward declarations */
|
||||||
static void redraw(char *path);
|
static void redraw(char *path);
|
||||||
|
@ -1769,8 +1774,15 @@ show_stats(char *fpath, char *fname, struct stat *sb)
|
||||||
char desc[DESCRIPTOR_LEN];
|
char desc[DESCRIPTOR_LEN];
|
||||||
char *perms = get_lsperms(sb->st_mode, desc);
|
char *perms = get_lsperms(sb->st_mode, desc);
|
||||||
char *p, *begin = g_buf;
|
char *p, *begin = g_buf;
|
||||||
char tmp[] = "/tmp/nnnXXXXXX";
|
|
||||||
int fd = mkstemp(tmp);
|
if (g_homepath[0])
|
||||||
|
xstrlcpy(g_homepath + g_homelen - 1, "/.nnnXXXXXX", MAX_HOME_LEN - g_homelen);
|
||||||
|
else {
|
||||||
|
printmsg(messages[STR_NOHOME_ID]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fd = mkstemp(g_homepath);
|
||||||
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1861,8 +1873,8 @@ show_stats(char *fpath, char *fname, struct stat *sb)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
exitcurses();
|
exitcurses();
|
||||||
get_output(NULL, 0, "cat", tmp, NULL, 1);
|
get_output(NULL, 0, "cat", g_homepath, NULL, 1);
|
||||||
unlink(tmp);
|
unlink(g_homepath);
|
||||||
refresh();
|
refresh();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1921,8 +1933,14 @@ handle_archive(char *fpath, char *arg, char *dir)
|
||||||
static int
|
static int
|
||||||
show_help(char *path)
|
show_help(char *path)
|
||||||
{
|
{
|
||||||
char tmp[] = "/tmp/nnnXXXXXX";
|
if (g_homepath[0])
|
||||||
int i = 0, fd = mkstemp(tmp);
|
xstrlcpy(g_homepath + g_homelen - 1, "/.nnnXXXXXX", MAX_HOME_LEN - g_homelen);
|
||||||
|
else {
|
||||||
|
printmsg(messages[STR_NOHOME_ID]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0, fd = mkstemp(g_homepath);
|
||||||
char *start, *end;
|
char *start, *end;
|
||||||
static char helpstr[] = {
|
static char helpstr[] = {
|
||||||
"cKey | Function\n"
|
"cKey | Function\n"
|
||||||
|
@ -2041,8 +2059,8 @@ show_help(char *path)
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
exitcurses();
|
exitcurses();
|
||||||
get_output(NULL, 0, "cat", tmp, NULL, 1);
|
get_output(NULL, 0, "cat", g_homepath, NULL, 1);
|
||||||
unlink(tmp);
|
unlink(g_homepath);
|
||||||
refresh();
|
refresh();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3461,11 +3479,15 @@ main(int argc, char *argv[])
|
||||||
if (getenv("NNN_QUOTE_ON"))
|
if (getenv("NNN_QUOTE_ON"))
|
||||||
cfg.quote = 1;
|
cfg.quote = 1;
|
||||||
|
|
||||||
/* Check if X11 is available */
|
if (getenv("HOME")) {
|
||||||
if (getenv("NNN_NO_X") && getenv("HOME")) {
|
g_homelen = xstrlcpy(g_homepath, getenv("HOME"), MAX_HOME_LEN);
|
||||||
cfg.noxdisplay = 1;
|
|
||||||
size_t len = xstrlcpy(g_cppath, getenv("HOME"), 48);
|
/* Check if X11 is available */
|
||||||
xstrlcpy(g_cppath + len - 1, "/.nnncp", 48 - len);
|
if (getenv("NNN_NO_X")) {
|
||||||
|
cfg.noxdisplay = 1;
|
||||||
|
xstrlcpy(g_cppath, g_homepath, MAX_HOME_LEN);
|
||||||
|
xstrlcpy(g_cppath + g_homelen - 1, "/.nnncp", MAX_HOME_LEN - g_homelen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signal(SIGINT, SIG_IGN);
|
signal(SIGINT, SIG_IGN);
|
||||||
|
|
Loading…
Reference in a new issue