Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commits (1)
  • Rob Swindell's avatar
    Replace the guts of OldFileBase to make it v3.19 compatible · ea1d2248
    Rob Swindell authored
    This appears to be enough to make hatchit.js work again and file
    listings in webv4 (not sure beyond that).
    
    This file is now just an unnecessary shim and should go away when
    the consumers (hatchit and webv4) no longer need it.
    
    I did not "port" support for the file properties:
    - base
    - ext
    - datoffset
    - opencount
    - misc
    - altpath
    
    They don't appear to be needed.
    ea1d2248
/*
* Pass a directory code and get back an array of objects for the files
* in the specified directory.
*
* This is file is now just an unnecessary shim for the new FileBase class
* and should be deprecated.
*
* Similar to filedir.js.
*
......@@ -8,122 +11,46 @@
*
* base: Base filename.
* ext: Filename extension.
* datoffset: Offset in .dat file of file data.
* datoffset: Offset in .dat file of file data. - N/A
* uldate: Date uploaded
* dldate: Date downloaded(?)
* credits: Number of credits(?)
* desc: Short description (58 chars max)
* uploader: Name of user that uploaded the file.
* downloaded: Number of times the file has been downloaded.
* opencount: I have no idea what this is.
* misc: Misc flags... see FM_* below.
* opencount: I have no idea what this is. - N/A
* misc: Misc flags... see FM_* below. - N/A
* anonymous: Anonymous upload
* altpath: Index into the internal array of alt paths (not visible to JavaScript)
* altpath: Index into the internal array of alt paths (not visible to JavaScript) - N/A
* extdesc: May be undefined... extended description.
* path: Full path to file. Undefined if the file doesn't exist or
* is in an alt path (since they're not visible to JS).
*/
var FM_EXTDESC = 1;
var FM_ANON = (1<<1);
function OldFileBase(dir) {
var f = new File(format("%s%s.ixb", file_area.dir[dir].data_dir, dir));
var dat = new File(format("%s%s.dat", file_area.dir[dir].data_dir, dir));
var exb = new File(format("%s%s.exb", file_area.dir[dir].data_dir, dir));
var record = null;
var ret = [];
function FileEntry() {
var byte;
function getrec(file, len) {
var ret=file.read(len);
ret = ret.replace(/[\x03\r\n].*$/,'');
return ret;
}
// Read from the IXB file
this.base = f.read(8).replace(/ +$/,'');
this.ext = f.read(3).replace(/ +$/, '');
this.datoffset = f.readBin(2);
byte = f.readBin(1);
this.datoffset |= (byte<<16);
this.uldate = f.readBin(4);
this.dldate = f.readBin(4);
// Read from the DAT file
dat.position = this.datoffset;
this.credits = parseInt(getrec(dat, 9), 10);
this.desc = getrec(dat, 58);
dat.readBin(2); // Should be \r\n
this.uploader = getrec(dat, 25);
dat.read(5); // Padding?
dat.readBin(2); // Should be \r\n
this.downloaded = parseInt(getrec(dat, 5), 10);
dat.readBin(2); // Should be \r\n
this.opencount = parseInt(getrec(dat, 3), 10);
dat.readBin(2); // Should be \r\n
this.misc = getrec(dat, 1);
if (this.misc.length > 0)
this.misc = ascii(this.misc)-32;
else
this.misc = 0;
if (this.misc & FM_ANON)
this.anonymous = true;
else
this.anonymous = false;
this.altpath = parseInt(getrec(dat, 2), 16);
// Read from the EXB file
var exbpos = (this.datoffset / 118) * 512;
if (exb.is_open && (this.misc & FM_EXTDESC)) {
if (exb.length > exbpos) {
exb.position = exbpos;
this.extdesc = exb.read(512).replace(/\x00.*$/, '');
}
}
if (this.altpath > 0 && file_area.alt_paths !== undefined) {
if (file_exists(file_area.alt_paths[this.altpath-1]+this.name))
this.path = fullpath(file_area.alt_paths[this.altpath-1]+this.name);
}
else {
if (file_exists(file_area.dir[dir].path+this.name))
this.path = fullpath(file_area.dir[dir].path+this.name);
}
}
Object.defineProperty(FileEntry.prototype, "name", {
enumerable: true,
get: function() {
return this.ext ? this.base+'.'+this.ext : this.base;
}
});
if(!f.exists)
return ret;
if (!f.open("rb"))
var filebase = new FileBase(dir);
if(!filebase.open())
return ret;
if(!dat.exists) {
f.close();
log(LOG_DEBUG, "readIxb: Invalid code or "+dat.name+" does not exist.");
return ret;
var file_list = filebase.get_list(FileBase.DETAIL.EXTENDED);
for(var i = 0; i < file_list.length; i++) {
var file = file_list[i];
ret.push({
name: file.name,
uldate: file.added,
dldate: file.last_downloaded,
credits: file.cost,
desc: file.desc,
uploader: file.from,
downloaded: file.times_downloaded,
extdesc: file.extdesc,
anonymous: file.anon,
path: filebase.get_path(file.name)
});
}
if (!dat.open("rb")) {
log(LOG_DEBUG, "readIxb: Unable to open "+dat.name+".");
return ret;
}
exb.open("rb");
for(var i = 0; f.position+1<f.length ; i++)
ret.push(new FileEntry(i));
f.close();
dat.close();
if (exb.is_open)
exb.close();
filebase.close();
return ret;
}