[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] Patch for bug #44950
From: |
Benno Schulenberg |
Subject: |
Re: [Nano-devel] Patch for bug #44950 |
Date: |
Wed, 20 Jan 2016 11:21:55 +0100 |
On Tue, Jan 19, 2016, at 19:38, Mike Frysinger wrote:
> On 18 Jan 2016 11:50, Benno Schulenberg wrote:
> > + if (stat(parentdir, &parentinfo) != -1 && S_ISDIR(parentinfo.st_mode))
> > + valid_path = TRUE;
> > + else {
> > + statusbar(_("Directory '%s' does not exist"), parentdir);
>
> this warning can be inaccurate/confusing. the reason for stat() failure
> is not always ENOENT, and it can hit here when it's not a dir. maybe:
> valid_path = FALSE;
> if (stat(parentdir, &parentinfo) != -1) {
> statusbar(_("Directory '%s' failed: %s"), parentdir,
> strerror(errno));
> beep();
> } else if (!S_ISDIR(parentinfo.st_mode)) {
> statusbar(_("Path '%s' is not a directory"), parentdir);
> beep();
> } else
> valid_path = TRUE;
Yes, better (after substituting '!= -1' with '== -1').
But I don't like the sound of:
[ Directory 'foo' failed: No such file or directory ]
So I propose the following instead:
if (stat(parentdir, &parentinfo) == -1) {
if (errno == ENOENT)
statusbar(_("Path '%s' does not exist"), parentdir);
else
statusbar(_("Path '%s': %s"), parentdir, strerror(errno));
valid_path = FALSE;
beep();
} else if (!S_ISDIR(parentinfo.st_mode)) {
statusbar(_("Path '%s' is not a directory"), parentdir);
valid_path = FALSE;
beep();
} else
valid_path = TRUE;
But... when I do as a normal user 'src/nano /root/something',
why don't I get "Path '/root': Permission denied"?
Benno
--
http://www.fastmail.com - Accessible with your email software
or over the web
clearer-messages.patch
Description: Text Data
- Re: [Nano-devel] Patch for bug #44950, (continued)
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/18
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/18
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/19
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/19
- Re: [Nano-devel] Patch for bug #44950, Mike Frysinger, 2016/01/19
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/20
- Re: [Nano-devel] Patch for bug #44950, Mike Frysinger, 2016/01/20
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/20
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/20
- Re: [Nano-devel] Patch for bug #44950, Mike Frysinger, 2016/01/19
- Re: [Nano-devel] Patch for bug #44950,
Benno Schulenberg <=
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/20
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/21
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/23
- Re: [Nano-devel] Patch for bug #44950, Rishabh Dave, 2016/01/23
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/23
- Re: [Nano-devel] Patch for bug #44950, Benno Schulenberg, 2016/01/10