javascript - Identifying the File System Root with Node.js -
i'm doing basic operation start given directory, , traverse filesystem until hit root. on linux/mac, root /
, on windows can c:\
or drive letter of course. question whether or not there way node.js identify root directory of filesystem is.
currently, i'm resorting checking last directory against path.normalize(dir + "/../")
see if stops changing. there process
property/method out there? maybe module?
would not work?
var path = require("path"); var os = require("os"); var root = (os.platform == "win32") ? process.cwd().split(path.sep)[0] : "/"
Comments
Post a Comment