Skip to content

Commit d2d0522

Browse files
authored
Merge pull request #74 from xbabka01/master
Added support for elf
2 parents 2693839 + faba42b commit d2d0522

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

filetype/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
archive.Z(),
8787
archive.Lzop(),
8888
archive.Lz(),
89+
archive.Elf(),
8990
archive.Lz4(),
9091
)
9192

filetype/types/archive.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,27 @@ def match(self, buf):
540540
buf[3] == 0x50)
541541

542542

543+
class Elf(Type):
544+
"""
545+
Implements the Elf archive type matcher
546+
"""
547+
MIME = 'application/x-executable'
548+
EXTENSION = 'elf'
549+
550+
def __init__(self):
551+
super(Elf, self).__init__(
552+
mime=Elf.MIME,
553+
extension=Elf.EXTENSION
554+
)
555+
556+
def match(self, buf):
557+
return (len(buf) > 52 and
558+
buf[0] == 0x7F and
559+
buf[1] == 0x45 and
560+
buf[2] == 0x4C and
561+
buf[3] == 0x46)
562+
563+
543564
class Lz4(Type):
544565
"""
545566
Implements the Lz4 archive type matcher.

0 commit comments

Comments
 (0)