mirror of
https://github.com/jarun/nnn.git
synced 2025-01-10 01:49:38 +00:00
Add timeout to warnings
This commit is contained in:
parent
2d65a30485
commit
810cf2e403
39
src/nnn.c
39
src/nnn.c
|
@ -449,7 +449,7 @@ static struct timespec gtimeout;
|
||||||
/* Function macros */
|
/* Function macros */
|
||||||
#define exitcurses() endwin()
|
#define exitcurses() endwin()
|
||||||
#define clearprompt() printmsg("")
|
#define clearprompt() printmsg("")
|
||||||
#define printwarn() printmsg(strerror(errno))
|
#define printwarn(presel) printwait(strerror(errno), presel)
|
||||||
#define istopdir(path) ((path)[1] == '\0' && (path)[0] == '/')
|
#define istopdir(path) ((path)[1] == '\0' && (path)[0] == '/')
|
||||||
#define copycurname() xstrlcpy(lastname, dents[cur].name, NAME_MAX + 1)
|
#define copycurname() xstrlcpy(lastname, dents[cur].name, NAME_MAX + 1)
|
||||||
#define settimeout() timeout(1000)
|
#define settimeout() timeout(1000)
|
||||||
|
@ -550,7 +550,8 @@ static inline void printmsg(const char *msg)
|
||||||
static void printwait(const char *msg, int *presel)
|
static void printwait(const char *msg, int *presel)
|
||||||
{
|
{
|
||||||
printmsg(msg);
|
printmsg(msg);
|
||||||
*presel = MSGWAIT;
|
if (presel)
|
||||||
|
*presel = MSGWAIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Kill curses and display error before exiting */
|
/* Kill curses and display error before exiting */
|
||||||
|
@ -740,7 +741,7 @@ static void writecp(const char *buf, const size_t buflen)
|
||||||
fwrite(buf, 1, buflen, fp);
|
fwrite(buf, 1, buflen, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
} else
|
} else
|
||||||
printwarn();
|
printwarn(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void appendfpath(const char *path, const size_t len)
|
static void appendfpath(const char *path, const size_t len)
|
||||||
|
@ -1052,7 +1053,7 @@ static bool xdiraccess(const char *path)
|
||||||
DIR *dirp = opendir(path);
|
DIR *dirp = opendir(path);
|
||||||
|
|
||||||
if (!dirp) {
|
if (!dirp) {
|
||||||
printwarn();
|
printwarn(NULL);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2370,8 +2371,7 @@ static char *visit_parent(char *path, char *newpath, int *presel)
|
||||||
|
|
||||||
dir = dirname(newpath);
|
dir = dirname(newpath);
|
||||||
if (access(dir, R_OK) == -1) {
|
if (access(dir, R_OK) == -1) {
|
||||||
printwarn();
|
printwarn(presel);
|
||||||
*presel = MSGWAIT;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2620,7 +2620,7 @@ static int dentfill(char *path, struct entry **dents)
|
||||||
|
|
||||||
if (fstatat(fd, ".", &sb_path, 0) == -1) {
|
if (fstatat(fd, ".", &sb_path, 0) == -1) {
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
printwarn();
|
printwarn(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3012,7 +3012,7 @@ begin:
|
||||||
* It's assumed that path IS a directory when we are here.
|
* It's assumed that path IS a directory when we are here.
|
||||||
*/
|
*/
|
||||||
if (access(path, R_OK) == -1)
|
if (access(path, R_OK) == -1)
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
|
|
||||||
populate(path, lastname);
|
populate(path, lastname);
|
||||||
if (interrupted) {
|
if (interrupted) {
|
||||||
|
@ -3077,7 +3077,7 @@ nochange:
|
||||||
|
|
||||||
/* Cannot use stale data in entry, file may be missing by now */
|
/* Cannot use stale data in entry, file may be missing by now */
|
||||||
if (stat(newpath, &sb) == -1) {
|
if (stat(newpath, &sb) == -1) {
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
DPRINTF_U(sb.st_mode);
|
DPRINTF_U(sb.st_mode);
|
||||||
|
@ -3085,8 +3085,7 @@ nochange:
|
||||||
switch (sb.st_mode & S_IFMT) {
|
switch (sb.st_mode & S_IFMT) {
|
||||||
case S_IFDIR:
|
case S_IFDIR:
|
||||||
if (access(newpath, R_OK) == -1) {
|
if (access(newpath, R_OK) == -1) {
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
presel = MSGWAIT;
|
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3442,7 +3441,7 @@ nochange:
|
||||||
|
|
||||||
mkpath(path, dents[cur].name, newpath);
|
mkpath(path, dents[cur].name, newpath);
|
||||||
if (lstat(newpath, &sb) == -1 || !show_stats(newpath, dents[cur].name, &sb)) {
|
if (lstat(newpath, &sb) == -1 || !show_stats(newpath, dents[cur].name, &sb)) {
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3787,7 +3786,7 @@ nochange:
|
||||||
/* Open the descriptor to currently open directory */
|
/* Open the descriptor to currently open directory */
|
||||||
fd = open(path, O_RDONLY | O_DIRECTORY);
|
fd = open(path, O_RDONLY | O_DIRECTORY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3812,7 +3811,7 @@ nochange:
|
||||||
/* Rename the file */
|
/* Rename the file */
|
||||||
if (renameat(fd, dents[cur].name, fd, tmp) != 0) {
|
if (renameat(fd, dents[cur].name, fd, tmp) != 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -3846,8 +3845,7 @@ nochange:
|
||||||
|
|
||||||
/* Check if file creation failed */
|
/* Check if file creation failed */
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
presel = MSGWAIT;
|
|
||||||
close(fd);
|
close(fd);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
@ -3877,8 +3875,7 @@ nochange:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(plugindir, &sb) == -1) {
|
if (stat(plugindir, &sb) == -1) {
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
presel = MSGWAIT;
|
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3930,7 +3927,7 @@ nochange:
|
||||||
} else {
|
} else {
|
||||||
/* Switch to current path for readline(3) */
|
/* Switch to current path for readline(3) */
|
||||||
if (chdir(path) == -1) {
|
if (chdir(path) == -1) {
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3941,7 +3938,7 @@ nochange:
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
if (chdir(ipath) == -1) {
|
if (chdir(ipath) == -1) {
|
||||||
printwarn();
|
printwarn(&presel);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
@ -4311,7 +4308,7 @@ int main(int argc, char *argv[])
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
if (stat(initpath, &sb) == -1) {
|
if (stat(initpath, &sb) == -1) {
|
||||||
printwarn();
|
xerror();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue