PageRenderTime 21ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/lib/io/core/file_stream.e

http://github.com/tybor/Liberty
Specman e | 74 lines | 37 code | 7 blank | 30 comment | 1 complexity | 805a3779a02330d18aad4667f0b173ba MD5 | raw file
 1-- This file is part of a Liberty Eiffel library.
 2-- See the full copyright at the end.
 3--
 4deferred class FILE_STREAM
 5   --
 6   -- Common parent class to all the file-related streams. Provides a common
 7   -- connection interface to the "real" files of the operating system.
 8   --
 9
10inherit
11   STREAM
12
13feature {ANY}
14   path: STRING
15         -- Not Void when connected to the corresponding file on the disk.
16
17   is_connected: BOOLEAN
18         -- Is this file connected to some file of the operating system?
19      do
20         Result := path /= Void
21      ensure
22         definition: Result = (path /= Void)
23      end
24
25   connect_to (new_path: ABSTRACT_STRING)
26         -- Try to connect to an existing file of the operating system.
27      require
28         not is_connected
29         not_malformed_path: not new_path.is_empty
30      deferred
31      ensure
32         is_connected implies path.same_as(new_path.out)
33      end
34
35feature {}
36   set_path (new_path: ABSTRACT_STRING)
37      do
38         if path = Void then
39            path := new_path.out
40         else
41            lock_tagged_out
42            tagged_out_memory.clear_count
43            new_path.out_in_tagged_out_memory
44            path.copy(tagged_out_memory)
45            unlock_tagged_out
46         end
47      ensure
48         path.same_as(new_path.out)
49      end
50
51invariant
52   is_connected implies path /= Void
53
54end -- class FILE_STREAM
55--
56-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
57--
58-- Permission is hereby granted, free of charge, to any person obtaining a copy
59-- of this software and associated documentation files (the "Software"), to deal
60-- in the Software without restriction, including without limitation the rights
61-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
62-- copies of the Software, and to permit persons to whom the Software is
63-- furnished to do so, subject to the following conditions:
64--
65-- The above copyright notice and this permission notice shall be included in
66-- all copies or substantial portions of the Software.
67--
68-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
69-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
70-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
71-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
72-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
73-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
74-- THE SOFTWARE.