File: example3.e

package info (click to toggle)
smarteiffel 1.1-11
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 12,288 kB
  • ctags: 40,785
  • sloc: ansic: 35,791; lisp: 4,036; sh: 1,783; java: 895; ruby: 613; python: 209; makefile: 115; csh: 78; cpp: 50
file content (54 lines) | stat: -rw-r--r-- 1,368 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class EXAMPLE3
--
-- This example shows how to compute parent directories path starting 
-- from some given path as an argument or from the current working 
-- directory.
--
   
creation make
   
feature {NONE}

   basic_directory: BASIC_DIRECTORY;

   make is
      local
         some_path: STRING;
      do
         if argument_count > 1 then
            io.put_string("usage : example3 [<some_path>]%N");
         elseif argument_count = 1 then
            some_path := argument(1).twin;
            go_up_from(some_path);
         else
            basic_directory.connect_to_current_working_directory;
            if basic_directory.is_connected then
               some_path := basic_directory.last_entry.twin;
               basic_directory.disconnect;
               go_up_from(some_path);
            end;
         end;
      end;
   
   go_up_from(some_path: STRING) is
      local
         stop: BOOLEAN;
      do
         from
         until
            stop
         loop
            io.put_string("%"");
            io.put_string(some_path);
            io.put_string("%"%N");
            basic_directory.compute_parent_directory_of(some_path);
            if basic_directory.last_entry.is_empty then
               stop := true;
            else
               some_path.copy(basic_directory.last_entry);
            end;
         end;
      end;

end