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 path0091.pas
More file actions
167 lines (143 loc) · 4.42 KB
/
Copy path0091.pas
File metadata and controls
167 lines (143 loc) · 4.42 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
program Delattr;
Uses Dos;
Procedure Usage;
Begin
Writeln;
Writeln('DELATTR (C) 1995 Scott Tunstall.');
Writeln('Gets rid of those annoying undeletable files quickly !');
Writeln;
Writeln;
Writeln('Usage:');
Writeln;
Writeln('DELATTR [-r] [-s] [-a] [-h] <FileSpec>');
Writeln;
Writeln(' -r will remove the READ ONLY attribute of a file,');
Writeln(' -s will remove the SYSTEM attribute,');
Writeln(' -a will remove the ARCHIVE attribute,');
Writeln(' -h will remove the HIDDEN attribute.');
Writeln;
Writeln;
Writeln('If you do not specify any attribute parameters, the');
Writeln('program assumes you want to remove ALL of the');
Writeln('specified file''s attributes. Or Something. :-) ');
Writeln;
Writeln('Use ATTRIB if all you want to do is ADD or VIEW ');
Writeln('the attributes of file(s).');
Writeln;
End;
Procedure BreakDownMask(TheMask: Word);
Begin
If TheMask <>0 Then
Begin
If TheMask AND Archive = Archive Then
Write('A ');
If TheMask AND Directory = Directory Then
Write('D ');
If TheMask AND Hidden = Hidden Then
Write('H ');
If TheMask AND ReadOnly = ReadOnly Then
Write('R ');
If TheMask AND SysFile = SysFile Then
Write('S ');
If TheMask AND VolumeID = VolumeID Then
Write('V ');
End
Else
Write('NULL ');
End;
{
ReadOnly │ $01
Hidden │ $02
SysFile │ $04
VolumeID │ $08
Directory │ $10
Archive │ $20
AnyFile │ $3F
}
Procedure DoAttrib;
Var Count: Byte;
FileToChange: File;
TempParam: string;
CurrentByteMask: Word;
ByteMask : Word;
SearchRc: SearchRec;
Begin
ByteMask:=0;
If ParamCount = 1 Then
ByteMask:=$2f
Else
For Count:=1 to (ParamCount -1) do
Begin
TempParam:=ParamStr(Count);
If TempParam[1] = '-' Then
Begin
Case upcase(TempParam[2]) of
'A': ByteMask:=ByteMask OR Archive;
'D': ByteMask:=ByteMask OR Directory;
'H': ByteMask:=ByteMask OR Hidden;
'R': ByteMask:=ByteMask OR ReadOnly;
'S': ByteMask:=ByteMask OR SysFile;
'V': ByteMasK:=ByteMask OR VolumeID;
Else
Begin
Write(chr(7));
Writeln(Paramstr(Count),' is not a valid switch !');
Halt;
End
End;
End
Else
Begin
Write(chr(7));
Writeln(ParamStr(Count),' is not recognised as a switch !');
Halt;
End;
End;
FindFirst(ParamStr(ParamCount),AnyFile, SearchRc);
If DosError =0 Then
Begin
While DosError = 0 do
Begin
Assign(FileToChange,SearchRc.Name);
GetFAttr(FileToChange,CurrentByteMask);
If CurrentByteMask <>0 Then
Begin
CurrentByteMask:=CurrentByteMask AND (65535 - ByteMask);
If ByteMask <>$2f Then
Begin
Write('Changed attributes of ',SearchRc.Name,' to ');
BreakDownMask(CurrentByteMask);
End
Else
Write('Removed all attributes from ',SearchRc.Name);
SetFAttr(FileToChange,CurrentByteMask);
If DosError = 0 Then
Write(' [OK].')
Else
Write('[Access Denied]');
Writeln;
FindNext(SearchRc);
End
Else
Begin
Writeln(SearchRc.Name, ' has no file attributes [OK].');
FindNext(SearchRc);
End;
End;
Writeln;
Writeln('Operation complete.');
Writeln;
End
Else
Begin
Writeln('Could not find the specified file(s) !');
Writeln;
End;
End;
Begin
If ParamCount = 0 Then
Usage
Else
Doattrib;
End.