forked from AdriaanBoshoff/RustCentralBanServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuMisc.pas
63 lines (53 loc) · 1.31 KB
/
uMisc.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
unit uMisc;
interface
function LoadFromFile(const aFile: string): WideString;
procedure SaveToFile(const aText, aFile: WideString);
implementation
uses
System.Classes, System.SysUtils;
function LoadFromFile(const aFile: string): WideString;
begin
var sList := TStringList.Create;
try
try
sList.LoadFromFile(aFile, TEncoding.UTF8);
Result := sList.Text;
except
on E: Exception do
begin
Result := '';
Writeln('============================');
Writeln('ERROR Loading FILE:');
Writeln('Procedure: LoadFromFile');
Writeln('Reason : File does not exist.');
Writeln('Path : ' + aFile);
Writeln('============================');
end;
end;
finally
sList.Free;
end;
end;
procedure SaveToFile(const aText, aFile: WideString);
begin
var sList := TStringList.Create;
try
sList.Text := aText;
try
sList.SaveToFile(aFile, TEncoding.UTF8);
except
on E: Exception do
begin
Writeln('============================');
Writeln('ERROR Writing FILE:');
Writeln('Procedure: SaveToFile');
Writeln('Reason : ' + E.Message);
Writeln('Path : ' + aFile);
Writeln('============================');
end;
end;
finally
sList.Free;
end;
end;
end.