Skip to content

Commit

Permalink
Add support for Mach-O (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLinCool authored Nov 1, 2023
1 parent dc2a832 commit ec4980b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export type FileExtension =
| 'epub'
| 'mobi'
| 'elf'
| 'macho'
| 'exe'
| 'swf'
| 'rtf'
Expand Down Expand Up @@ -209,6 +210,7 @@ export type MimeType =
| 'audio/amr'
| 'application/pdf'
| 'application/x-elf'
| 'application/x-mach-binary'
| 'application/x-msdownload'
| 'application/x-shockwave-flash'
| 'application/rtf'
Expand Down
7 changes: 7 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,13 @@ class FileTypeParser {
};
}

if (this.check([0xCF, 0xFA, 0xED, 0xFE])) {
return {
ext: 'macho',
mime: 'application/x-mach-binary',
};
}

// -- 5-byte signatures --

if (this.check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
Expand Down
Binary file added fixture/fixture.macho
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"is",
"exif",
"elf",
"macho",
"exe",
"binary",
"buffer",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ Returns a `Set<string>` of supported MIME types.
- [`m4b`](https://en.wikipedia.org/wiki/M4B) - Audiobook and podcast MPEG-4 files, which also contain metadata including chapter markers, images, and hyperlinks
- [`m4p`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions) - MPEG-4 files with audio streams encrypted by FairPlay Digital Rights Management as were sold through the iTunes Store
- [`m4v`](https://en.wikipedia.org/wiki/M4V) - Video container format developed by Apple, which is very similar to the MP4 format
- [`macho`](https://en.wikipedia.org/wiki/Mach-O) - Mach-O binary format
- [`mid`](https://en.wikipedia.org/wiki/MIDI) - Musical Instrument Digital Interface file
- [`mie`](https://en.wikipedia.org/wiki/Sidecar_file) - Dedicated meta information format which supports storage of binary as well as textual meta information
- [`mj2`](https://en.wikipedia.org/wiki/Motion_JPEG_2000) - Motion JPEG 2000
Expand Down
2 changes: 2 additions & 0 deletions supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const extensions = [
'pdf',
'epub',
'elf',
'macho',
'exe',
'swf',
'rtf',
Expand Down Expand Up @@ -206,6 +207,7 @@ export const mimeTypes = [
'audio/amr',
'application/pdf',
'application/x-elf',
'application/x-mach-binary',
'application/x-msdownload',
'application/x-shockwave-flash',
'application/rtf',
Expand Down

0 comments on commit ec4980b

Please sign in to comment.