Skip to content

Latest commit

 

History

History
348 lines (327 loc) · 10.4 KB

file9.pas

File metadata and controls

348 lines (327 loc) · 10.4 KB
 
Nov 18, 2000
Nov 18, 2000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
unit file9;
interface
uses
crt, dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
myio,
file0, file1, file2,
common;
function info:astr;
procedure dir(cd,x:astr; expanded:boolean);
procedure dirf(expanded:boolean);
procedure deleteff(rn:integer; var pl:integer; killverbose:boolean);
procedure remove;
procedure setdirs;
procedure pointdate;
procedure yourfileinfo;
procedure listopts;
implementation
function align2(s:astr):astr;
begin
if pos('.',s)=0 then s:=mln(s,12)
else s:=mln(copy(s,1,pos('.',s)-1),8)+' '+mln(copy(s,pos('.',s)+1,3),3);
align2:=s;
end;
function info:astr;
var pm:char;
i:integer;
s:astr;
dt:datetime;
function ti(i:integer):astr;
var s:astr;
begin
ti:=tch(cstr(i));
end;
begin
s:=dirinfo.name;
if (dirinfo.attr and directory)=directory then s:=mln(s,13)+'<DIR> '
else s:=align2(s)+' '+mrn(cstrl(dirinfo.size),7);
unpacktime(dirinfo.time,dt);
with dt do begin
if hour<13 then pm:='a' else begin pm:='p'; hour:=hour-12; end;
s:=s+' '+mrn(cstr(month),2)+'-'+ti(day)+'-'+ti(year-1900)+
' '+mrn(cstr(hour),2)+':'+ti(min)+pm;
end;
info:=s;
end;
procedure dir(cd,x:astr; expanded:boolean);
var abort,next,nofiles:boolean;
s:astr;
onlin:integer;
dfs:longint;
numfiles:integer;
begin
if (copy(cd,length(cd),1)<>'\') then cd:=cd+'\';
abort:=FALSE;
cd:=cd+x;
if (fso) then begin
printacr(#3#5+' Directory of '+#3#3+copy(cd,1,length(cd)),abort,next);
nl;
end;
s:=''; onlin:=0; numfiles:=0; nofiles:=TRUE;
ffile(cd);
while (found) and (not abort) do begin
if (not (dirinfo.attr and directory=directory)) or (fso) then
if (not (dirinfo.attr and volumeid=volumeid)) then
if ((not (dirinfo.attr and dos.hidden=dos.hidden)) or (usernum=1)) then
if ((dirinfo.attr and dos.hidden=dos.hidden) and
(not (dirinfo.attr and directory=directory))) or
(not (dirinfo.attr and dos.hidden=dos.hidden)) then begin
nofiles:=FALSE;
if (expanded) then printacr(info,abort,next)
else begin
inc(onlin);
s:=s+align2(dirinfo.name);
if onlin<>5 then s:=s+' ' else begin
printacr(s,abort,next);
s:=''; onlin:=0;
end;
end;
inc(numfiles);
end;
nfile;
end;
if (not found) and (onlin in [1..5]) then printacr(s,abort,next);
dfs:=freek(exdrv(cd));
if (nofiles) then s:=#3#3+'Files not found'
else s:=#3#3+mrn(cstr(numfiles)+#3#5+' File(s)',17);
printacr(s+#3#3+mrn(cstrl(dfs*1024),10)+#3#5+' bytes free',abort,next);
end;
procedure dirf(expanded:boolean);
var fspec:astr;
abort,next,all:boolean;
begin
nl;
print('Raw directory.');
gfn(fspec); abort:=FALSE; next:=FALSE;
nl;
loaduboard(fileboard);
dir(memuboard.dlpath,fspec,expanded);
end;
procedure deleteff(rn:integer; var pl:integer; killverbose:boolean);
var i:integer;
f:ulfrec;
v:verbrec;
begin
if (rn<=pl) and (rn>0) then begin
dec(pl);
seek(ulff,rn); read(ulff,f);
if (f.vpointer<>-1) and (killverbose) then begin
assign(verbf,systat.gfilepath+'verbose.dat');
reset(verbf);
seek(verbf,f.vpointer); read(verbf,v);
if (ioresult=0) then begin
v.descr[1]:='';
seek(verbf,f.vpointer); write(verbf,v);
end;
close(verbf);
end;
for i:=rn to pl do begin
seek(ulff,i+1); read(ulff,f);
seek(ulff,i); write(ulff,f);
end;
seek(ulff,0); f.blocks:=pl; write(ulff,f);
end;
end;
procedure remove;
var done,abort,next,subit:boolean;
c:char;
pl,rn:integer;
s,fn:astr;
ff:file;
f:ulfrec;
u:userrec;
begin
nl;
print('Remove files.');
gfn(fn); abort:=FALSE; next:=FALSE;
nl;
recno(fn,pl,rn);
if (baddlpath) then exit;
if (fn='') or (pos('.',fn)=0) or (rn=0) then
print('No matching files.')
else begin
lastcommandovr:=TRUE;
c:=#0;
while (fn<>'') and (rn<>0) and (not abort) and (not hangup) do begin
seek(ulff,rn); read(ulff,f);
reset(uf); seek(uf,f.owner); read(uf,u);
if (rn<>0) then begin
done:=FALSE;
repeat
if (c<>'?') then begin
nl;
fileinfo(f,FALSE,abort,next);
nl;
end;
if (next) then c:='N' else begin
prt('Remove files (?=help) : ');
if (f.owner<>usernum) and (not fso) then
onek(c,'QN?'^M)
else onek(c,'QDN?'^M);
end;
case c of
^M:c:=#0; {* do nothing *}
'?':begin
nl;
print('<CR>Redisplay entry');
if (f.owner<>usernum) and (not fso) then
lcmds(12,3,'Next file','Quit')
else begin
lcmds(12,3,'Delete file','Next file');
lcmds(12,3,'Quit','');
end;
nl;
end;
'D':if (f.owner<>usernum) and (not fso) then
sprint(#3#7+'You can''t delete this!!')
else begin
deleteff(rn,pl,TRUE);
dec(lrn);
s:='Removed "'+sqoutsp(f.filename)+'" from Dir#'+cstr(fileboard);
nl;
if (not exist(memuboard.dlpath+f.filename)) then
sprint(#3#5+'File does not exist!')
else
if (fso) then
if pynq('Erase file too? ') then begin
assign(ff,memuboard.dlpath+f.filename);
{$I-} erase(ff); {$I+}
if (ioresult=0) then s:=s+' [FILE DELETED]'
else
s:='Tried deleting "'+sqoutsp(f.filename)+'" from Dir#'+cstr(fileboard);
end;
subit:=(allcaps(f.stowner)=allcaps(u.name));
if (fso) then
if (not subit) then begin
print('Uploader name does not match user name!');
print('Cannot remove credit from user.');
end else
subit:=pynq('Remove from '+#3#5+caps(u.name)+' #'+
cstr(f.owner)+#3#7+'''s ratio? ');
if (subit) then begin
if (f.owner=usernum) then u:=thisuser;
with u do begin
uk:=uk-(f.blocks div 8);
dec(uploads);
if (uk<0) then uk:=0;
if (uploads<0) then uploads:=0;
end;
seek(uf,f.owner); write(uf,u);
if (f.owner=usernum) then thisuser:=u;
end;
sysoplog(s);
done:=TRUE;
end;
else
done:=TRUE;
end;
until ((done) or (hangup));
abort:=FALSE; next:=FALSE;
if (c='Q') then abort:=TRUE;
if (c<>'?') then nrecno(fn,pl,rn);
end;
end;
reset(uf); close(uf);
close(ulff);
end;
end;
procedure setdirs;
var s:astr;
i:integer;
done:boolean;
begin
nl;
if (novice in thisuser.ac) then begin fbaselist; nl; end;
done:=FALSE;
repeat
prt('Set NewScan file bases (Q=Quit,?=List,#=Toggle base) : '); input(s,3);
if (s='Q') then done:=TRUE;
if (s='?') then begin fbaselist; nl; end;
i:=ccuboards[0][value(s)];
if (fbaseac(i)) then { loads memuboard }
if (i>=0) and (i<=maxulb) and
(length(s)>0) and (s[1] in ['0'..'9']) then begin
nl;
sprompt(#3#5+memuboard.name+#3#3);
if (i in zscanr.fzscan) then begin
sprint(' will NOT be scanned.');
zscanr.fzscan:=zscanr.fzscan-[i];
end else begin
sprint(' WILL be scanned.');
zscanr.fzscan:=zscanr.fzscan+[i];
end;
nl;
end;
until (done) or (hangup);
lastcommandovr:=TRUE;
savezscanr;
end;
procedure pointdate;
var s:astr;
begin
nl;
print('Enter limiting date for new files -');
print('Date is currently set to '+newdate);
nl;
prt('(mm/dd/yy): '); input(s,8);
if (daynum(s)=0) then print('Illegal date.') else newdate:=s;
nl;
print('Current limiting date is '+newdate);
end;
procedure yourfileinfo;
begin
nl;
with thisuser do begin
sprint(#3#4+'Name.........: '+#3#5+nam);
sprint(#3#4+'SL...........: '+#3#5+cstr(thisuser.sl));
sprint(#3#4+'DSL..........: '+#3#5+cstr(thisuser.dsl));
sprint(#3#4+'File points..: '+#3#5+cstr(thisuser.filepoints));
sprompt(#3#4+'You DLed.....: '+#3#5+cstrl(thisuser.dk)+'k in '+cstr(thisuser.downloads)+' file');
if (thisuser.downloads<>1) then sprint('s') else nl;
sprompt(#3#4+'You ULed.....: '+#3#5+cstrl(thisuser.uk)+'k in '+cstr(thisuser.uploads)+' file');
if (thisuser.uploads<>1) then sprint('s') else nl;
sprint(#3#4+'File point status:');
if (fnofilepts in thisuser.ac) then
sprint(#3#3+' Special flag - No file point check!')
else
if (aacs(systat.nofilepts)) then
sprint(#3#3+' High security level - No file point check!')
else
sprint(#3#5+' Active according to setting on each file.');
if (not systat.fileptratio) then
sprint(#3#3+' Auto file point compensation inactive.')
else begin
sprint(#3#5+' File point compensation of '+cstr(systat.fileptcomp)+' to 1.');
sprint(#3#5+' Base compensation size of '+cstr(systat.fileptcompbasesize)+'k.');
end;
sprint(#3#4+'UL/DL ratio settings:');
if (not systat.uldlratio) then
sprint(#3#3+' Inactive.')
else
if (fnodlratio in thisuser.ac) then
sprint(#3#3+' Special flag - No ratio check!')
else
if (aacs(systat.nodlratio)) then
sprint(#3#3+' High security level - No ratio check!')
else begin
sprint(#3#5+' 1 upload for every '+cstr(systat.dlratio[thisuser.sl])+' downloads');
sprint(#3#5+' 1k upload for every '+cstr(systat.dlkratio[thisuser.sl])+' downloaded');
end;
end;
end;
procedure listopts;
var c:char;
begin
nl;
prt('List version: (1-3) ['+cstr(thisuser.flistopt)+'] : '); onek(c,'Q123 '^M);
if (c in ['1'..'3']) then thisuser.flistopt:=ord(c)-48;
if (thisuser.flistopt in [1,3]) then begin
dyny:=flistverb;
flistverb:=pynq('List verbose descriptions? ['+syn(flistverb)+'] : ');
end;
lastcommandovr:=TRUE;
end;
end.