2
This file is part of the Free Pascal run time library.
3
Copyright (c) 1999-2000 by Florian Klaempfl and Pavel Ozerski
4
member of the Free Pascal development team.
6
FPC Pascal system unit for the Win32 API.
8
See the file COPYING.FPC, included in this distribution,
9
for details about the copyright.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
**********************************************************************}
18
{*****************************************************************************
20
*****************************************************************************}
23
procedure dosdir(func:byte;const s:string);
25
var buffer:array[0..255] of char;
28
move(s[1],buffer,length(s));
29
buffer[length(s)]:=#0;
30
allowslash(Pchar(@buffer));
42
procedure MkDir (const S: string);[IOCHECK];
44
var buffer:array[0..255] of char;
48
If (s='') or (InOutRes <> 0) then
50
if os_mode = osOs2 then
52
move(s[1],buffer,length(s));
53
buffer[length(s)]:=#0;
54
allowslash(Pchar(@buffer));
55
Rc := DosCreateDir(buffer,nil);
64
{ Under EMX 0.9d DOS this routine call may sometimes fail }
65
{ The syscall documentation indicates clearly that this }
66
{ routine was NOT tested. }
72
procedure rmdir(const s : string);[IOCHECK];
73
var buffer:array[0..255] of char;
78
If (s='') or (InOutRes <> 0) then
80
if os_mode = osOs2 then
82
move(s[1],buffer,length(s));
83
buffer[length(s)]:=#0;
84
allowslash(Pchar(@buffer));
85
Rc := DosDeleteDir(buffer);
94
{ Under EMX 0.9d DOS this routine call may sometimes fail }
95
{ The syscall documentation indicates clearly that this }
96
{ routine was NOT tested. }
103
procedure ChDir (const S: string);[IOCheck];
106
Buffer: array [0..255] of char;
109
If (s='') or (InOutRes <> 0) then
111
(* According to EMX documentation, EMX has only one current directory
112
for all processes, so we'll use native calls under OS/2. *)
113
if os_Mode = osOS2 then
115
if (Length (S) >= 2) and (S [2] = ':') then
117
RC := DosSetDefaultDisk ((Ord (S [1]) and
122
if Length (S) > 2 then
124
Move (S [1], Buffer, Length (S));
125
Buffer [Length (S)] := #0;
126
AllowSlash (PChar (@Buffer));
127
RC := DosSetCurrentDir (@Buffer);
137
Move (S [1], Buffer, Length (S));
138
Buffer [Length (S)] := #0;
139
AllowSlash (PChar (@Buffer));
140
RC := DosSetCurrentDir (@Buffer);
149
if (Length (S) >= 2) and (S [2] = ':') then
165
end ['eax','edx','esi'];
166
if (Length (S) > 2) and (InOutRes <> 0) then
167
{ Under EMX 0.9d DOS this routine may sometime }
168
{ fail or crash the system. }
172
{ Under EMX 0.9d DOS this routine may sometime }
173
{ fail or crash the system. }
179
procedure GetDir (DriveNr: byte; var Dir: ShortString);
181
{Written by Michael Van Canneyt.}
188
{ Used in case the specified drive isn't available }
190
{ dir[1..3] will contain '[drivenr]:\', but is not }
191
{ supplied by DOS, so we let dos string start at }
193
{ Get dir from drivenr : 0=default, 1=A etc... }
202
end [ 'eax','edx','esi'];
203
{ Now Dir should be filled with directory in ASCIIZ, }
204
{ starting from dir[4] }
209
{Conversion to Pascal string }
210
while (dir[i]<>#0) do
212
{ convert path name to DOS }
218
{ upcase the string (FPC function) }
219
if drivenr<>0 then { Drive was supplied. We know it }
220
dir[1]:=chr(64+drivenr)
223
{ We need to get the current drive from DOS function 19H }
224
{ because the drive was the default, which can be unknown }
233
if not (FileNameCaseSensitive) then dir:=upcase(dir);