Skip to content

Commit f84e96c

Browse files
authored
Add support for cpio (#590)
1 parent 935470e commit f84e96c

8 files changed

Lines changed: 25 additions & 1 deletion

File tree

core.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export type FileExtension =
147147
| 'parquet'
148148
| 'class'
149149
| 'arj'
150+
| 'cpio'
150151
; // eslint-disable-line semi-style
151152

152153
export type MimeType =
@@ -290,6 +291,7 @@ export type MimeType =
290291
| 'application/x-parquet'
291292
| 'application/java-vm'
292293
| 'application/x-arj'
294+
| 'application/x-cpio'
293295
; // eslint-disable-line semi-style
294296

295297
export type FileTypeResult = {

core.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ class FileTypeParser {
149149
};
150150
}
151151

152+
if (this.check([0xC7, 0x71])) {
153+
return {
154+
ext: 'cpio',
155+
mime: 'application/x-cpio',
156+
};
157+
}
158+
152159
if (this.check([0x60, 0xEA])) {
153160
return {
154161
ext: 'arj',
@@ -981,6 +988,13 @@ class FileTypeParser {
981988
}
982989
}
983990

991+
if (this.checkString('070707')) {
992+
return {
993+
ext: 'cpio',
994+
mime: 'application/x-cpio',
995+
};
996+
}
997+
984998
// -- 7-byte signatures --
985999

9861000
if (this.checkString('BLENDER')) {

fixture/fixture-ascii.cpio

512 Bytes
Binary file not shown.

fixture/fixture-bin.cpio

512 Bytes
Binary file not shown.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@
199199
"dwg",
200200
"parquet",
201201
"class",
202-
"arj"
202+
"arj",
203+
"cpio"
203204
],
204205
"dependencies": {
205206
"readable-web-to-node-stream": "^3.0.2",

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ Returns a `Set<string>` of supported MIME types.
366366
- [`cfb`](https://en.wikipedia.org/wiki/Compound_File_Binary_Format) - Compount File Binary Format
367367
- [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help
368368
- [`class`](https://en.wikipedia.org/wiki/Java_class_file) - Java class file
369+
- [`cpio`](https://en.wikipedia.org/wiki/Cpio) - Cpio archive
369370
- [`cr2`](https://fileinfo.com/extension/cr2) - Canon Raw image file (v2)
370371
- [`cr3`](https://fileinfo.com/extension/cr3) - Canon Raw image file (v3)
371372
- [`crx`](https://developer.chrome.com/extensions/crx) - Google Chrome extension

supported.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export const extensions = [
144144
'parquet',
145145
'class',
146146
'arj',
147+
'cpio',
147148
];
148149

149150
export const mimeTypes = [
@@ -287,4 +288,5 @@ export const mimeTypes = [
287288
'application/x-parquet',
288289
'application/java-vm',
289290
'application/x-arj',
291+
'application/x-cpio',
290292
];

test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ const names = {
243243
dwg: [
244244
'fixture-line-weights',
245245
],
246+
cpio: [
247+
'fixture-bin',
248+
'fixture-ascii',
249+
],
246250
};
247251

248252
// Define an entry here only if the file type has potential

0 commit comments

Comments
 (0)