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 path0071.pas
More file actions
108 lines (96 loc) · 4.63 KB
/
Copy path0071.pas
File metadata and controls
108 lines (96 loc) · 4.63 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
{
Here are some routines for Hiding files, making read only files and
stuff. Let me know what you think. Any comments, criticism, or rude
remarks are welcome.
{ ********************************************************** }
{ *********************** Files Unit *********************** }
{ ********************************************************** }
{ **************** Written by: Rick Haines ***************** }
{ ********************************************************** }
{ ***************** Last Revised 02/02/95 ****************** }
{ ********************************************************** }
Unit Files;
Interface
{ Note: All FileNames MUST end in a null Char }
{ EX: HideFile(FileName+#0); }
{ EX: HideFile('MyFile.Exe'+#0); }
Function HideFile(FileName : String) : Byte; { Hide FileName }
Function SystemFile(FileName : String) : Byte; { Make FileName a System File }
Function ReadOnlyFile(FileName : String) : Byte; { Make FileName ReadOnly }
Function NormalFile(FileName : String) : Byte; { Make FileName a Normal File }
Function FileAttributes(FileName : String) : Integer; { Returns Attributes of }
Implementation
Function HideFile(FileName : String) : Byte; Assembler;
Asm
Push DS { Push Data Segment }
LDS DX, FileName { Nul Terminated String of FileName }
Inc DX { Get Rid Of Length Byte }
Mov AH, 43h { Dos Function 43h, File Change Mode }
Mov AL, 1 { Change Attributes }
Mov CX, 2 { Bit 1, Hide It }
Int 21h { Call Dos }
JC @Done { See if there was an error }
Mov AL, 0 { If Not, Then No Error }
@Done:
Pop DS { Pop Data Segment }
End;
Function SystemFile(FileName : String) : Byte; Assembler;
Asm
Push DS { Push Data Segment }
LDS DX, FileName { Nul Terminated String of FileName }
Inc DX { Get Rid Of Length Byte }
Mov AH, 43h { Dos Function 43h, File Change Mode }
Mov AL, 1 { Change Attributes }
Mov CX, 4 { Bit 3, System File }
Int 21h { Call Dos }
JC @Done { See if there was an error }
Mov AL, 0 { If Not, Then No Error }
@Done:
Pop DS { Pop Data Segment }
End;
Function ReadOnlyFile(FileName : String) : Byte; Assembler;
Asm
Push DS { Push Data Segment }
LDS DX, FileName { Nul Terminated String of FileName }
Inc DX { Get Rid Of Length Byte }
Mov AH, 43h { Dos Function 43h, File Change Mode }
Mov AL, 1 { Change Attributes }
Mov CX, 1 { Bit 0, Read Only }
Int 21h { Call Dos }
JC @Done { See if there was an error }
Mov AL, 0 { If Not, Then No Error }
@Done:
Pop DS { Pop Data Segment }
End;
Function NormalFile(FileName : String) : Byte; Assembler;
Asm
Push DS { Push Data Segment }
LDS DX, FileName { Nul Terminated String of FileName }
Inc DX { Get Rid of Length Byte }
Mov AH, 43h { Dos Function 43h, File Change Mode }
Mov AL, 1 { Change Attributes }
Mov CX, 0 { Nothing, UnEverything it }
Int 21h { Call Dos }
JC @Done { See if there was an error }
Mov AL, 0 { If not, then no error }
@Done:
Pop DS { Pop Data Segment }
End;
Function FileAttributes(FileName : String) : Integer; Assembler;
Asm
Push DS { Push Data Segment }
LDS DX, FileName { Nul Terminated String of FileName }
Inc DX { Get Rid of Length Byte }
Mov AH, 43h { Dos Function 43h, File Change Mode }
Mov AL, 0 { Return Attributes }
Int 21h { Call Dos }
JC @Error { See if there was an error }
Mov AX, CX { Return Attributes }
Jmp @Done
@Error:
Mov AX, -1 { Return -1 For Error }
@Done:
Pop DS { Pop Data Segment }
End;
End.