Phantomjs-maketree-method

提供:Dev Guides
2020年6月23日 (火) 08:10時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

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();

上記のプログラムは、次の output を生成します。

Checking to see if the maketree has converted into directory : true
Listing the contents from the path given
[".","..","file.txt"]