/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

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