| 
									
										
										
										
											2017-09-25 12:26:15 -06:00
										 |  |  | #!/usr/bin/env node
 | 
					
						
							| 
									
										
										
										
											2017-09-25 12:00:04 -06:00
										 |  |  | (function () { | 
					
						
							|  |  |  | 'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var hexdump = require('../').hexdump; | 
					
						
							|  |  |  | var fsname = process.argv[2]; | 
					
						
							|  |  |  | var fs = require('fs'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (!fsname || '--help' === fs || '-h' === fs) { | 
					
						
							|  |  |  |   console.error('Usage: hexdump.js <filepath>'); | 
					
						
							| 
									
										
										
										
											2017-09-25 12:22:44 -06:00
										 |  |  |   process.exit(2); | 
					
						
							| 
									
										
										
										
											2017-09-25 12:00:04 -06:00
										 |  |  |   return; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | try { | 
					
						
							|  |  |  |   fs.statSync(fsname); | 
					
						
							|  |  |  | } catch(e) { | 
					
						
							|  |  |  |   console.error(e.message); | 
					
						
							| 
									
										
										
										
											2017-09-25 12:22:44 -06:00
										 |  |  |   process.exit(3); | 
					
						
							| 
									
										
										
										
											2017-09-25 12:00:04 -06:00
										 |  |  |   return; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var nb = fs.readFileSync(fsname); | 
					
						
							|  |  |  | var str = hexdump(nb.buffer, nb.byteOffset, nb.byteLength); | 
					
						
							|  |  |  | console.log(str); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }()); |