Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / phantomjs / lib / phantom / examples / scandir.js
1 // List all the files in a Tree of Directories
2 var system = require('system');
3
4 if (system.args.length !== 2) {
5     console.log("Usage: phantomjs scandir.js DIRECTORY_TO_SCAN");
6     phantom.exit(1);
7 }
8
9 var scanDirectory = function (path) {
10     var fs = require('fs');
11     if (fs.exists(path) && fs.isFile(path)) {
12         console.log(path);
13     } else if (fs.isDirectory(path)) {
14         fs.list(path).forEach(function (e) {
15             if ( e !== "." && e !== ".." ) {    //< Avoid loops
16                 scanDirectory(path + '/' + e);
17             }
18         });
19     }
20 };
21 scanDirectory(system.args[1]);
22 phantom.exit();