PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/basic_directory/example3.e

http://github.com/tybor/Liberty
Specman e | 56 lines | 45 code | 6 blank | 5 comment | 3 complexity | dce05798b696ab71c424a7434ff696e5 MD5 | raw file
 1class EXAMPLE3
 2   --
 3   -- This example shows how to compute parent directories path starting
 4   -- from some given path as an argument or from the current working
 5   -- directory.
 6   --
 7
 8insert
 9   ARGUMENTS
10
11create {ANY}
12   make
13
14feature {}
15   basic_directory: BASIC_DIRECTORY
16
17   make
18      local
19         some_path: STRING
20      do
21         if argument_count > 1 then
22            io.put_string("usage : example3 [<some_path>]%N")
23         elseif argument_count = 1 then
24            some_path := argument(1).twin
25            go_up_from(some_path)
26         else
27            basic_directory.connect_to_current_working_directory
28            if basic_directory.is_connected then
29               some_path := basic_directory.last_entry.twin
30               basic_directory.disconnect
31               go_up_from(some_path)
32            end
33         end
34      end
35
36   go_up_from (some_path: STRING)
37      local
38         stop: BOOLEAN
39      do
40         from
41         until
42            stop
43         loop
44            io.put_string("%"")
45            io.put_string(some_path)
46            io.put_string("%"%N")
47            basic_directory.compute_parent_directory_of(some_path)
48            if basic_directory.last_entry.is_empty then
49               stop := True
50            else
51               some_path.copy(basic_directory.last_entry)
52            end
53         end
54      end
55
56end -- class EXAMPLE3