fpc/rtl/morphos/sysdir.inc
2005-02-14 17:13:06 +00:00

114 lines
2.7 KiB
PHP

{
$Id$
This file is part of the Free Pascal run time library.
Copyright (c) 1999-2000 by Florian Klaempfl and Pavel Ozerski
member of the Free Pascal development team.
FPC Pascal system unit for the Win32 API.
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{*****************************************************************************
Directory Handling
*****************************************************************************}
procedure mkdir(const s : string);[IOCheck];
var
tmpStr : array[0..255] of char;
tmpLock: LongInt;
begin
checkCTRLC;
if (s='') or (InOutRes<>0) then exit;
tmpStr:=PathConv(s)+#0;
tmpLock:=dosCreateDir(@tmpStr);
if tmpLock=0 then begin
dosError2InOut(IoErr);
exit;
end;
UnLock(tmpLock);
end;
procedure rmdir(const s : string);[IOCheck];
var
tmpStr : array[0..255] of Char;
begin
checkCTRLC;
if (s='.') then InOutRes:=16;
If (s='') or (InOutRes<>0) then exit;
tmpStr:=PathConv(s)+#0;
if not dosDeleteFile(@tmpStr) then
dosError2InOut(IoErr);
end;
procedure chdir(const s : string);[IOCheck];
var
tmpStr : array[0..255] of Char;
tmpLock: LongInt;
FIB : PFileInfoBlock;
begin
checkCTRLC;
If (s='') or (InOutRes<>0) then exit;
tmpStr:=PathConv(s)+#0;
tmpLock:=0;
{ Changing the directory is a pretty complicated affair }
{ 1) Obtain a lock on the directory }
{ 2) CurrentDir the lock }
tmpLock:=Lock(@tmpStr,SHARED_LOCK);
if tmpLock=0 then begin
dosError2InOut(IoErr);
exit;
end;
FIB:=nil;
new(FIB);
if (Examine(tmpLock,FIB)=True) and (FIB^.fib_DirEntryType>0) then begin
tmpLock:=CurrentDir(tmpLock);
if MOS_OrigDir=0 then begin
MOS_OrigDir:=tmpLock;
tmpLock:=0;
end;
end;
if tmpLock<>0 then Unlock(tmpLock);
if assigned(FIB) then dispose(FIB);
end;
procedure GetDir (DriveNr: byte; var Dir: ShortString);
var tmpbuf: array[0..255] of char;
begin
checkCTRLC;
Dir:='';
if not GetCurrentDirName(tmpbuf,256) then
dosError2InOut(IoErr)
else
Dir:=strpas(tmpbuf);
end;
{
$Log$
Revision 1.2 2005-02-14 17:13:30 peter
* truncate log
Revision 1.1 2005/02/07 21:30:12 peter
* system unit updated
Revision 1.1 2005/02/06 16:57:18 peter
* threads for go32v2,os,emx,netware
Revision 1.1 2005/02/06 13:06:20 peter
* moved file and dir functions to sysfile/sysdir
* win32 thread in systemunit
}