Revision: 55985
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 3, 2012 06:21 by tpryan
Initial Code
importPackage(java.io); function directoryList(startPath){ var fileObject=new File(startPath); var list = fileObject.list(); var results = []; for (var i=0; i<list.length; i++) { var child = new File(startPath + "/" + list[i]); if (child.isDirectory()){ var recurseDirectoryListing = directoryList(child.getCanonicalPath()); results = results.concat(recurseDirectoryListing); } else{ var fileArray = {}; fileArray['path'] = child.getCanonicalPath(); fileArray['name'] = child.getName(); fileArray['parent'] = child.getParent(); fileArray['hidden'] = child.isHidden() ; fileArray['dir'] = child.isDirectory() ; var pos = fileArray['name'].lastIndexOf('.'); if (pos < 0){ fileArray['ext'] = ''; }else{ fileArray['ext'] = fileArray['name'].substring(pos+1); } results.push(fileArray); } } return results; }
Initial URL
Initial Description
A function that will return a list of files from a directory.
Initial Title
directoryList in Rhino
Initial Tags
directory
Initial Language
JavaScript