On 11/29/17, deepthaw said the following...
Poking through the data structures, I see that it's not too hard to extract how many times each file has been downloaded (as in, it's literally just an integer in the record.)
Is there already a door or other utility that will generate reports
based on that? I'm not opposed to rolling my own, but just want to check before I duplicate effort.
Try this. It's been a while since I tried it. You may need to update the RecFileList structure from the records.112 file if it doesn't work.
-----------8<------------------
Uses Cfg
Uses FBase
Const MaxList = 11
Type
RecFileList = Record
FileName : String[70];
Size : LongInt;
DatTim : LongInt;
Uploader : String[30];
Flags : Byte;
Downloads : LongInt;
Rating : Byte;
DescPtr : LongInt;
DescLines : Byte;
End;
Type
RecTopTen = Record
FileName : String[70]
Downloads: LongInt;
End
Var FileInfo : RecFileList
Var TopTen : Array [1..MaxList] of RecTopTen
Var TTI : Byte = 0
Procedure Insert2TT(FN:String;DL:LongInt)
Var L,X : Byte
Var TT : RecTopTen
Begin
TopTen[MaxList].FileName:=FN
TopTen[MaxList].DownLoads:=DL
For L:=1 To MaxList-1 Do Begin
For X:=1 To maxList-1 Do Begin
If TopTen[X+1].DownLoads> TopTen[X].DownLoads Then Begin
TT:=TopTen[X]
TopTen[X]:=TopTen[X+1]
TopTen[X+1]:=TT
End
End
End
End
Function ReadDirEntry(FN:String;I:Integer):Boolean
Var Fp : File
Var Dir : String
Var Ret : Boolean = False
Begin
Dir:=CfgDataPath+FN+'.dir'
fAssign(Fp,Dir,66)
fReset(Fp)
If IoResult = 0 Then Begin
fSeek(Fp,(I-1)*SizeOf(FileInfo))
If Not fEof(Fp) Then Begin
fRead(Fp,FileInfo,SizeOf(FileInfo))
Ret:=True
End
fClose(Fp)
End
ReadDirEntry:=Ret
End
Procedure ReadDLs
Var I,D : Integer = 1
Begin
D:=1
While GetFBase(D) Do Begin
I:=1
While ReadDirEntry(FBaseFN,I) Do Begin
Insert2TT(FileInfo.FileName,FileInfo.Downloads)
I:=I+1
End
D:=D+1
End
End
Procedure Main
Var I : Integer
Begin
ClrScr
ReadDLs
For I:=1 To MaxList-1 Do Begin
WriteLn(PadRt(TopTen[I].FileName,25,' ')+' '+Int2Str(TopTen[I].Downloads))
End
pause
End
Procedure Init
Var I : Byte
Begin
For I:=1 To MaxList-1 Do Begin
TopTen[I].FileName:=''
TopTen[I].Downloads:=0
End
TTI:=0
End
Begin
Init
Main
End
--- Mystic BBS v1.12 A35 (Linux/64)
* Origin: Cyberia BBS | cyberia.darktech.org | San Jose, CA (21:1/120)