fkc
Version:
FKC application service framework.
46 lines • 1.12 kB
JavaScript
;
const fs = require('fs');
const isDir = (url) => {
if(fs.existsSync(url)){
const stat = fs.statSync(url);
return stat.isDirectory();
}else{
return false;
}
}
const isFile = (url) => {
if (fs.existsSync(url)) {
const stats = fs.statSync(url);
return stats.isFile();
} else {
return false;
}
}
const getFile = (path) => {
let arr = [];
const arrFile = (url, p) => {
if (!p) p = '/';
const item = fs.readdirSync(url);
if (item.length > 0) {
item.forEach(e => {
const ets = p + e;
if (isDir(url + ets)) {
arrFile(url + ets, p + e + '/');
} else {
if (isDir(path + ets)) {
arrFile(path + ets, p + e + '/');
} else {
arr.push(ets);
}
}
});
}
}
arrFile(path);
return arr;
}
module.exports = {
isDir,
getFile,
isFile
}