Originally published on: Sat, 24 Jul 2010
After successfully compilng a Rhino JavaScript program to a Java class file ( Compiling Rhino JavaScript to Java), I wanted to see if I could then convert such a class file to a Windows executable (EXE) file using launch4j.
Let's start by creating a new, self-contained JS file that does not contain any runtime calls to load().
The script dir_scan.js uses a recursive function scanDir() to traverse a directory, tallying up all of the consumed file space into a map named mapOfDirs.
After the traversal, the keys from mapOfDirs are isolated into an array called mapKeys. The array is then sorted. A closure function is used in the sort invocation that sorts the array based on the corresponding value in the map. When the call to mapKeys.sort() completes, the array then holds the keys in sorted, ascending order by the computed filesize of the elements of the given directory.
dir_scan.js
| Previous post: | Compiling Rhino JavaScript to Java |
|---|---|
| Next post: | Extending SpiderMonkey JavaScript on Windows |
Subscribe!
Auto Save Clipboard Images Redux
Extending SpiderMonkey JavaScript on Windows
Rhino JavaScript to EXE with launch4j
Compiling Rhino JavaScript to Java
Directory Traversal in Rhino JavaScript
A Command-Line MP3 Player for Windows
Auto Save Images from the Clipboard
Java in a Windows EXE with launch4j
An Interview with Tom Zimmer: Forth System Developer
Setting Windows Console Text Colors in C
Thwarting HTTP Referer Trackbacks
Embedding JavaScript in a Batch File
Hiding Batch File Console Windows
Jim Butterfield : The Commodore Guru
Extracting URL Addresses from Text in C
A Simple Associative Array Library in C
Stacking Images with PerlMagick
MicroISV on a Shoestring
DadHacker
The Bottom Feeder
Writin' That Code!
The Recursive ISV
The Thomsen Blog
Prototypically Speaking
The Reinvigorated Programmer