PhantomJS - makeTree 方法
makeTree 方法创建所有必要的文件夹,以便能够形成最终目录。如果创建成功,则返回 true,否则返回 false。如果目录已存在,则返回 true。
语法
其语法如下 −
fs.makeTree(path);
示例
以下示例展示了如何使用 makeTree 方法 −
var fs = require('fs');
var system = require('system');
var path = system.args[1];
fs.makeTree(path);
console.log("Checking to see if the maketree has converted into directory : " +fs.isDirectory(path));
console.log("Listing the contents from the path given");
var a = path.split("/");
var list = fs.list(a[0]+"/"+a[1]+"/"+a[2]+"/"+a[3]);
console.log(JSON.stringify(list));
phantom.exit();
上述程序生成以下输出。
Checking to see if the maketree has converted into directory : true Listing the contents from the path given [".","..","file.txt"]
phantomjs_file_system_module_methods.html

