Files
nodejs-fm/processing.js

28 lines
931 B
JavaScript
Raw Normal View History

2019-05-22 20:22:59 +05:30
const path = require('path')
2019-05-27 14:21:51 +05:30
const os = require('os')
2019-05-21 19:37:11 +05:30
module.exports.mergedir = (dirname,settings)=>{
2019-05-22 20:22:59 +05:30
return path.normalize(path.join(settings.dirname,dirname));
2019-05-21 19:37:11 +05:30
}
2019-05-22 20:22:59 +05:30
//produces the contents array
module.exports.dirprocess = (dirstream,location,settings)=>{
let contents = []
2019-05-21 20:31:41 +05:30
dirstream.forEach(element => {
2019-05-23 08:40:01 +05:30
//console.log(element)
2019-05-22 20:22:59 +05:30
if(!(element.name.startsWith('.')&&!settings.showHidden) )
{
contents.push({
"name":element.name,
2019-05-24 11:25:10 +05:30
"path":path.relative(settings.dirname,path.normalize(path.join(location,element.name))) ,
2019-05-22 20:22:59 +05:30
"isDir": element.isDirectory()
})
}
2019-05-21 20:31:41 +05:30
});
2019-05-22 20:22:59 +05:30
return contents
2019-05-21 10:38:54 +05:30
}
2019-05-27 14:21:51 +05:30
// settings.dirname, whatever
module.exports.inDir = (dircheck,dirmain) => !path.relative(path.normalize(dircheck), dirmain).startsWith('..')
module.exports.getTmpDir = (location) => path.join(os.tmpdir(), path.basename(location))