- PhantomJS Tutorial
- PhantomJS - Home
- PhantomJS - Overview
- PhantomJS - Environment Setup
- PhantomJS - Object
- PhantomJS - Methods
- WebPage Module
- PhantomJS - Properties
- PhantomJS - Methods
- PhantomJS - Events/Callbacks
- PhantomJS - Child Process Module
- File System Module
- PhantomJS - Properties
- PhantomJS - Methods
- System Module
- PhantomJS - Properties
- Web Server Module
- PhantomJS - Properties
- PhantomJS - Methods
- Miscellaneous
- Command Line Interface
- PhantomJS - Screen Capture
- PhantomJS - Page Automation
- PhantomJS - Network Monitoring
- PhantomJS - Testing
- PhantomJS - REPL
- PhantomJS - Examples
- PhantomJS Useful Resources
- PhantomJS - Quick Guide
- PhantomJS - Useful Resources
- PhantomJS - Discussion
PhantomJS - makeTree
The makeTree method creates all the necessary folders to be able to form the final directories. This will return true, if the creation was successful, otherwise false. If the directory already exists, it will return true.
Syntax
Its syntax is as follows −
fs.makeTree(path);
Example
The following example shows how you can use the makeTree method −
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();
The above program generates the following output.
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
Advertisements