mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 02:09:33 +02:00
* Add IsYAMLfileName
This commit is contained in:
parent
2b56b2d725
commit
abeccabdf1
@ -78,6 +78,7 @@ Type
|
||||
Constructor Create(const aInput : array of string);
|
||||
Constructor Create(const aFileName : string);
|
||||
Destructor Destroy; override;
|
||||
Class function IsYamlFileName(const aFileName : string) : Boolean; inline;
|
||||
function ParseSingleDocument: TYAMLDocument;
|
||||
Function Parse : TYAMLStream;
|
||||
end;
|
||||
@ -620,11 +621,20 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
class function TYAMLParser.IsYamlFileName(const aFileName: string): Boolean;
|
||||
|
||||
begin
|
||||
Result:=fpyaml.types.IsYamlFileName(aFileName);
|
||||
end;
|
||||
|
||||
|
||||
function TYAMLParser.ParseSingleDocument: TYAMLDocument;
|
||||
begin
|
||||
Result:=ParseSingleDocument(Nil);
|
||||
end;
|
||||
|
||||
|
||||
function TYAMLParser.ParseSingleDocument(aStream : TYAMLStream): TYAMLDocument;
|
||||
|
||||
var
|
||||
|
@ -18,6 +18,10 @@ unit fpyaml.strings;
|
||||
|
||||
interface
|
||||
|
||||
const
|
||||
YAMLExt1 = '.yaml';
|
||||
YAMLExt2 = '.yml';
|
||||
|
||||
resourcestring
|
||||
// Data
|
||||
SErrIsNotA = '%s is not a valid %s';
|
||||
|
@ -87,6 +87,8 @@ Const
|
||||
'tag:yaml.org,2002:seq',
|
||||
'tag:yaml.org,2002:map');
|
||||
|
||||
Function IsYAMLFileName(const aFileName : string) : Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
@ -143,5 +145,16 @@ begin
|
||||
Result:=YAMLTagNames[Self];
|
||||
end;
|
||||
|
||||
Function IsYAMLFileName(const aFileName : string) : Boolean;
|
||||
|
||||
var
|
||||
Ext : string;
|
||||
|
||||
begin
|
||||
Ext:=ExtractFileExt(aFileName);
|
||||
Result:=SameText(YamlExt1,Ext) or SameText(YamlExt2,Ext);
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user