importing nherment's patch for issue #7

This commit is contained in:
David Schoen 2011-10-21 12:07:08 +08:00 committed by Ryan McGrath
parent 403deea04c
commit 34de06b73d

View file

@ -213,6 +213,30 @@ exports.copyDirRecursive = function copyDirRecursive(srcDir, newDir, clbk) {
}); });
}; };
var mkDirSyncRecursive = function(path, mode) {
var self = this;
try {
fs.mkdirSync(path, mode);
} catch(err) {
if(err.code == "ENOENT") {
var slashIdx = path.lastIndexOf("/");
if(slashIdx > 0) {
var parentPath = path.substring(0, slashIdx);
mkDirSyncRecursive(parentPath, mode);
mkDirSyncRecursive(path, mode);
} else {
throw err;
}
} else if(err.code == "EEXIST") {
return;
} else {
throw err;
}
}
};
exports.mkDirSyncRecursive = mkDirSyncRecursive;
exports.LineReader = function(filename, bufferSize) { exports.LineReader = function(filename, bufferSize) {
this.bufferSize = bufferSize || 8192; this.bufferSize = bufferSize || 8192;
this.buffer = ""; this.buffer = "";