Skip to content

Commit 69b99db

Browse files
committed
Reuse new VSS's file output stream.
1 parent 0367f80 commit 69b99db

File tree

2 files changed

+9
-35
lines changed

2 files changed

+9
-35
lines changed

source/backend/streams.adb

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
-- of the license. --
1616
------------------------------------------------------------------------------
1717

18-
with VSS.Stream_Element_Vectors.Conversions;
18+
with VSS.Strings.Conversions;
1919

2020
package body Streams is
2121

@@ -25,7 +25,8 @@ package body Streams is
2525

2626
procedure Close (Self : in out Output_Text_Stream'Class) is
2727
begin
28-
GNATCOLL.VFS.Close (Self.Writable);
28+
VSS.Text_Streams.File_Output.File_Output_Text_Stream
29+
(Self).Close;
2930
end Close;
3031

3132
----------
@@ -36,28 +37,9 @@ package body Streams is
3637
(Self : in out Output_Text_Stream'Class;
3738
File : GNATCOLL.VFS.Virtual_File) is
3839
begin
39-
Self.Encoder.Initialize ("utf-8");
40-
Self.Writable := File.Write_File;
40+
Self.Create
41+
(VSS.Strings.Conversions.To_Virtual_String (File.Display_Full_Name),
42+
"utf-8");
4143
end Open;
4244

43-
---------
44-
-- Put --
45-
---------
46-
47-
overriding procedure Put
48-
(Self : in out Output_Text_Stream;
49-
Item : VSS.Characters.Virtual_Character;
50-
Success : in out Boolean)
51-
is
52-
pragma Unreferenced (Success);
53-
54-
Data : constant String :=
55-
VSS.Stream_Element_Vectors.Conversions.Unchecked_To_String
56-
(Self.Encoder.Encode (Item));
57-
58-
begin
59-
GNATCOLL.VFS.Write (Self.Writable, Data);
60-
-- Note, any errors are reported at the time of file close only.
61-
end Put;
62-
6345
end Streams;

source/backend/streams.ads

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
with GNATCOLL.VFS;
1919

20-
private with VSS.Characters;
21-
private with VSS.Strings.Converters.Encoders;
2220
with VSS.Text_Streams;
21+
private with VSS.Text_Streams.File_Output;
2322

2423
package Streams is
2524

@@ -35,14 +34,7 @@ package Streams is
3534
private
3635

3736
type Output_Text_Stream is
38-
limited new VSS.Text_Streams.Output_Text_Stream with record
39-
Encoder : VSS.Strings.Converters.Encoders.Virtual_String_Encoder;
40-
Writable : GNATCOLL.VFS.Writable_File;
41-
end record;
42-
43-
overriding procedure Put
44-
(Self : in out Output_Text_Stream;
45-
Item : VSS.Characters.Virtual_Character;
46-
Success : in out Boolean);
37+
limited new VSS.Text_Streams.File_Output.File_Output_Text_Stream with
38+
null record;
4739

4840
end Streams;

0 commit comments

Comments
 (0)