From f376c4de7598afbf4c4e15c16cea0d348b165c46 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 8 Jun 2023 19:01:27 -0400 Subject: [PATCH] Explorer directory fix (#670) * Improve explorer dir and permissions logic --------- Signed-off-by: tyopoyt Co-authored-by: tyopoyt --- res/app/control-panes/explorer/index.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/res/app/control-panes/explorer/index.js b/res/app/control-panes/explorer/index.js index 4d1525fe..5ae1b504 100644 --- a/res/app/control-panes/explorer/index.js +++ b/res/app/control-panes/explorer/index.js @@ -1,5 +1,9 @@ require('./explorer.css') +const S_IFMT = 0o0170000 // Bit mask for checking file types +const S_IFDIR = 0o040000 // Directory type +const S_IFLNK = 0o120000 // Symlink type + module.exports = angular.module('stf.explorer', []) .run(['$templateCache', function($templateCache) { $templateCache.put('control-panes/explorer/explorer.pug', @@ -20,7 +24,13 @@ module.exports = angular.module('stf.explorer', []) } } } - res.unshift(mode & 040000 ? 'd' : '-') + if ((mode & S_IFMT) === S_IFDIR) { + res.unshift('d') + } else if ((mode & S_IFMT) === S_IFLNK) { + res.unshift('l') + } else { + res.unshift('-') + } return res.join('') } } @@ -30,8 +40,7 @@ module.exports = angular.module('stf.explorer', []) var mode = m if (mode !== null) { mode = parseInt(mode, 10) - mode -= (mode & 0777) - return (mode === 040000) || (mode === 0120000) + return ((mode & S_IFMT) === S_IFDIR) || ((mode & S_IFMT) === S_IFLNK) } } })