/**
* 创建文件夹帮助类
*/

var fs = require("fs");
var path = require("path");


exports.mkdirs = function mkdirs(dirname, callback) {
return mkdirs(dirname, callback);
}

//递归创建目录 异步方法
function mkdirs(dirname, callback) {
fs.exists(dirname, function (exists) {
if (exists) {
callback();
} else {
//console.log(path.dirname(dirname));
mkdirs(path.dirname(dirname), function () {
fs.mkdir(dirname, callback);
});
}
});
}


exports.mkdirsSync = function mkdirsSync(dirname) {
return mkdirsSync(dirname);
}

//递归创建目录 同步方法
function mkdirsSync(dirname) {
//console.log(dirname);
if (fs.existsSync(dirname)) {
return true;
} else {
if (mkdirsSync(path.dirname(dirname))) {
fs.mkdirSync(dirname);
return true;
}
}
}

//调用
//mkdirsSync("./aa/bb/cc" , null);
//mkdirs("./aa/bb/cc", function (ee) {
// console.log(ee)
//});


JS代码混淆加密,就用JShaman(http://www.jshaman.com/)。