- 檔案系統模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 系統模組
- PhantomJS - 屬性
- Web 伺服器模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 其他
- 命令列介面
- PhantomJS - 螢幕捕獲
- PhantomJS - 頁面自動化
- PhantomJS - 網路監控
- PhantomJS - 測試
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 有用資源
- PhantomJS - 快速指南
- PhantomJS - 有用資源
- PhantomJS - 討論
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.htm
廣告