Method Description:
Create a file directory asynchronously. If the directory already exists, an exception is thrown.
Grammar:
Copy Code code as follows:
Fs.mkdir (path, [mode], [Callback (ERR)])
Because this method belongs to the FS module, it is necessary to introduce FS module (VAR fs= require ("FS") before use.
Receive parameters:
directory path that path will create
Mode directory permissions (read-write permissions), default 0777
Callback callback, passing exception parameter err
Example:
Copy Code code as follows:
var fs = require (' FS ');
Fs.mkdir (' Creatdir ', 0777, function (err) {
if (err) {
Console.log (ERR);
}else{
Console.log ("creat done!");
}
})
Source:
Copy Code code as follows:
Fs.mkdir = function (path, mode, callback) {
if (util.isfunction (mode)) callback = mode;
callback = Makecallback (callback);
if (!nullcheck (path, callback)) return;
Binding.mkdir (path), Pathmodule._makelong
Modenum (mode, 511/*=0777*/),
callback);
};