File tree 6 files changed +24
-14
lines changed
6 files changed +24
-14
lines changed Original file line number Diff line number Diff line change 1
- import { Parser } from "../lib/binary_parser" ;
2
1
import { readFile } from "fs" ;
2
+ import { join } from "path" ;
3
+
4
+ import { Parser } from "../lib/binary_parser" ;
3
5
4
6
// C structure BITMAPFILEHEADER
5
7
// typedef struct tagBITMAPFILEHEADER {
@@ -56,6 +58,6 @@ const bmpFile = new Parser()
56
58
type : bmpInfoHeader ,
57
59
} ) ;
58
60
59
- readFile ( "test.bmp" , ( _ , data ) => {
61
+ readFile ( join ( __dirname , "test.bmp" ) , ( _ , data ) => {
60
62
console . log ( bmpFile . parse ( data ) ) ;
61
63
} ) ;
Original file line number Diff line number Diff line change 1
- import { Parser } from "../lib/binary_parser" ;
2
1
import { readFile } from "fs" ;
2
+ import { join } from "path" ;
3
3
import { inspect } from "util" ;
4
4
5
+ import { Parser } from "../lib/binary_parser" ;
6
+
5
7
const ConstantClassInfo = Parser . start ( ) . uint16be ( "name_index" ) ;
6
8
7
9
const ConstantFieldrefInfo = Parser . start ( )
@@ -83,6 +85,6 @@ const ClassFile = Parser.start()
83
85
} ,
84
86
} ) ;
85
87
86
- readFile ( "Hello.class" , function ( _ , data ) {
88
+ readFile ( join ( __dirname , "Hello.class" ) , ( _ , data ) => {
87
89
console . log ( inspect ( ClassFile . parse ( data ) , { depth : null , colors : true } ) ) ;
88
90
} ) ;
Original file line number Diff line number Diff line change 1
- import { Parser } from "../lib/binary_parser" ;
2
1
import { readFile } from "fs" ;
2
+ import { join } from "path" ;
3
3
import { inspect } from "util" ;
4
4
5
+ import { Parser } from "../lib/binary_parser" ;
6
+
5
7
const ELF32ProgramHeader = new Parser ( )
6
8
. endianess ( "little" )
7
9
. uint32 ( "type" )
@@ -80,7 +82,7 @@ const ELF32Header = new Parser()
80
82
} ,
81
83
} ) ;
82
84
83
- readFile ( "hello" , function ( _ , data ) {
85
+ readFile ( join ( __dirname , "hello" ) , ( _ , data ) => {
84
86
const result = ELF32Header . parse ( data ) ;
85
87
console . log ( inspect ( result , { depth : null , colors : true } ) ) ;
86
88
} ) ;
Original file line number Diff line number Diff line change 1
- import { Parser } from "../lib/binary_parser" ;
2
1
import { readFile } from "fs" ;
2
+ import { join } from "path" ;
3
3
import { inspect } from "util" ;
4
4
5
+ import { Parser } from "../lib/binary_parser" ;
6
+
5
7
const SOI = Parser . start ( ) ;
6
8
7
9
const EOI = Parser . start ( ) ;
@@ -106,6 +108,6 @@ const JPEG = Parser.start().array("segments", {
106
108
readUntil : "eof" ,
107
109
} ) ;
108
110
109
- readFile ( "test.jpg" , function ( _ , data ) {
111
+ readFile ( join ( __dirname , "test.jpg" ) , ( _ , data ) => {
110
112
console . log ( inspect ( JPEG . parse ( data ) , { depth : null , colors : true } ) ) ;
111
113
} ) ;
Original file line number Diff line number Diff line change 1
- import { Parser } from "../lib/binary_parser" ;
2
1
import { readFile } from "fs" ;
2
+ import { join } from "path" ;
3
3
import { inspect } from "util" ;
4
4
5
+ import { Parser } from "../lib/binary_parser" ;
6
+
5
7
const chs = new Parser ( )
6
8
. uint8 ( "head" )
7
9
. bit2 ( "cylinderHigh" )
@@ -39,6 +41,6 @@ const mbrParser = new Parser()
39
41
assert : 0x55aa ,
40
42
} ) ;
41
43
42
- readFile ( "raspbian.img" , function ( _ , data ) {
44
+ readFile ( join ( __dirname , "raspbian.img" ) , ( _ , data ) => {
43
45
console . log ( inspect ( mbrParser . parse ( data ) , { depth : null , colors : true } ) ) ;
44
46
} ) ;
Original file line number Diff line number Diff line change 1
- import { Parser } from "../lib/binary_parser " ;
1
+ import { join } from "path " ;
2
2
import { readFile } from "fs" ;
3
3
4
+ import { Parser } from "../lib/binary_parser" ;
5
+
4
6
function oct2int ( s : string ) : number {
5
7
return parseInt ( s , 8 ) ;
6
8
}
@@ -37,8 +39,6 @@ const tarArchive = new Parser().array("files", {
37
39
readUntil : "eof" ,
38
40
} ) ;
39
41
40
- console . log ( tarArchive . getCode ( ) ) ;
41
-
42
- readFile ( "test.tar" , function ( _ , data ) {
42
+ readFile ( join ( __dirname , "test.tar" ) , ( _ , data ) => {
43
43
console . dir ( tarArchive . parse ( data ) , { depth : null , colors : true } ) ;
44
44
} ) ;
You can’t perform that action at this time.
0 commit comments