DiskDump improvements (eg, don't put .img files inside other .img files)

This commit is contained in:
Jeff Parsons 2015-06-10 17:01:21 -07:00
commit 7bb42d5ab6
2 changed files with 20 additions and 7 deletions

View file

@ -109,7 +109,7 @@ function DiskDump(sDiskPath, asExclude, sFormat, fComments, mbHD, sServerRoot, s
*/
this.sServerRoot = sServerRoot;
this.sDiskPath = (net.isRemote(sDiskPath)? sDiskPath : path.join(this.sServerRoot, sDiskPath));
this.asExclude = asExclude;
this.asExclude = asExclude || DiskDump.asExclusions;
this.mbHD = mbHD? parseInt(mbHD, 10) : 0;
this.sFormat = (sFormat || DumpAPI.FORMAT.JSON);
this.fJSONNative = (this.sFormat == DumpAPI.FORMAT.JSON && !fComments);
@ -276,6 +276,9 @@ DiskDump.aDefaultBPBs = [
]
];
DiskDump.asExclusions = [".*", ".IMG"];
DiskDump.asTextFileExts = [".MD", ".ME", ".ASM", ".BAS", ".TXT", ".XML"];
/*
* Class methods
*/
@ -788,9 +791,16 @@ DiskDump.readFile = function(sPath, sEncoding, done)
*/
DiskDump.prototype.isExcluded = function(sName)
{
if (this.asExclude) {
for (var i = 0; i < this.asExclude.length; i++) {
if (sName.toUpperCase() == this.asExclude[i].toUpperCase()) return true;
sName = sName.toUpperCase();
for (var i = 0; i < this.asExclude.length; i++) {
var sExclude = this.asExclude[i].toUpperCase();
if (sName == sExclude) return true;
if (sExclude.charAt(0) == '.') {
if (sExclude.charAt(1) == '*') {
if (sName.charAt(0) == '.') return true;
} else {
if (str.endsWith(sName, sExclude)) return true;
}
}
}
return false;
@ -1162,8 +1172,6 @@ DiskDump.prototype.addManifestInfo = function(fileInfo)
this.aManifestInfo.push(fileInfo);
};
DiskDump.asTextFileExts = [".MD", ".ME", ".ASM", ".BAS", ".TXT", ".XML"];
/**
* isTextFile(sFileName)
*

View file

@ -40,7 +40,12 @@ assumed to be a directory, and so PCjs will ask the server to enumerate the cont
JSON-encoded disk image containing all the files in that directory (including any subdirectories).
Since the contents of this directory will probably be in flux for a while, I've opted for this approach. Once
things settle down, I'll generate a JSON-encoded disk image containing a snapshot of this directory.
things settle down, I'll generate a JSON-encoded disk image containing a snapshot of this directory, like so:
diskdump --dir=. --format=img --output=TESTVGA.img
One advantage of using the PCjs [DiskDump](/modules/diskdump/) module is that it automatically converts linefeeds in
known text files (including ASM files) into DOS-compatible CR/LF sequences.
I've updated a [Compaq DeskPro 386 Machine](/devices/pc/machine/compaq/deskpro386/vga/2048kb/) to use the
[Library](/disks/pc/library.xml) disk collection and automatically load the above disk: