1
0

RxFPC:rxstrutils add new function - FileToString

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6914 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2019-05-16 07:40:56 +00:00
parent b1b663cbbe
commit 0361aa3588
10 changed files with 118 additions and 4 deletions

@ -232,7 +232,7 @@ function RomanToInt(const S: string): Longint; deprecated; //use this function f
doesn't contain a valid roman numeric value, the 0 value is returned. }
procedure StrToStrings(const S:string; const List:TStrings; const Delims:Char);
function FileToString(const AFileName:string):string;
const
DigitChars = ['0'..'9'];
Brackets = ['(',')','[',']','{','}'];
@ -1129,4 +1129,24 @@ begin
end;
end;
function FileToString(const AFileName: string): string;
var
F: TFileStream;
begin
if FileExists(AFileName) then
begin;
F:=TFileStream.Create(AFileName, fmOpenRead);
if F.Size>0 then
begin
SetLength(Result, F.Size);
F.ReadBuffer(Result[1], F.Size);
end
else
Result:='';
F.Free;
end
else
Result:='';
end;
end.