2
$Id: sysdir.inc,v 1.3 2005/02/14 17:13:31 peter Exp $
3
This file is part of the Free Pascal run time library.
5
Main OS dependant body of the system unit, loosely modelled
6
after POSIX. *BSD version (Linux version is near identical)
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
*****************************************************************************}
22
Procedure MkDir(Const s: String);[IOCheck];
24
{ read/write search permission for everyone }
25
MODE_MKDIR = S_IWUSR OR S_IRUSR OR
28
S_IXUSR OR S_IXGRP OR S_IXOTH;
30
Buffer: Array[0..255] of Char;
32
If (s='') or (InOutRes <> 0) then
34
Move(s[1], Buffer, Length(s));
35
Buffer[Length(s)] := #0;
36
If Fpmkdir(@buffer, MODE_MKDIR)<0 Then
43
Procedure RmDir(Const s: String);[IOCheck];
45
Buffer: Array[0..255] of Char;
49
If (s='') or (InOutRes <> 0) then
51
Move(s[1], Buffer, Length(s));
52
Buffer[Length(s)] := #0;
53
If Fprmdir(@buffer)<0 Then
60
Procedure ChDir(Const s: String);[IOCheck];
62
Buffer: Array[0..255] of Char;
64
If (s='') or (InOutRes <> 0) then
66
Move(s[1], Buffer, Length(s));
67
Buffer[Length(s)] := #0;
68
If Fpchdir(@buffer)<0 Then
72
{ file not exists is path not found under tp7 }
77
{ // $define usegetcwd}
79
procedure getdir(drivenr : byte;var dir : shortstring);
82
buf : array[0..254] of char;
86
thedir,dummy : string[255];
97
if Fpgetcwd(@buf,sizeof(buf))<>nil then
103
{ get root directory information }
105
if Fpstat(@tmp[1],rootinfo)<0 then
109
{ get current directory information }
110
if Fpstat(@tmp[1],cwdinfo)<0 then
113
{ open directory stream }
114
{ try to find the current inode number of the cwd }
115
dirstream:=Fpopendir(@tmp[1]);
116
if dirstream=nil then
120
d:=Fpreaddir(dirstream);
121
{ no more entries to read ... }
122
if not assigned(d) then
124
tmp:=dummy+'../'+strpas(d^.d_name) + #0;
125
if (Fpstat(@tmp[1],thisdir)=0) then
127
{ found the entry for this directory name }
128
if (cwdinfo.st_dev=thisdir.st_dev) and (cwdinfo.st_ino=thisdir.st_ino) then
130
{ are the filenames of type '.' or '..' ? }
131
{ then do not set the name. }
132
if (not ((d^.d_name[0]='.') and ((d^.d_name[1]=#0) or
133
((d^.d_name[1]='.') and (d^.d_name[2]=#0))))) then
134
name:='/'+strpas(d^.d_name);
138
if Fpclosedir(dirstream)<0 then
142
if ((cwdinfo.st_dev=rootinfo.st_dev) and (cwdinfo.st_ino=rootinfo.st_ino)) then
156
Revision 1.3 2005/02/14 17:13:31 peter
159
Revision 1.2 2005/02/13 20:01:38 peter
160
* include file cleanup
162
Revision 1.1 2005/02/07 22:04:55 peter
165
Revision 1.1 2005/02/06 13:06:20 peter
166
* moved file and dir functions to sysfile/sysdir
167
* win32 thread in systemunit