File tree Expand file tree Collapse file tree 11 files changed +39
-2
lines changed Expand file tree Collapse file tree 11 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 11.DS_Store
22testfiles /
33fq
4+ * .swp
Original file line number Diff line number Diff line change 8686json,
8787[ macho] ( doc/formats.md#macho ) ,
8888[ matroska] ( doc/formats.md#matroska ) ,
89+ mbr,
8990mp3,
9091mp3_frame,
9192[ mp4] ( doc/formats.md#mp4 ) ,
Original file line number Diff line number Diff line change 55- Create a directory ` format/<name> `
66- Copy some similar decoder, ` format/format/bson.go ` is quite small, to ` format/<name>/<name>.go `
77- Cleanup and fill in the register struct, rename ` format.BSON ` and add it
8- to ` format/fromat .go ` and don't forget to change the string constant.
8+ to ` format/format .go ` and don't forget to change the string constant.
99- Add an import to ` format/all/all.go `
1010
1111### Some general tips
Original file line number Diff line number Diff line change 5656| ` json ` | JSON | <sub ></sub >|
5757| [ ` macho ` ] ( #macho ) | Mach-O  ; macOS  ; executable | <sub ></sub >|
5858| [ ` matroska ` ] ( #matroska ) | Matroska  ; file | <sub >` aac_frame ` ` av1_ccr ` ` av1_frame ` ` avc_au ` ` avc_dcr ` ` flac_frame ` ` flac_metadatablocks ` ` hevc_au ` ` hevc_dcr ` ` image ` ` mp3_frame ` ` mpeg_asc ` ` mpeg_pes_packet ` ` mpeg_spu ` ` opus_packet ` ` vorbis_packet ` ` vp8_frame ` ` vp9_cfm ` ` vp9_frame ` </sub >|
59+ |` mbr ` |Master  ; Boot  ; Record
5960| ` mp3 ` | MP3  ; file | <sub >` id3v2 ` ` id3v1 ` ` id3v11 ` ` apev2 ` ` mp3_frame ` </sub >|
6061| ` mp3_frame ` | MPEG  ; audio  ; layer  ; 3  ; frame | <sub >` xing ` </sub >|
6162| [ ` mp4 ` ] ( #mp4 ) | MPEG-4  ; file  ; and  ; similar | <sub >` aac_frame ` ` av1_ccr ` ` av1_frame ` ` flac_frame ` ` flac_metadatablocks ` ` id3v2 ` ` image ` ` jpeg ` ` mp3_frame ` ` avc_au ` ` avc_dcr ` ` mpeg_es ` ` hevc_au ` ` hevc_dcr ` ` mpeg_pes_packet ` ` opus_packet ` ` protobuf_widevine ` ` pssh_playready ` ` vorbis_packet ` ` vp9_frame ` ` vpx_ccr ` ` icc_profile ` </sub >|
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import (
2424 _ "github.com/wader/fq/format/json"
2525 _ "github.com/wader/fq/format/macho"
2626 _ "github.com/wader/fq/format/matroska"
27+ _ "github.com/wader/fq/format/mbr"
2728 _ "github.com/wader/fq/format/mp3"
2829 _ "github.com/wader/fq/format/mp4"
2930 _ "github.com/wader/fq/format/mpeg"
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ const (
6363 JSON = "json"
6464 MACHO = "macho"
6565 MATROSKA = "matroska"
66+ MBR = "mbr"
6667 MP3 = "mp3"
6768 MP3_FRAME = "mp3_frame"
6869 MP4 = "mp4"
Original file line number Diff line number Diff line change 1+ package mbr
2+
3+ import (
4+ "github.com/wader/fq/format"
5+ "github.com/wader/fq/format/registry"
6+ "github.com/wader/fq/pkg/decode"
7+ )
8+
9+ func init () {
10+ registry .MustRegister (decode.Format {
11+ Name : format .MBR ,
12+ Description : "Master Boot Record" ,
13+ DecodeFn : mbrDecode ,
14+ })
15+ }
16+
17+ func mbrDecode (d * decode.D , in interface {}) interface {} {
18+ d .FieldRawLen ("code_area" , 446 * 8 )
19+ d .FieldRawLen ("partition_table" , 64 * 8 )
20+ d .FieldRawLen ("boot_record_sig" , 2 * 8 )
21+ return nil
22+ }
Original file line number Diff line number Diff line change 1+ # head -c 512 /dev/sda > mbr.bin
2+ $ fq . -d mbr mbr.bin
3+ |00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: mbr.bin (mbr)
4+ 0x000|fa bc 00 7c 31 c0 8e d0 8e c0 8e d8 52 be 00 7c|...|1.......R..|| code_area: raw bits
5+ * |until 0x1bd.7 (446) | |
6+ 0x1b0| 00 00| ..| partition_table: raw bits
7+ 0x1c0|00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00|................|
8+ * |until 0x1fd.7 (64) | |
9+ 0x1f0| 55 aa| U.| boot_record_sig: raw bits
Original file line number Diff line number Diff line change 66 "github.com/wader/fq/pkg/cli"
77)
88
9- const version = "0.0.6 "
9+ const version = "0.0.7 "
1010
1111func main () {
1212 cli .Main (registry .Default , version )
You can’t perform that action at this time.
0 commit comments