PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/basic_directory/example1.e

http://github.com/tybor/Liberty
Specman e | 45 lines | 37 code | 4 blank | 4 comment | 1 complexity | 011762e2074b66a497ca51bb3183c338 MD5 | raw file
 1class EXAMPLE1
 2   --
 3   -- This example shows how to list the contents of the current working
 4   -- directory using class BASIC_DIRECTORY.
 5   --
 6
 7create {ANY}
 8   make
 9
10feature {}
11   make
12      local
13         basic_directory: BASIC_DIRECTORY
14      do
15         basic_directory.connect_to_current_working_directory
16         if basic_directory.is_connected then
17            io.put_string("The current working directory is %"")
18            io.put_string(basic_directory.last_entry)
19            io.put_string("%".%N")
20            display_content_of(basic_directory)
21         else
22            io.put_string("Unable to open current working directory.%N")
23         end
24      end
25
26   display_content_of (basic_directory: BASIC_DIRECTORY)
27      require
28         basic_directory.is_connected
29      do
30         from
31            basic_directory.read_entry
32         until
33            basic_directory.end_of_input
34         loop
35            io.put_character('%T')
36            io.put_string(basic_directory.last_entry)
37            io.put_character('%N')
38            basic_directory.read_entry
39         end
40         basic_directory.disconnect
41      ensure
42         not basic_directory.is_connected
43      end
44
45end -- class EXAMPLE1