initial commit
This commit is contained in:
commit
4b60ece582
327 changed files with 28286 additions and 0 deletions
34
libjs/polymorph/pathCheck.js
Normal file
34
libjs/polymorph/pathCheck.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
const fs = require("fs");
|
||||
|
||||
function pathCheck(/*Array*/path, cb) {
|
||||
fs.access(path[0], function(err) {
|
||||
if (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
fs.mkdir(path[0], function() {
|
||||
if (path.length === 1) {
|
||||
cb();
|
||||
} else {
|
||||
let nPath = path.slice();
|
||||
let out = nPath.splice(1, 1);
|
||||
nPath[0] += "/" + out[0];
|
||||
pathCheck(nPath, cb);
|
||||
}
|
||||
})
|
||||
} else {
|
||||
cb(err);
|
||||
}
|
||||
} else {
|
||||
if (path.length === 1) {
|
||||
cb();
|
||||
} else {
|
||||
let nPath = path.slice();
|
||||
let out = nPath.splice(1, 1);
|
||||
nPath[0] += "/" + out[0];
|
||||
pathCheck(nPath, cb);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = pathCheck;
|
Loading…
Add table
Add a link
Reference in a new issue