Unverified Commit 4419de25 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #11 from ethereum/startnode

add resolveDirectory & change sharedfolder `get` return value
parents 8719ce86 4cbe4c17
...@@ -15,6 +15,15 @@ module.exports = { ...@@ -15,6 +15,15 @@ module.exports = {
cb(null, utils.walkSync(this.sharedFolder, {}, this.sharedFolder)) cb(null, utils.walkSync(this.sharedFolder, {}, this.sharedFolder))
}, },
resolveDirectory: function (args, cb) {
try {
var path = utils.absolutePath(args.path, this.sharedFolder)
cb(null, utils.resolveDirectory(path, this.sharedFolder))
} catch (e) {
cb(e)
}
},
get: function (args, cb) { get: function (args, cb) {
var path = utils.absolutePath(args.path, this.sharedFolder) var path = utils.absolutePath(args.path, this.sharedFolder)
if (!isRealPath(path, cb)) return if (!isRealPath(path, cb)) return
...@@ -25,7 +34,7 @@ module.exports = { ...@@ -25,7 +34,7 @@ module.exports = {
} else { } else {
fs.readFile(path, 'utf8', (error, data) => { fs.readFile(path, 'utf8', (error, data) => {
if (error) console.log(error) if (error) console.log(error)
cb(error, data) cb(error, {content: data, readonly: false})
}) })
} }
}) })
......
...@@ -6,7 +6,8 @@ var pathModule = require('path') ...@@ -6,7 +6,8 @@ var pathModule = require('path')
module.exports = { module.exports = {
absolutePath: absolutePath, absolutePath: absolutePath,
relativePath: relativePath, relativePath: relativePath,
walkSync: walkSync walkSync: walkSync,
resolveDirectory: resolveDirectory
} }
/** /**
...@@ -59,3 +60,16 @@ function walkSync (dir, filelist, sharedFolder) { ...@@ -59,3 +60,16 @@ function walkSync (dir, filelist, sharedFolder) {
}) })
return filelist return filelist
} }
function resolveDirectory (dir, sharedFolder) {
var ret = {}
var files = fs.readdirSync(dir)
files.forEach(function (file) {
var subElement = path.join(dir, file)
if (!fs.lstatSync(subElement).isSymbolicLink()) {
var relative = relativePath(subElement, sharedFolder)
ret[relative] = { isDirectory: fs.statSync(subElement).isDirectory() }
}
})
return ret
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment