Skip to content

Commit c118951

Browse files
committed
Added support for elf
1 parent c26baf8 commit c118951

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
@@ -77,6 +77,7 @@
7777
archive.Ar(),
7878
archive.Z(),
7979
archive.Lz(),
80+
archive.Elf(),
8081
)
8182

8283
# Expose supported type matchers

filetype/types/archive.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,3 +513,24 @@ def match(self, buf):
513513
buf[1] == 0x5A and
514514
buf[2] == 0x49 and
515515
buf[3] == 0x50)
516+
517+
518+
class Elf(Type):
519+
"""
520+
Implements the Elf archive type matcher
521+
"""
522+
MIME = 'application/x-executable'
523+
EXTENSION = 'elf'
524+
525+
def __init__(self):
526+
super(Elf, self).__init__(
527+
mime=Elf.MIME,
528+
extension=Elf.EXTENSION
529+
)
530+
531+
def match(self, buf):
532+
return (len(buf) > 52 and
533+
buf[0] == 0x7F and
534+
buf[1] == 0x45 and
535+
buf[2] == 0x4C and
536+
buf[3] == 0x46)

0 commit comments

Comments
 (0)