Natools

Diff
Login

Differences From Artifact [96c31e5d5b]:

To Artifact [f0ef6fde5e]:


1
2

3
4
5
6
7
8
9
1

2
3
4
5
6
7
8
9

-
+







------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté                                        --
-- Copyright (c) 2014-2017, Natacha Porté                                   --
--                                                                          --
-- Permission to use, copy, modify, and distribute this software for any    --
-- purpose with or without fee is hereby granted, provided that the above   --
-- copyright notice and this permission notice appear in all copies.        --
--                                                                          --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF         --
70
71
72
73
74
75
76




























77
78
79
80
81
82
83
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







      Name : in String;
      Form : in String := "") is
   begin
      Finalize (Self.Holder);
      Stream_IO.Open (Self.Holder.File, Stream_IO.Append_File, Name, Form);
   end Open;


   function Open_Or_Create (Name : String; Form : String := "")
     return Writer is
   begin
      return Result : Writer do
         Open_Or_Create (Result, Name, Form);
      end return;
   end Open_Or_Create;


   procedure Open_Or_Create
     (Self : in out Writer;
      Name : in String;
      Form : in String := "") is
   begin
      Finalize (Self.Holder);

      Open_Attempt :
      begin
         Stream_IO.Open (Self.Holder.File, Stream_IO.Append_File, Name, Form);
         return;
      exception
         when Stream_IO.Name_Error => null;
      end Open_Attempt;

      Stream_IO.Create (Self.Holder.File, Stream_IO.Append_File, Name, Form);
   end Open_Or_Create;


   function Name (Self : Writer) return String is
   begin
      return Stream_IO.Name (Self.Holder.File);
   end Name;

end Natools.S_Expressions.File_Writers;