/src/lib/io/internal/path_joiner.e

http://github.com/tybor/Liberty · Specman e · 108 lines · 51 code · 9 blank · 48 comment · 0 complexity · 31eab8dac09d39280f93e89dbe16677a MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. deferred class PATH_JOINER
  5. -- A protocol for PATH_NAMEs to describe themselves to other objects.
  6. --
  7. -- A typical session goes like this:
  8. -- # call `start_join' describing you drive (if any) and whether you are absolute or relative
  9. -- # Repeatedly call the `join_xxx' procedures to describe yourself, more significant elements first (i.e.
  10. -- generally left-to-right)
  11. -- # call `end_join'
  12. --
  13. -- Caveat: the only way to make sure that the target is not changed at all is by not starting a session. A
  14. -- call to `start_join' (even with `drive'=Void and absoluteness=0) immediately followed by a call to
  15. -- `end_join' can have some benign side-effect on the target (including some amount of normalization being performed).
  16. feature {PATH_JOINER}
  17. start_join (drive: STRING; absoluteness: INTEGER)
  18. -- Start joining an absolute path to `Current'
  19. --
  20. -- `drive' is optional
  21. -- `absoluteness' is, e.g., the number of leading slashes:
  22. -- 0 for relative paths
  23. -- 1 for absolute paths
  24. -- more for super-absolute paths (for instance, network-wide)
  25. require
  26. absoluteness >= 0
  27. deferred
  28. end
  29. join_directory (element: STRING)
  30. -- Add a directory to the end of the path
  31. require
  32. element /= Void
  33. do
  34. join_element(element)
  35. ensure
  36. old join_error implies join_error
  37. end
  38. join_up
  39. -- Go up one directory
  40. deferred
  41. ensure
  42. old join_error implies join_error
  43. end
  44. join_file (element: STRING)
  45. -- Add a file to the end of the path
  46. require
  47. element /= Void
  48. do
  49. join_element(element)
  50. ensure
  51. old join_error implies join_error
  52. end
  53. join_element (element: STRING)
  54. -- Add an unspecified element (directory or file) to the end of the path
  55. require
  56. element /= Void
  57. deferred
  58. ensure
  59. old join_error implies join_error
  60. end
  61. join_extension (an_extension: STRING)
  62. -- Add an extension to the last element of the path
  63. require
  64. an_extension /= Void
  65. deferred
  66. ensure
  67. old join_error implies join_error
  68. end
  69. end_join
  70. -- Finish joining the path
  71. deferred
  72. ensure
  73. old join_error implies join_error
  74. end
  75. join_error: BOOLEAN
  76. -- Did an error occur during joining
  77. deferred
  78. end
  79. end -- class PATH_JOINER
  80. --
  81. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  82. --
  83. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  84. -- of this software and associated documentation files (the "Software"), to deal
  85. -- in the Software without restriction, including without limitation the rights
  86. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  87. -- copies of the Software, and to permit persons to whom the Software is
  88. -- furnished to do so, subject to the following conditions:
  89. --
  90. -- The above copyright notice and this permission notice shall be included in
  91. -- all copies or substantial portions of the Software.
  92. --
  93. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  94. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  95. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  96. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  97. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  98. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  99. -- THE SOFTWARE.