aboutsummaryrefslogtreecommitdiffstats
path: root/nnn.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-09-06 05:34:10 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2018-09-06 05:34:10 +0530
commitdbd1db72feb5bb569fd49c3c3577ebe5aaa55633 (patch)
treec6fa970f46329d92a459e80cefbacd20470e16b0 /nnn.c
parent18ea909a1228311891cdbb78abdb2612c6532807 (diff)
downloadnnn-dbd1db72feb5bb569fd49c3c3577ebe5aaa55633.tar.gz
Support same dir tmp and nnncp files
Diffstat (limited to 'nnn.c')
-rw-r--r--nnn.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/nnn.c b/nnn.c
index 47a77c1..853b218 100644
--- a/nnn.c
+++ b/nnn.c
@@ -106,13 +106,18 @@ enabledbg()
FILE *fp = fopen("/tmp/nnn_debug", "w");
if (!fp) {
- fprintf(stderr, "Cannot open debug file\n");
- return -1;
+ fprintf(stderr, "debug: open failed! (1)\n");
+
+ fp = fopen("./nnn_debug", "w");
+ if (!fp) {
+ fprintf(stderr, "debug: open failed! (2)\n");
+ return -1;
+ }
}
DEBUG_FD = fileno(fp);
if (DEBUG_FD == -1) {
- fprintf(stderr, "Cannot open debug file descriptor\n");
+ fprintf(stderr, "debug: open fd failed!\n");
return -1;
}
@@ -603,11 +608,21 @@ writecp(const char *buf, const size_t buflen)
{
FILE *fp = fopen(g_cppath, "w");
+ if (!fp) {
+ struct passwd *pass = getpwuid(getuid());
+
+ xstrlcpy(g_cppath, "./nnncp", 11);
+ xstrlcpy(g_cppath + 10, pass->pw_name, 33);
+
+ fp = fopen(g_cppath, "w");
+ if (!fp)
+ printwarn();
+ }
+
if (fp) {
fwrite(buf, 1, buflen, fp);
fclose(fp);
- } else
- printwarn();
+ }
}
static bool