Test if we can back out/enter directories

This commit is contained in:
sin 2014-10-22 17:25:25 +01:00
parent aedec0ddf3
commit 48f9c5a79d

10
noice.c
View file

@ -615,6 +615,10 @@ nochange:
/* There is no going back */ /* There is no going back */
if (strcmp(path, "/") == 0) if (strcmp(path, "/") == 0)
goto nochange; goto nochange;
if (testopendir(path) == 0) {
printwarn();
goto nochange;
}
dir = xdirname(path); dir = xdirname(path);
free(path); free(path);
path = dir; path = dir;
@ -642,6 +646,10 @@ nochange:
switch (sb.st_mode & S_IFMT) { switch (sb.st_mode & S_IFMT) {
case S_IFDIR: case S_IFDIR:
if (testopendir(path) == 0) {
printwarn();
goto nochange;
}
free(path); free(path);
path = xrealpath(name); path = xrealpath(name);
/* Reset filter */ /* Reset filter */
@ -745,7 +753,7 @@ main(int argc, char *argv[])
} }
/* Test initial path */ /* Test initial path */
if (!testopendir(ipath)) if (testopendir(ipath) == 0)
printerr(1, ipath); printerr(1, ipath);
/* Set locale before curses setup */ /* Set locale before curses setup */