This repository was archived by the owner on Oct 11, 2022. It is now read-only.
forked from nickelsworth/swag
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0081.pas
More file actions
212 lines (185 loc) · 3.86 KB
/
Copy path0081.pas
File metadata and controls
212 lines (185 loc) · 3.86 KB
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
Unit WGFFind; {File Find Object Unit}
{$I WGDEFINE.INC} { see below for WGDEFINE !! }
Interface
Uses
{$IFDEF WINDOWS}
WinDos;
{$ELSE}
Dos;
{$ENDIF}
Const
{searchtypes}
stReadOnly=$01;
stHidden=$02;
stSysFile=$04;
stVolumeID=$08;
stDirectory=$10;
stArchive=$20;
stAnyFile=$3F;
Type
{$IFDEF WINDOWS}
PathStr=String[128];
DirStr=String[128];
NameStr=String[13];
ExtStr=String[4];
{$ENDIF}
FindRec=Record
{$IFDEF WINDOWS}
SR:TSearchRec;
TStr:Array[0..180] of Char;
{$ELSE}
SR:SearchRec;
{$ENDIF}
Dir:DirStr;
Name:NameStr;
Ext:ExtStr;
DError:Word;
SearchType:Word;
End;
FindObj = Object
FI: ^FindRec;
Constructor Init(ST:Word); {SearchType: Sysfile, AnyFile, Archive}
Destructor Done;
Procedure FFirst(FN:String);
Procedure FNext;
Function Found:Boolean;
Function GetName:String;
Function GetFullPath:String;
Function GetDate:LongInt;
Function GetSize:LongInt;
Function GetAttr:Word;
End;
Implementation
{$IFDEF WINDOWS}
Function FExpand(Str:String):String;
Var
IStr:Array[0..128] of Char;
OStr:Array[0..128] of Char;
Begin
StrPCopy(IStr,Str);
FileExpand(OStr,IStr);
FExpand:=StrPas(OStr);
End;
{$ENDIF}
{$IFDEF WINDOWS}
Procedure FSplit(Path:String;Var Dir:String;Var Name:String;Var Ext:String);
Var
FPath:Array[0..129] of Char;
TD:Array[0..129] of Char;
TN:Array[0..14] of Char;
TE:Array[0..5] of Char;
Begin
StrPCopy(FPath,Path);
FileSplit(FPath,TD,TN,TE);
Dir:=StrPas(TD);
Name:=StrPas(TN);
Ext:=StrPas(TE);
End;
{$ENDIF}
Constructor FindObj.Init;
Begin
New(FI);
If FI=Nil then Fail;
FI^.DError:=1;
FI^.SearchType:=StArchive+StReadOnly; {default}
End;
Destructor FindObj.Done;
Begin
If FI<>Nil then Dispose(FI);
End;
Procedure FindObj.FFirst(FN:String);
Begin
If FI<>Nil then Begin
FN:=FExpand(FN);
FSplit(FN,FI^.Dir,FI^.Name,FI^.Ext);
{$IFDEF WINDOWS}
StrPCopy(FI^.TStr, FN);
FindFirst(FI^.TStr,FI^.SearchType,FI^.SR);
{$ELSE}
FindFirst(FN,FI^.SearchType,FI^.SR);
{$ENDIF}
FI^.DError:=DosError;
End
Else FI^.DError:=1;
End;
Function FindObj.GetName:String;
Begin
GetName:='';
If FI<>Nil then
If Found Then
{$IFDEF WINDOWS}
GetName:=StrPas(FI^.SR.Name);
{$ELSE}
GetName:=FI^.SR.Name;
{$ENDIF}
End;
Function FindObj.GetFullPath:String;
Begin
If FI<>Nil then GetFullPath:=FI^.Dir+GetName
Else GetFullPath:='';
End;
Function FindObj.GetSize:LongInt;
Begin
GetSize:=0;
If FI<>Nil then
If Found Then GetSize:=FI^.SR.Size;
End;
Function FindObj.GetDate: LongInt;
Begin
GetDate:=0;
If FI<>Nil then
If Found Then GetDate:=FI^.SR.Time;
End;
Function FindObj.GetAttr:Word;
Begin
GetAttr:=0;
If FI<>Nil then
If Found Then GetAttr:=FI^.SR.Attr;
End;
Procedure FindObj.FNext;
Begin
If FI<>Nil then Begin
FindNext(FI^.SR);
FI^.DError:=DosError;
End
Else FI^.DError:=1;
End;
Function FindObj.Found:Boolean;
Begin
Found:=(FI^.DError=0);
End;
End.
[WGDEFINE.INC]
{$I-}
{$V-}
{$S+}
{$F+}
{$D-}
{$L-}
{$R-}
{$X+}
{$IFNDEF WINDOWS}
{$O+} {Make units overlayable}
{$IFNDEF OS2}
{$X-} {Turn off extended syntax}
{$ENDIF}
{$ENDIF}
{$IFDEF WINDOWS}
{$DEFINE BASMINT} {Use BASM for interrupts under windows}
{$ENDIF}
{.$.DEFINE OPRO}
{.$.DEFINE DEBUG}
{BBS Definitions below (some that I have tested the new WGMSG*.PAS w/!)}
{$IFDEF MAXIMUS}
{$DEFINE SQUISH}
{$ENDIF}
{$IFDEF RA2}
{$DEFINE JAM}
{$DEFINE HUDSON}
{$ENDIF}
{$IFDEF XENOPHOBE}
{$DEFINE FIDO}
{$DEFINE SQUISH}
{$DEFINE JAM}
{$ENDIF}