mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 13:26:37 +00:00
Merge pull request #1658 from N-R-K/chmod_fix
fix: properly update mode after xchmod
This commit is contained in:
commit
fb6e7403cf
10
src/nnn.c
10
src/nnn.c
|
@ -4604,12 +4604,12 @@ static bool show_stats(char *fpath)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xchmod(const char *fpath, mode_t mode)
|
static bool xchmod(const char *fpath, mode_t *mode)
|
||||||
{
|
{
|
||||||
/* (Un)set (S_IXUSR | S_IXGRP | S_IXOTH) */
|
/* (Un)set (S_IXUSR | S_IXGRP | S_IXOTH) */
|
||||||
(0100 & mode) ? (mode &= ~0111) : (mode |= 0111);
|
(0100 & *mode) ? (*mode &= ~0111) : (*mode |= 0111);
|
||||||
|
|
||||||
return (chmod(fpath, mode) == 0);
|
return (chmod(fpath, *mode) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t get_fs_info(const char *path, uchar_t type)
|
static size_t get_fs_info(const char *path, uchar_t type)
|
||||||
|
@ -7381,13 +7381,13 @@ nochange:
|
||||||
|
|
||||||
if ((sel == SEL_STATS && !show_stats(newpath))
|
if ((sel == SEL_STATS && !show_stats(newpath))
|
||||||
|| (lstat(newpath, &sb) == -1)
|
|| (lstat(newpath, &sb) == -1)
|
||||||
|| (sel == SEL_CHMODX && !xchmod(newpath, sb.st_mode))) {
|
|| (sel == SEL_CHMODX && !xchmod(newpath, &sb.st_mode))) {
|
||||||
printwarn(&presel);
|
printwarn(&presel);
|
||||||
goto nochange;
|
goto nochange;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sel == SEL_CHMODX)
|
if (sel == SEL_CHMODX)
|
||||||
pdents[cur].mode ^= 0111;
|
pdents[cur].mode = sb.st_mode;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SEL_REDRAW: // fallthrough
|
case SEL_REDRAW: // fallthrough
|
||||||
|
|
Loading…
Reference in a new issue