Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Mach-O #615

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions core.d.ts
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
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
Expand Up @@ -52,6 +52,7 @@
"is",
"exif",
"elf",
"macho",
"exe",
"binary",
"buffer",
Expand Down
1 change: 1 addition & 0 deletions readme.md
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
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