mirror of
https://github.com/codedread/bitjs
synced 2025-10-03 09:39:16 +02:00
Use the file sniffer inside archive.js
This commit is contained in:
parent
1570f058f8
commit
60a6bf405c
2 changed files with 6 additions and 6 deletions
|
@ -8,6 +8,8 @@
|
|||
* Copyright(c) 2011 Google Inc.
|
||||
*/
|
||||
|
||||
import { findMimeType } from '../file/sniffer.js';
|
||||
|
||||
/**
|
||||
* An unarchive event.
|
||||
*/
|
||||
|
@ -381,12 +383,10 @@ export function getUnarchiver(ab, opt_pathToBitJS) {
|
|||
|
||||
let unarchiver = null;
|
||||
const pathToBitJS = opt_pathToBitJS || '';
|
||||
const h = new Uint8Array(ab, 0, 10);
|
||||
|
||||
// TODO: Use bitjs.file.sniffer.
|
||||
if (h[0] == 0x52 && h[1] == 0x61 && h[2] == 0x72 && h[3] == 0x21) { // Rar!
|
||||
const mimeType = findMimeType(ab);
|
||||
if (mimeType === 'application/x-rar-compressed') { // Rar!
|
||||
unarchiver = new Unrarrer(ab, pathToBitJS);
|
||||
} else if (h[0] == 0x50 && h[1] == 0x4B) { // PK (Zip)
|
||||
} else if (mimetype === 'application/zip') { // PK (Zip)
|
||||
unarchiver = new Unzipper(ab, pathToBitJS);
|
||||
} else { // Try with tar
|
||||
unarchiver = new Untarrer(ab, pathToBitJS);
|
||||
|
|
|
@ -88,4 +88,4 @@ export function findMimeType(ab) {
|
|||
curNode = curNode.children[byte];
|
||||
if (curNode.mimeType) return curNode.mimeType;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue