mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-09 15:37:11 +01:00
* more removal of deprecated functions (deprecated before 2.4.0)
old copies of routines in dos, and some shortstring shorthands for fsplit. git-svn-id: trunk@21359 -
This commit is contained in:
parent
043ff2c81c
commit
0757517dde
@ -26,16 +26,11 @@ Type
|
||||
NameStr = String[255] deprecated 'Clean up shortstring use, or use same type from unit dos.';
|
||||
ExtStr = String[255] deprecated 'Clean up shortstring use, or use same type from unit dos.';
|
||||
|
||||
Function Dirname(Const path:pathstr):pathstr; deprecated;
|
||||
Function StringToPPChar(S: PChar;ReserveEntries:integer):ppchar;
|
||||
Function StringToPPChar(Var S:String;ReserveEntries:integer):ppchar; deprecated;
|
||||
Function StringToPPChar(Var S:AnsiString;ReserveEntries:integer):ppchar;
|
||||
function ArrayStringToPPchar(const S:Array of AnsiString;reserveentries:Longint):ppchar; // const ?
|
||||
Function Basename(Const path:pathstr;Const suf:pathstr):pathstr; deprecated;
|
||||
Function FNMatch(const Pattern,Name:string):Boolean; deprecated;
|
||||
Function GetFS (var T:Text):longint; deprecated;
|
||||
Function GetFS(var T:Text):longint; deprecated;
|
||||
Function GetFS(Var F:File):longint; deprecated; // use sysutils.getfilehandle
|
||||
Procedure FSplit(const Path:PathStr;Var Dir:DirStr;Var Name:NameStr;Var Ext:ExtStr); deprecated;
|
||||
Function LocalToEpoch(year,month,day,hour,minute,second:Word):Longint;
|
||||
Procedure EpochToLocal(epoch:longint;var year,month,day,hour,minute,second:Word);
|
||||
Procedure JulianToGregorian(JulianDN:LongInt;Var Year,Month,Day:Word);
|
||||
@ -70,59 +65,6 @@ begin
|
||||
ArrayStringToPPchar:=p;
|
||||
end;
|
||||
|
||||
|
||||
Procedure FSplit(const Path:PathStr;Var Dir:DirStr;Var Name:NameStr;Var Ext:ExtStr);
|
||||
Var
|
||||
DotPos,SlashPos,i : longint;
|
||||
Begin
|
||||
SlashPos:=0;
|
||||
DotPos:=256;
|
||||
i:=Length(Path);
|
||||
While (i>0) and (SlashPos=0) Do
|
||||
Begin
|
||||
If (DotPos=256) and (Path[i]='.') Then
|
||||
begin
|
||||
DotPos:=i;
|
||||
end;
|
||||
If (Path[i]='/') Then
|
||||
SlashPos:=i;
|
||||
Dec(i);
|
||||
End;
|
||||
Ext:=Copy(Path,DotPos,255);
|
||||
Dir:=Copy(Path,1,SlashPos);
|
||||
Name:=Copy(Path,SlashPos + 1,DotPos - SlashPos - 1);
|
||||
End;
|
||||
|
||||
|
||||
Function Dirname(Const path:pathstr):pathstr;
|
||||
{
|
||||
This function returns the directory part of a complete path.
|
||||
Unless the directory is root '/', The last character is not
|
||||
a slash.
|
||||
}
|
||||
var
|
||||
Dir : PathStr;
|
||||
Name : NameStr;
|
||||
Ext : ExtStr;
|
||||
begin
|
||||
FSplit(Path,Dir,Name,Ext);
|
||||
if length(Dir)>1 then
|
||||
Delete(Dir,length(Dir),1);
|
||||
DirName:=Dir;
|
||||
end;
|
||||
|
||||
Function StringToPPChar(Var S:String;ReserveEntries:integer):ppchar;
|
||||
{
|
||||
Create a PPChar to structure of pchars which are the arguments specified
|
||||
in the string S. Especially useful for creating an ArgV for Exec-calls
|
||||
Note that the string S is destroyed by this call.
|
||||
}
|
||||
|
||||
begin
|
||||
S:=S+#0;
|
||||
StringToPPChar:=StringToPPChar(pchar(@S[1]),ReserveEntries);
|
||||
end;
|
||||
|
||||
Function StringToPPChar(Var S:AnsiString;ReserveEntries:integer):ppchar;
|
||||
{
|
||||
Create a PPChar to structure of pchars which are the arguments specified
|
||||
@ -205,107 +147,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
Function Basename(Const path:pathstr;Const suf:pathstr):pathstr;
|
||||
{
|
||||
This function returns the filename part of a complete path. If suf is
|
||||
supplied, it is cut off the filename.
|
||||
}
|
||||
var
|
||||
Dir : PathStr;
|
||||
Name : NameStr;
|
||||
Ext : ExtStr;
|
||||
begin
|
||||
FSplit(Path,Dir,Name,Ext);
|
||||
if Suf<>Ext then
|
||||
Name:=Name+Ext;
|
||||
BaseName:=Name;
|
||||
end;
|
||||
|
||||
|
||||
Function FNMatch(const Pattern,Name:string):Boolean;
|
||||
Var
|
||||
LenPat,LenName : longint;
|
||||
|
||||
Function DoFNMatch(i,j:longint):Boolean;
|
||||
Var
|
||||
Found : boolean;
|
||||
Begin
|
||||
Found:=true;
|
||||
While Found and (i<=LenPat) Do
|
||||
Begin
|
||||
Case Pattern[i] of
|
||||
'?' : Found:=(j<=LenName);
|
||||
'*' : Begin
|
||||
{find the next character in pattern, different of ? and *}
|
||||
while Found do
|
||||
begin
|
||||
inc(i);
|
||||
if i>LenPat then Break;
|
||||
case Pattern[i] of
|
||||
'*' : ;
|
||||
'?' : begin
|
||||
if j>LenName then begin DoFNMatch:=false; Exit; end;
|
||||
inc(j);
|
||||
end;
|
||||
else
|
||||
Found:=false;
|
||||
end;
|
||||
end;
|
||||
Assert((i>LenPat) or ( (Pattern[i]<>'*') and (Pattern[i]<>'?') ));
|
||||
{Now, find in name the character which i points to, if the * or ?
|
||||
wasn't the last character in the pattern, else, use up all the
|
||||
chars in name}
|
||||
Found:=false;
|
||||
if (i<=LenPat) then
|
||||
begin
|
||||
repeat
|
||||
{find a letter (not only first !) which maches pattern[i]}
|
||||
while (j<=LenName) and (name[j]<>pattern[i]) do
|
||||
inc (j);
|
||||
if (j<LenName) then
|
||||
begin
|
||||
if DoFnMatch(i+1,j+1) then
|
||||
begin
|
||||
i:=LenPat;
|
||||
j:=LenName;{we can stop}
|
||||
Found:=true;
|
||||
Break;
|
||||
end else
|
||||
inc(j);{We didn't find one, need to look further}
|
||||
end else
|
||||
if j=LenName then
|
||||
begin
|
||||
Found:=true;
|
||||
Break;
|
||||
end;
|
||||
{ This 'until' condition must be j>LenName, not j>=LenName.
|
||||
That's because when we 'need to look further' and
|
||||
j = LenName then loop must not terminate. }
|
||||
until (j>LenName);
|
||||
end else
|
||||
begin
|
||||
j:=LenName;{we can stop}
|
||||
Found:=true;
|
||||
end;
|
||||
end;
|
||||
else {not a wildcard character in pattern}
|
||||
Found:=(j<=LenName) and (pattern[i]=name[j]);
|
||||
end;
|
||||
inc(i);
|
||||
inc(j);
|
||||
end;
|
||||
DoFnMatch:=Found and (j>LenName);
|
||||
end;
|
||||
|
||||
Begin {start FNMatch}
|
||||
LenPat:=Length(Pattern);
|
||||
LenName:=Length(Name);
|
||||
FNMatch:=DoFNMatch(1,1);
|
||||
End;
|
||||
|
||||
|
||||
|
||||
Function GetFS (var T:Text):longint;
|
||||
{
|
||||
Get File Descriptor of a text file.
|
||||
@ -317,7 +158,6 @@ begin
|
||||
GETFS:=textrec(t).Handle
|
||||
end;
|
||||
|
||||
|
||||
Function GetFS(Var F:File):longint;
|
||||
{
|
||||
Get File Descriptor of an unTyped file.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user