Detect-It-Easy/db/archive-file
DosX 33711a0407 Add standard DiE-JS framework header to db files
Added a standard header comment to all db framework and detection rule files, indicating they are part of the Detect It Easy (DiE-JS) framework and warning against unauthorized changes. This improves consistency and clarifies file purpose for maintainers.
2025-08-27 23:21:24 +03:00

39 lines
No EOL
1.2 KiB
Text

// Detect It Easy: DiE-JS framework file
// Don't change anything unless you're sure about what you're doing
// Common routines for handling archives.
meta("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;
}
}