File tree Expand file tree Collapse file tree 6 files changed +24
-14
lines changed Expand file tree Collapse file tree 6 files changed +24
-14
lines changed Original file line number Diff line number Diff line change 1- import { Parser } from "../lib/binary_parser" ;
21import { readFile } from "fs" ;
2+ import { join } from "path" ;
3+
4+ import { Parser } from "../lib/binary_parser" ;
35
46// C structure BITMAPFILEHEADER
57// typedef struct tagBITMAPFILEHEADER {
@@ -56,6 +58,6 @@ const bmpFile = new Parser()
5658 type : bmpInfoHeader ,
5759 } ) ;
5860
59- readFile ( "test.bmp" , ( _ , data ) => {
61+ readFile ( join ( __dirname , "test.bmp" ) , ( _ , data ) => {
6062 console . log ( bmpFile . parse ( data ) ) ;
6163} ) ;
Original file line number Diff line number Diff line change 1- import { Parser } from "../lib/binary_parser" ;
21import { readFile } from "fs" ;
2+ import { join } from "path" ;
33import { inspect } from "util" ;
44
5+ import { Parser } from "../lib/binary_parser" ;
6+
57const ConstantClassInfo = Parser . start ( ) . uint16be ( "name_index" ) ;
68
79const ConstantFieldrefInfo = Parser . start ( )
@@ -83,6 +85,6 @@ const ClassFile = Parser.start()
8385 } ,
8486 } ) ;
8587
86- readFile ( "Hello.class" , function ( _ , data ) {
88+ readFile ( join ( __dirname , "Hello.class" ) , ( _ , data ) => {
8789 console . log ( inspect ( ClassFile . parse ( data ) , { depth : null , colors : true } ) ) ;
8890} ) ;
Original file line number Diff line number Diff line change 1- import { Parser } from "../lib/binary_parser" ;
21import { readFile } from "fs" ;
2+ import { join } from "path" ;
33import { inspect } from "util" ;
44
5+ import { Parser } from "../lib/binary_parser" ;
6+
57const ELF32ProgramHeader = new Parser ( )
68 . endianess ( "little" )
79 . uint32 ( "type" )
@@ -80,7 +82,7 @@ const ELF32Header = new Parser()
8082 } ,
8183 } ) ;
8284
83- readFile ( "hello" , function ( _ , data ) {
85+ readFile ( join ( __dirname , "hello" ) , ( _ , data ) => {
8486 const result = ELF32Header . parse ( data ) ;
8587 console . log ( inspect ( result , { depth : null , colors : true } ) ) ;
8688} ) ;
Original file line number Diff line number Diff line change 1- import { Parser } from "../lib/binary_parser" ;
21import { readFile } from "fs" ;
2+ import { join } from "path" ;
33import { inspect } from "util" ;
44
5+ import { Parser } from "../lib/binary_parser" ;
6+
57const SOI = Parser . start ( ) ;
68
79const EOI = Parser . start ( ) ;
@@ -106,6 +108,6 @@ const JPEG = Parser.start().array("segments", {
106108 readUntil : "eof" ,
107109} ) ;
108110
109- readFile ( "test.jpg" , function ( _ , data ) {
111+ readFile ( join ( __dirname , "test.jpg" ) , ( _ , data ) => {
110112 console . log ( inspect ( JPEG . parse ( data ) , { depth : null , colors : true } ) ) ;
111113} ) ;
Original file line number Diff line number Diff line change 1- import { Parser } from "../lib/binary_parser" ;
21import { readFile } from "fs" ;
2+ import { join } from "path" ;
33import { inspect } from "util" ;
44
5+ import { Parser } from "../lib/binary_parser" ;
6+
57const chs = new Parser ( )
68 . uint8 ( "head" )
79 . bit2 ( "cylinderHigh" )
@@ -39,6 +41,6 @@ const mbrParser = new Parser()
3941 assert : 0x55aa ,
4042 } ) ;
4143
42- readFile ( "raspbian.img" , function ( _ , data ) {
44+ readFile ( join ( __dirname , "raspbian.img" ) , ( _ , data ) => {
4345 console . log ( inspect ( mbrParser . parse ( data ) , { depth : null , colors : true } ) ) ;
4446} ) ;
Original file line number Diff line number Diff line change 1- import { Parser } from "../lib/binary_parser " ;
1+ import { join } from "path " ;
22import { readFile } from "fs" ;
33
4+ import { Parser } from "../lib/binary_parser" ;
5+
46function oct2int ( s : string ) : number {
57 return parseInt ( s , 8 ) ;
68}
@@ -37,8 +39,6 @@ const tarArchive = new Parser().array("files", {
3739 readUntil : "eof" ,
3840} ) ;
3941
40- console . log ( tarArchive . getCode ( ) ) ;
41-
42- readFile ( "test.tar" , function ( _ , data ) {
42+ readFile ( join ( __dirname , "test.tar" ) , ( _ , data ) => {
4343 console . dir ( tarArchive . parse ( data ) , { depth : null , colors : true } ) ;
4444} ) ;
You can’t perform that action at this time.
0 commit comments