diff --git a/src/browser.c b/src/browser.c index bd85b3e1..7a759320 100644 --- a/src/browser.c +++ b/src/browser.c @@ -709,14 +709,10 @@ char *browse_in(const char *inpath) path = free_and_assign(path, strip_last_component(path)); if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) { - char *currentdir = nmalloc(PATH_MAX + 1); - - path = free_and_assign(path, getcwd(currentdir, PATH_MAX + 1)); + path = free_and_assign(path, realpath(".", NULL)); if (path == NULL) { - statusline(MILD, _("The working directory has disappeared")); - free(currentdir); - beep(); + statusline(ALERT, _("The working directory has disappeared")); napms(1200); return NULL; } diff --git a/src/files.c b/src/files.c index 51bc1dce..5c9a768a 100644 --- a/src/files.c +++ b/src/files.c @@ -358,8 +358,7 @@ bool has_valid_path(const char *filename) statusline(ALERT, _("The working directory has disappeared")); free(currentdir); - } else - if (stat(parentdir, &parentinfo) == -1) { + } else if (stat(parentdir, &parentinfo) == -1) { if (errno == ENOENT) /* TRANSLATORS: Keep the next ten messages at most 76 characters. */ statusline(ALERT, _("Directory '%s' does not exist"), parentdir);