From 04310479519db859ca9d8659de7b6c91368ee62b Mon Sep 17 00:00:00 2001 From: ioedeveloper Date: Tue, 5 May 2020 03:30:17 +0000 Subject: [PATCH] Added isFile and isDirectory to sharedFolder api --- src/services/sharedFolder.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/services/sharedFolder.js b/src/services/sharedFolder.js index 927202472c..3b8d79e645 100644 --- a/src/services/sharedFolder.js +++ b/src/services/sharedFolder.js @@ -63,7 +63,8 @@ module.exports = { }, exists: function (args, cb) { - var path = utils.absolutePath(args.path, this.currentSharedFolder) + const path = utils.absolutePath(args.path, this.currentSharedFolder) + cb(null, fs.existsSync(path)) }, @@ -116,6 +117,18 @@ module.exports = { }) }, + isDirectory: function (args, cb) { + const path = utils.absolutePath(args.path, this.currentSharedFolder) + + cb(null, fs.statSync(path).isDirectory()) + }, + + isFile: function (args, cb) { + const path = utils.absolutePath(args.path, this.currentSharedFolder) + + cb(null, fs.statSync(path).isFile()) + }, + setupNotifications: function (path) { if (!isRealPath(path)) return var watcher = chokidar.watch(path, {depth: 0, ignorePermissionErrors: true})