Skip to content

Commit

Permalink
transittion to magicnumber reader.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Aug 30, 2024
1 parent 4238499 commit 15e8c7c
Show file tree
Hide file tree
Showing 14 changed files with 1,767 additions and 15 deletions.
Empty file added assets/testdata/EMPTY.ZIP
Empty file.
Binary file added assets/testdata/TEST.jar
Binary file not shown.
Binary file added assets/testdata/TEST.tar.bz2
Binary file not shown.
Binary file added assets/testdata/TESTfree.arc
Binary file not shown.
8 changes: 4 additions & 4 deletions internal/magicnumber/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import "bytes"
// Package file archive.go contains the functions that parse bytes as common file archive,
// compression and disk image formats.

// Arc matches the FreeArc compression format in the byte slice.
func Arc(p []byte) bool {
// ArcFree matches the FreeArc compression format in the byte slice.
func ArcFree(p []byte) bool {
const min = 4
if len(p) < min {
return false
}
return bytes.Equal(p[:min], []byte{'A', 'r', 'C', 0x1})
}

// ArcArk matches the ARChive SEA compression format in the byte slice.
func ArcArk(p []byte) bool {
// ArcSEA matches the ARChive SEA compression format in the byte slice.
func ArcSEA(p []byte) bool {
const min = 2
if len(p) < min {
return false
Expand Down
21 changes: 10 additions & 11 deletions internal/magicnumber/magicnumber.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,14 @@ func Ext() Extension { //nolint:funlen
CDNero: []string{".nri"},
CDPowerISO: []string{".daa"},
CDAlcohol120: []string{".mdf"},
// JavaARchive: []string{".jar"},
WindowsHelpFile: []string{".hlp"},
PortableDocumentFormat: []string{".pdf"},
RichTextFormat: []string{".rtf"},
UTF8Text: []string{".txt"},
UTF16Text: []string{".txt"},
UTF32Text: []string{".txt"},
ANSIEscapeText: []string{".ans"},
PlainText: []string{".txt"},
WindowsHelpFile: []string{".hlp"},
PortableDocumentFormat: []string{".pdf"},
RichTextFormat: []string{".rtf"},
UTF8Text: []string{".txt"},
UTF16Text: []string{".txt"},
UTF32Text: []string{".txt"},
ANSIEscapeText: []string{".ans"},
PlainText: []string{".txt"},
}
}

Expand Down Expand Up @@ -428,8 +427,8 @@ func New() Finder { //nolint:funlen
X7zCompressArchive: X7z,
XZCompressArchive: XZ,
ZStandardArchive: ZStd,
FreeArc: Arc,
ARChiveSEA: ArcArk,
FreeArc: ArcFree,
ARChiveSEA: ArcSEA,
YoshiLHA: LzhLha,
ZooArchive: Zoo,
ArchiveRobertJung: Arj,
Expand Down
Loading

0 comments on commit 15e8c7c

Please sign in to comment.