[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] Checking permissions before opening file
From: |
Mike Frysinger |
Subject: |
Re: [Nano-devel] Checking permissions before opening file |
Date: |
Tue, 26 Jan 2016 15:48:01 -0500 |
On 26 Jan 2016 21:03, Benno Schulenberg wrote:
> + if (errno == ENOENT)
> + statusbar(_("Path '%s' does not exist"), parentdir);
> + else
> + statusbar(_("Path '%s': %s"), parentdir, strerror(errno));
why is this needed ? the strerror() for ENOENT is already:
No such file or directory
and glibc already provides translations for that string.
seems to me it should be a single line:
statusbar(_("Path '%s': %s"), parentdir, strerror(errno));
> + } else if (!S_ISDIR(parentinfo.st_mode)) {
> + statusbar(_("Path '%s' is not a directory"), parentdir);
> + beep();
> + } else {
> + if (access(parentdir, X_OK) != -1)
> + validity = TRUE;
> + else {
> + statusbar(_("Path '%s' is not accessible"), parentdir);
> + beep();
> + }
i don't think this check is useful. it should just attempt the open
(or whatever) and diagnose problems when that fails. there's no way
to guarantee the path will stay valid after this func returns.
i.e. the whole has_valid_path should be punted and avoid early checks.
-mike
signature.asc
Description: Digital signature