mirror of
https://github.com/horsicq/Detect-It-Easy.git
synced 2026-06-24 01:54:08 +00:00
Update file(s): 2023-10-17
This commit is contained in:
parent
b39c20d81e
commit
63dee17ada
4 changed files with 689 additions and 584 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,61 +1,61 @@
|
|||
// https://github.com/horsicq/Detect-It-Easy signature file
|
||||
// Author: Kaens TG@kaens
|
||||
|
||||
init("audio","Next/SUN Au waveform audio (.AU,.SND)");
|
||||
includeScript("read");
|
||||
|
||||
function detect(bShowType,bShowVersion,bShowOptions) {
|
||||
|
||||
//ref https://en.wikipedia.org/wiki/Au_file_format
|
||||
// & https://sox.sourceforge.net/AudioFormats-11.html#ss11.2
|
||||
// & http://soundfile.sapp.org/doc/NextFormat/soundstruct.h
|
||||
// & https://sox.sourceforge.net/AudioFormats-11.html
|
||||
if(!Binary.compare("'.snd'")) return false; malformed = 0;
|
||||
_log(" 1" );
|
||||
dataofs = File.read_uint32(4,_BE);
|
||||
_log(Hex(dataofs));
|
||||
if(dataofs<0x18 || dataofs>File.getSize()) return false;
|
||||
if(dataofs<0x1C) malformed = "dtofs="+Hex(dataofs);
|
||||
_log(" 2");
|
||||
datasz = File.read_uint32(8,_BE);
|
||||
if(datasz != 0xFFFFFFFF && datasz > File.getSize()) malformed = "dtsz="+Hex(datasz);
|
||||
bDetected = 1;
|
||||
switch(File.read_int32(0x0C,_BE)) {
|
||||
case 0x00: sVersion = "unspecified format"; break;
|
||||
case 0x01: sVersion = "8-bit G.711 μ-law"; break;
|
||||
case 0x02: sVersion = "8-bit linear PCM"; break;
|
||||
case 0x03: sVersion = "16-bit linear PCM"; break;
|
||||
case 0x04: sVersion = "24-bit linear PCM"; break;
|
||||
case 0x05: sVersion = "32-bit linear PCM"; break;
|
||||
case 0x06: sVersion = "32-bit IEEE floating point"; break;
|
||||
case 0x07: sVersion = "64-bit IEEE floating point"; break;
|
||||
case 0x08: sVersion = "Fragmented sample data"; break;
|
||||
case 0x0A: sVersion = "DSP program"; break;
|
||||
case 0x0B: sVersion = "8-bit fixed point"; break;
|
||||
case 0x0C: sVersion = "16-bit fixed point"; break;
|
||||
case 0x0D: sVersion = "24-bit fixed point"; break;
|
||||
case 0x0E: sVersion = "32-bit fixed point"; break;
|
||||
case 0x10: sVersion = "Sound Kit's visual data"; break;
|
||||
case 0x11: sVersion = "MULAW_SQUELCH"; break;
|
||||
case 0x12: sVersion = "16-bit linear w/emphasis"; break;
|
||||
case 0x13: sVersion = "16-bit linear compressed"; break;
|
||||
case 0x14: sVersion = "16-bit linear w/emphasis compressed"; break;
|
||||
case 0x15: sVersion = "Music Kit DSP commands"; break;
|
||||
case 0x17: sVersion = "ITU-T G.721 4-bit ADPCM"; break;
|
||||
case 0x18: sVersion = "ITU-T G.722 4-bit SB-ADPCM"; break;
|
||||
case 0x19: sVersion = "ITU-T G.723 3-bit SB-ADPCM"; break;
|
||||
case 0x1A: sVersion = "ITU-T G.723 5-bit SB-ADPCM"; break;
|
||||
case 0x1B: sVersion = "8-bit G.711 A-law"; break;
|
||||
case 0x1B: sVersion = "AES"; break;
|
||||
case 0x1C: sVersion = "8-bit Delta μ-law"; break;
|
||||
default: sVersion = "unknown"
|
||||
}
|
||||
if(malformed) sVersion += ", malformed "+malformed;
|
||||
if(Binary.isVerbose()) {
|
||||
sr = (File.read_uint32(0x10,_BE)/1000).toFixed(1); ch = File.read_uint32(0x14,_BE);
|
||||
if(dataofs >= 0x1C) sOption(File.read_ansiString(0x18,Math.min(File.getSize()-0x18,0x100)));
|
||||
sOption("ch:"+ch+" s/r:"+sr+"kHz");
|
||||
}
|
||||
|
||||
return result(bShowType,bShowVersion,bShowOptions);
|
||||
}
|
||||
// https://github.com/horsicq/Detect-It-Easy signature file
|
||||
// Author: Kaens TG@kaens
|
||||
|
||||
init("audio","Next/SUN Au waveform audio (.AU,.SND)");
|
||||
includeScript("read");
|
||||
|
||||
function detect(bShowType,bShowVersion,bShowOptions) {
|
||||
|
||||
//ref https://en.wikipedia.org/wiki/Au_file_format
|
||||
// & https://sox.sourceforge.net/AudioFormats-11.html#ss11.2
|
||||
// & http://soundfile.sapp.org/doc/NextFormat/soundstruct.h
|
||||
// & https://sox.sourceforge.net/AudioFormats-11.html
|
||||
if(!Binary.compare("'.snd'")) return false; malformed = 0;
|
||||
_log(" 1" );
|
||||
dataofs = File.read_uint32(4,_BE);
|
||||
_log(Hex(dataofs));
|
||||
if(dataofs<0x18 || dataofs>File.getSize()) return false;
|
||||
if(dataofs<0x1C) malformed = "dtofs="+Hex(dataofs);
|
||||
_log(" 2");
|
||||
datasz = File.read_uint32(8,_BE);
|
||||
if(datasz != 0xFFFFFFFF && datasz > File.getSize()) malformed = "dtsz="+Hex(datasz);
|
||||
bDetected = 1;
|
||||
switch(File.read_int32(0x0C,_BE)) {
|
||||
case 0x00: sVersion = "unspecified format"; break;
|
||||
case 0x01: sVersion = "8-bit G.711 μ-law"; break;
|
||||
case 0x02: sVersion = "8-bit linear PCM"; break;
|
||||
case 0x03: sVersion = "16-bit linear PCM"; break;
|
||||
case 0x04: sVersion = "24-bit linear PCM"; break;
|
||||
case 0x05: sVersion = "32-bit linear PCM"; break;
|
||||
case 0x06: sVersion = "32-bit IEEE floating point"; break;
|
||||
case 0x07: sVersion = "64-bit IEEE floating point"; break;
|
||||
case 0x08: sVersion = "Fragmented sample data"; break;
|
||||
case 0x0A: sVersion = "DSP program"; break;
|
||||
case 0x0B: sVersion = "8-bit fixed point"; break;
|
||||
case 0x0C: sVersion = "16-bit fixed point"; break;
|
||||
case 0x0D: sVersion = "24-bit fixed point"; break;
|
||||
case 0x0E: sVersion = "32-bit fixed point"; break;
|
||||
case 0x10: sVersion = "Sound Kit's visual data"; break;
|
||||
case 0x11: sVersion = "MULAW_SQUELCH"; break;
|
||||
case 0x12: sVersion = "16-bit linear w/emphasis"; break;
|
||||
case 0x13: sVersion = "16-bit linear compressed"; break;
|
||||
case 0x14: sVersion = "16-bit linear w/emphasis compressed"; break;
|
||||
case 0x15: sVersion = "Music Kit DSP commands"; break;
|
||||
case 0x17: sVersion = "ITU-T G.721 4-bit ADPCM"; break;
|
||||
case 0x18: sVersion = "ITU-T G.722 4-bit SB-ADPCM"; break;
|
||||
case 0x19: sVersion = "ITU-T G.723 3-bit SB-ADPCM"; break;
|
||||
case 0x1A: sVersion = "ITU-T G.723 5-bit SB-ADPCM"; break;
|
||||
case 0x1B: sVersion = "8-bit G.711 A-law"; break;
|
||||
case 0x1B: sVersion = "AES"; break;
|
||||
case 0x1C: sVersion = "8-bit Delta μ-law"; break;
|
||||
default: sVersion = "unknown"
|
||||
}
|
||||
if(malformed) sVersion += ", malformed "+malformed;
|
||||
if(Binary.isVerbose()) {
|
||||
sr = (File.read_uint32(0x10,_BE)/1000).toFixed(1); ch = File.read_uint32(0x14,_BE);
|
||||
if(dataofs >= 0x1C) sOption(File.read_ansiString(0x18,Math.min(File.getSize()-0x18,0x100)));
|
||||
sOption("ch:"+ch+" s/r:"+sr+"kHz");
|
||||
}
|
||||
|
||||
return result(bShowType,bShowVersion,bShowOptions);
|
||||
}
|
||||
|
|
|
|||
370
db/read
370
db/read
|
|
@ -1,176 +1,194 @@
|
|||
// Supplemental read functions.
|
||||
// Authors: unknown guy, Kaens (TG @kaens)
|
||||
// Lots of legacy,
|
||||
// TODO update the old scripts to use the new functions,
|
||||
// and get rid of the functions themselves
|
||||
|
||||
const _BE = true; const _LE = false; //endianness for read_uint16+
|
||||
//little-endian = reversed notation (Intel),
|
||||
//big-endian = direct notation (TCP/IP, Motorola, Amiga, ZX Spectrum)
|
||||
|
||||
// ---------- START OF PRE-v3.06 CODE --------------------
|
||||
|
||||
/**
|
||||
* Read a big-endian word.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @returns {UShort} The word value.
|
||||
* @alias Binary.readBEWord
|
||||
*/
|
||||
File.readBEWord = function(nOffset)
|
||||
{
|
||||
return File.read_uint16(nOffset,_BE)
|
||||
// return (File.readByte(nOffset) << 8) + File.readByte(nOffset+1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a big-endian dword.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @returns {UInt} The dword value.
|
||||
* @alias Binary.readBEDword
|
||||
*/
|
||||
File.readBEDword = function(nOffset)
|
||||
{
|
||||
return File.read_uint32(nOffset,_BE)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a word, selecting endianness.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @param {Bool} bBE - True for big-endian.
|
||||
* @returns {UShort} The word value.
|
||||
* @alias Binary.readEWord
|
||||
*/
|
||||
File.readEWord = function(nOffset,bBE)
|
||||
{
|
||||
return File.read_uint16(nOffset,bBE)
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a dword, selecting endianness.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @param {Bool} bBE - True for big-endian.
|
||||
* @returns {UInt} The dword value.
|
||||
* @alias Binary.readEDWord
|
||||
*/
|
||||
File.readEDword = function(nOffset,bBE)
|
||||
{
|
||||
return File.read_uint16(nOffset,bBE)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a short (signed 16-bit) value.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @returns {Short} The short value.
|
||||
* @alias Binary.readShort
|
||||
*/
|
||||
File.readShort = function(nOffset)
|
||||
{
|
||||
return File.read_int16(nOffset,_LE)
|
||||
}
|
||||
|
||||
|
||||
// -------- END OF PRE-v3.06 CODE
|
||||
|
||||
const CP437="ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛"+
|
||||
"┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";
|
||||
const JISX0201="→-‚ƒ„…†‡ˆ‰Š‹Œ↑޳™‘’“”•–—˜™š›œ¢žŸ"+//decided to mix it with cp1252
|
||||
"→。「」、・ヲァィゥェォャュョッーアイウエカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚"+
|
||||
"àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
|
||||
|
||||
/**
|
||||
* Derive a string hexadecimal value, zero-padded.
|
||||
* @param {Int} a - the numerical value.
|
||||
* @param {UInt} padz (optional,default=2) - how many characters to zero-pad.
|
||||
* @returns {String} The hex value, capital letters A~F, ending with "h".
|
||||
*/
|
||||
function Hex(a,padz) {
|
||||
if(padz==undefined) padz=2;
|
||||
var minus=""; if(a<0) { a=-a; minus="-" }
|
||||
var r = a.toString(16).toUpperCase(); var pads="";
|
||||
if(r.length < padz) pads = Array(1 + padz - r.length).join('0');
|
||||
return minus+pads+r+"h"
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a byte array from file.
|
||||
* @param {UInt} ofs - the offset to start from.
|
||||
* @param {ByteArray} len - the amount of bytes to read.
|
||||
* @returns {[uint8]} The file slice. If you go beyond EoF, read_uint8 only knows what happens.
|
||||
*/
|
||||
function readBytes(ofs,len) { //for now; feels like this should be a system function
|
||||
var s=[];
|
||||
for (i=0;i<len;i++) s.push(File.read_uint8(ofs+i));
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a 1-byte encoding from a byte array using the 128-byte-long table given.
|
||||
* @param {[uint8]} ansi - an array returned by readBytes.
|
||||
* @param {String[0x80]} dectbl - a decoding table; just make a const here in db/read for that
|
||||
* @param {bool} zstop (optional, default=true) - whether to stop reading on 0 (ASCIIZ behaviour)
|
||||
* @returns {String} a string value usable with js.
|
||||
*/
|
||||
function decEncoding(ansi,dectbl,zstop) {
|
||||
if(zstop==undefined) zstop=true;
|
||||
var s=""; var bit8=0;
|
||||
for(i=0; i<ansi.length; i++)
|
||||
if ((ansi[i]==0) && zstop) break; else
|
||||
if(ansi[i] < 0x80)
|
||||
switch(ansi[i]) { // 7-bit variation processing
|
||||
case 0x0E: if(dectbl == "JISX0201") bit8=0x80; break;
|
||||
case 0x0F: if(dectbl == "JISX0201") bit8=0; break;
|
||||
case 0x5C: if(dectbl == "JISX0201") s+="¥"; break;
|
||||
case 0x7E: if(dectbl == "JISX0201") s+="‾"; break;
|
||||
default: s += String.fromCharCode(bit8+ansi[i]);
|
||||
}
|
||||
else s+=dectbl[ansi[i]-0x80];
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a 1-byte encoding from file using the 128-byte-long table given.
|
||||
* @param {UInt} ofs - the offset to start from.
|
||||
* @param {ByteArray} len - the amount of bytes to read.
|
||||
* @param {String[0x80]} dectbl - a decoding table; just make a const here in db/read for that
|
||||
* @param {bool} zstop (optional, default=true) - whether to stop reading on 0 (ASCIIZ behaviour)
|
||||
* @returns {String} a string value usable with js.
|
||||
*/
|
||||
function decAnsi(ofs,len,dectbl,zstop) {
|
||||
var s="";
|
||||
if(zstop==undefined) zstop=true;
|
||||
for (i=0;i<len;i++) {
|
||||
b = Binary.read_uint8(ofs+i);
|
||||
if ((b==0) && zstop) break; else
|
||||
if(b < 0x80) s+=String.fromCharCode(b);
|
||||
else s+=dectbl[b-0x80];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* sOptions.append a string (optionally prefixed) if the space-trimmed string is not empty.
|
||||
* @param {variant} a - the string to output (safe to accidentally drop a non-string in)
|
||||
* @param {String} prefix (optional) - what to put in front of the output string
|
||||
*/
|
||||
function sOptionT(a,prefix) { if ((""+a).trim() != "")
|
||||
if(prefix != undefined) sOptions = sOptions.append(prefix+a.trim())
|
||||
else sOptions = sOptions.append((""+a).trim()) }
|
||||
|
||||
/**
|
||||
* sOptions.append a string (optionally prefixed) if the string is not empty.
|
||||
* @param {variant} a - the string to output (safe to accidentally drop a non-string in)
|
||||
* @param {String} prefix (optional) - what to put in front of the output string
|
||||
*/
|
||||
function sOption(a,prefix) { if ((""+a) != "")
|
||||
if(prefix != undefined) sOptions = sOptions.append(prefix+a)
|
||||
else sOptions = sOptions.append(""+a) }
|
||||
|
||||
/**
|
||||
* A shorthand for the situation where you compare the file suffix to what you'd expect. Use as the option to isHeuristicScan being true.
|
||||
* @param {String} a - the expected file suffix, case-insensitive, no heading period unlike Python
|
||||
* @returns {bool} if a match is reached
|
||||
*/
|
||||
function extIs(a) { return Binary.getFileSuffix().toLowerCase() == a.toLowerCase() }
|
||||
|
||||
// Supplemental read functions.
|
||||
// Authors: unknown guy, Kaens (TG @kaens)
|
||||
// Lots of legacy,
|
||||
// TODO update the old scripts to use the new functions,
|
||||
// and get rid of the functions themselves
|
||||
|
||||
const _BE = true; const _LE = false; //endianness for read_uint16+
|
||||
//little-endian = reversed notation (Intel),
|
||||
//big-endian = direct notation (TCP/IP, Motorola, Amiga, ZX Spectrum)
|
||||
|
||||
const TOEOF = -1; //use for the size parameter in findSignature
|
||||
|
||||
// ---------- START OF PRE-v3.06 CODE --------------------
|
||||
|
||||
/**
|
||||
* Read a big-endian word.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @returns {UShort} The word value.
|
||||
* @alias Binary.readBEWord
|
||||
*/
|
||||
File.readBEWord = function(nOffset)
|
||||
{
|
||||
return File.read_uint16(nOffset,_BE)
|
||||
// return (File.readByte(nOffset) << 8) + File.readByte(nOffset+1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a big-endian dword.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @returns {UInt} The dword value.
|
||||
* @alias Binary.readBEDword
|
||||
*/
|
||||
File.readBEDword = function(nOffset)
|
||||
{
|
||||
return File.read_uint32(nOffset,_BE)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a word, selecting endianness.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @param {Bool} bBE - True for big-endian.
|
||||
* @returns {UShort} The word value.
|
||||
* @alias Binary.readEWord
|
||||
*/
|
||||
File.readEWord = function(nOffset,bBE)
|
||||
{
|
||||
return File.read_uint16(nOffset,bBE)
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a dword, selecting endianness.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @param {Bool} bBE - True for big-endian.
|
||||
* @returns {UInt} The dword value.
|
||||
* @alias Binary.readEDWord
|
||||
*/
|
||||
File.readEDword = function(nOffset,bBE)
|
||||
{
|
||||
return File.read_uint16(nOffset,bBE)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read a short (signed 16-bit) value.
|
||||
* @param {UInt} nOffset - The offset in the file.
|
||||
* @returns {Short} The short value.
|
||||
* @alias Binary.readShort
|
||||
*/
|
||||
File.readShort = function(nOffset)
|
||||
{
|
||||
return File.read_int16(nOffset,_LE)
|
||||
}
|
||||
|
||||
|
||||
// -------- END OF PRE-v3.06 CODE
|
||||
|
||||
const CP437="ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛"+
|
||||
"┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ";
|
||||
const JISX0201="→-‚ƒ„…†‡ˆ‰Š‹Œ↑޳™‘’“”•–—˜™š›œ¢žŸ"+//decided to mix it with cp1252
|
||||
"→。「」、・ヲァィゥェォャュョッーアイウエカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚"+
|
||||
"àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
|
||||
|
||||
/**
|
||||
* Derive a string hexadecimal value, zero-padded.
|
||||
* @param {Int} a - the numerical value.
|
||||
* @param {UInt} padz (optional,default=2) - how many characters to zero-pad.
|
||||
* @returns {String} The hex value, capital letters A~F, ending with "h".
|
||||
*/
|
||||
function Hex(a,padz) {
|
||||
if(padz==undefined) padz=2;
|
||||
var minus=""; if(a<0) { a=-a; minus="-" }
|
||||
var r = a.toString(16).toUpperCase(); var pads="";
|
||||
if(r.length < padz) pads = Array(1 + padz - r.length).join('0');
|
||||
return minus+pads+r+"h"
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a byte array from file.
|
||||
* @param {UInt} ofs - the offset to start from.
|
||||
* @param {ByteArray} len - the amount of bytes to read.
|
||||
* @returns {[uint8]} The file slice. If you go beyond EoF, read_uint8 only knows what happens.
|
||||
*/
|
||||
function readBytes(ofs,len) { //for now; feels like this should be a system function
|
||||
var s=[];
|
||||
for (i=0;i<len;i++) s.push(File.read_uint8(ofs+i));
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a 1-byte encoding from a byte array using the 128-byte-long table given.
|
||||
* @param {[uint8]} ansi - an array returned by readBytes.
|
||||
* @param {String[0x80]} dectbl - a decoding table; just make a const here in db/read for that
|
||||
* @param {bool} zstop (optional, default=true) - whether to stop reading on 0 (ASCIIZ behaviour)
|
||||
* @returns {String} a string value usable with js.
|
||||
*/
|
||||
function decEncoding(ansi,dectbl,zstop) {
|
||||
if(zstop==undefined) zstop=true;
|
||||
var s=""; var bit8=0;
|
||||
for(i=0; i<ansi.length; i++)
|
||||
if ((ansi[i]==0) && zstop) break; else
|
||||
if(ansi[i] < 0x80)
|
||||
switch(ansi[i]) { // 7-bit variation processing
|
||||
case 0x0E: if(dectbl == "JISX0201") bit8=0x80; break;
|
||||
case 0x0F: if(dectbl == "JISX0201") bit8=0; break;
|
||||
case 0x5C: if(dectbl == "JISX0201") s+="¥"; break;
|
||||
case 0x7E: if(dectbl == "JISX0201") s+="‾"; break;
|
||||
default: s += String.fromCharCode(bit8+ansi[i]);
|
||||
}
|
||||
else s+=dectbl[ansi[i]-0x80];
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a 1-byte encoding from file using the 128-byte-long table given.
|
||||
* @param {UInt} ofs - the offset to start from.
|
||||
* @param {ByteArray} len - the amount of bytes to read.
|
||||
* @param {String[0x80]} dectbl - a decoding table; just make a const here in db/read for that
|
||||
* @param {bool} zstop (optional, default=true) - whether to stop reading on 0 (ASCIIZ behaviour)
|
||||
* @returns {String} a string value usable with js.
|
||||
*/
|
||||
function decAnsi(ofs,len,dectbl,zstop) {
|
||||
var s="";
|
||||
if(zstop==undefined) zstop=true;
|
||||
for (i=0;i<len;i++) {
|
||||
b = Binary.read_uint8(ofs+i);
|
||||
if ((b==0) && zstop) break; else
|
||||
if(b < 0x80) s+=String.fromCharCode(b);
|
||||
else s+=dectbl[b-0x80];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* sOptions.append a string (optionally prefixed) if the space-trimmed string is not empty.
|
||||
* @param {variant} a - the string to output (safe to accidentally drop a non-string in)
|
||||
* @param {String} prefix (optional) - what to put in front of the output string
|
||||
*/
|
||||
function sOptionT(a,prefix) { if ((""+a).trim() != "")
|
||||
if(prefix != undefined) sOptions = sOptions.append(prefix+a.trim())
|
||||
else sOptions = sOptions.append((""+a).trim()) }
|
||||
|
||||
/**
|
||||
* sOptions.append a string (optionally prefixed) if the string is not empty.
|
||||
* @param {variant} a - the string to output (safe to accidentally drop a non-string in)
|
||||
* @param {String} prefix (optional) - what to put in front of the output string
|
||||
*/
|
||||
function sOption(a,prefix) { if ((""+a) != "")
|
||||
if(prefix != undefined) sOptions = sOptions.append(prefix+a)
|
||||
else sOptions = sOptions.append(""+a) }
|
||||
|
||||
/**
|
||||
* A shorthand for the situation where you compare the file suffix to what you'd expect. Use as the option to isHeuristicScan being true.
|
||||
* @param {String} a - the expected file suffix, case-insensitive, no heading period unlike Python
|
||||
* @returns {bool} if a match is reached
|
||||
*/
|
||||
function extIs(a) { return Binary.getFileSuffix().toLowerCase() == a.toLowerCase() }
|
||||
|
||||
/**
|
||||
* slashTag formats a string in a way that's useful when a tag has two versions (for ex. in different languages). It will either show both with "/" in between, or one of them if the other one's an empty string, or an empty string if both are empty.
|
||||
* @param {String} a - the first of the two
|
||||
* @param {String} b - the second of the two
|
||||
* @returns {String}
|
||||
*/
|
||||
function slashTag(a,b) {
|
||||
if(a == b) return a;
|
||||
else if(a != "" && b == "")
|
||||
return a;
|
||||
else if(a == "" && b != "")
|
||||
return b;
|
||||
else if(a != "" && b != "")
|
||||
return a+"/"+b;
|
||||
else return ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,16 +8,18 @@ die [FileName] or diec [FileName] or diel [FileName]
|
|||
|
||||
### Portable version on Linux
|
||||
|
||||
Download an appImage file https://github.com/horsicq/DIE-engine/releases/download/3.09/Detect_It_Easy-3.09-x86_64.AppImage
|
||||
|
||||
Make the file executable
|
||||
|
||||
```bash
|
||||
chmod +x Detect_It_Easy-3.08-x86_64.AppImage
|
||||
chmod +x Detect_It_Easy-3.09-x86_64.AppImage
|
||||
```
|
||||
|
||||
Run it
|
||||
|
||||
```bash
|
||||
./Detect_It_Easy-3.08-x86_64.AppImage
|
||||
./Detect_It_Easy-3.09-x86_64.AppImage
|
||||
```
|
||||
|
||||
### Run with Docker
|
||||
|
|
@ -26,4 +28,4 @@ Here's how to use DIE with Docker:
|
|||
|
||||
```bash
|
||||
docker/diec.sh [FileName]
|
||||
```
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue