I often need to use a function which reads a file into a string, as is so 
common in so many scripting languages. Can it be considered to add something 
like this to the RTL? Since we have a refcounted Ansistring type it's natural 
for this to be a one-liner. Not saying we should use TStringList but that's the 
closest thing I found in the RTL.

function ReadFile(path: Ansistring): Ansistring;
var
  list: TStringList;
begin
  list := TStringList.Create;
  list.LoadFromFile(ExpandFileName(path));
  result := list.Text;
  list.Free;
end;

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to