mirror of
https://github.com/horsicq/Detect-It-Easy.git
synced 2026-06-24 01:54:08 +00:00
44 lines
1.2 KiB
Text
44 lines
1.2 KiB
Text
// Common routines for handling archives.
|
|
|
|
init("archive");
|
|
|
|
var Archive = {
|
|
nFiles: 0, // number of files in archive
|
|
nDirs: 0, // number of directories in archive
|
|
nSize: 0, // total unpacked size of all files
|
|
nPacked: 0, // total packed size of all files
|
|
|
|
// Add an entry, updating the counts and sizes.
|
|
add: function(nSize,nPacked,bDir)
|
|
{
|
|
if(bDir)
|
|
{
|
|
this.nDirs++;
|
|
}
|
|
else
|
|
{
|
|
this.nFiles++;
|
|
this.nSize+=nSize;
|
|
this.nPacked+=nPacked;
|
|
}
|
|
},
|
|
|
|
// Return the contents according to what was found - "P%,F files,D dirs".
|
|
contents: function()
|
|
{
|
|
var sContents="";
|
|
if(this.nSize!=0)
|
|
{
|
|
sContents=(this.nPacked/this.nSize*100).toFixed(1)+"%";
|
|
}
|
|
if(this.nFiles!=0)
|
|
{
|
|
sContents=sContents.append(this.nFiles+(this.nFiles==1?" file":" files"));
|
|
}
|
|
if(this.nDirs!=0)
|
|
{
|
|
sContents=sContents.append(this.nDirs+(this.nDirs==1?" dir":" dirs"));
|
|
}
|
|
return sContents;
|
|
}
|
|
}
|