PageRenderTime 30ms CodeModel.GetById 27ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/basic_directory/example6.e

http://github.com/tybor/Liberty
Specman e | 58 lines | 49 code | 5 blank | 4 comment | 1 complexity | 18ce2440fad3acf73691cbd5db191f5d MD5 | raw file
 1class EXAMPLE6
 2   --
 3   -- This example shows how to create a new directory, how to change
 4   -- the current working directory.
 5   --
 6
 7create {ANY}
 8   make
 9
10feature {}
11   make
12      local
13         directory_path: STRING; basic_directory: BASIC_DIRECTORY
14      do
15         basic_directory.connect_to_current_working_directory
16         directory_path := basic_directory.last_entry.twin
17         basic_directory.disconnect
18         io.put_string("Initial working directory is %"")
19         io.put_string(directory_path)
20         io.put_string("%".%N")
21         basic_directory.compute_parent_directory_of(directory_path)
22         directory_path := basic_directory.last_entry.twin
23         basic_directory.change_current_working_directory(directory_path)
24         if basic_directory.last_entry.is_empty then
25            io.put_string("Unable to change working directory to %"")
26            io.put_string(directory_path)
27            io.put_string("%".%N")
28            die_with_code(exit_failure_code)
29         end
30
31         basic_directory.connect_to_current_working_directory
32         directory_path := basic_directory.last_entry.twin
33         io.put_string("New working directory is %"")
34         io.put_string(directory_path)
35         io.put_string("%".%N")
36         display_content_of(basic_directory)
37      end
38
39   display_content_of (basic_directory: BASIC_DIRECTORY)
40      require
41         basic_directory.is_connected
42      do
43         from
44            basic_directory.read_entry
45         until
46            basic_directory.end_of_input
47         loop
48            io.put_character('%T')
49            io.put_string(basic_directory.last_entry)
50            io.put_character('%N')
51            basic_directory.read_entry
52         end
53         basic_directory.disconnect
54      ensure
55         not basic_directory.is_connected
56      end
57
58end -- class EXAMPLE6