/src/lib/io/filesystem/path_name/amiga_directory_notation.e

http://github.com/tybor/Liberty · Specman e · 171 lines · 124 code · 19 blank · 28 comment · 11 complexity · 7cea90a13a19f20dc414991f4f502692 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class AMIGA_DIRECTORY_NOTATION
  5. -- The Amiga file path notation looks like:
  6. -- DEV:SmartEiffel/sys/system.se
  7. inherit
  8. DIRECTORY_NOTATION
  9. feature {ANY}
  10. is_current_directory (path: STRING): BOOLEAN is
  11. do
  12. not_yet_implemented
  13. end
  14. is_parent_directory (path: STRING): BOOLEAN is
  15. do
  16. not_yet_implemented
  17. end
  18. to_parent_directory (some_path: STRING) is
  19. do
  20. if some_path.last = ':' then
  21. some_path.clear_count
  22. else
  23. from
  24. some_path.remove_last
  25. until
  26. some_path.is_empty or else some_path.last = '/' or else some_path.last = ':'
  27. loop
  28. some_path.remove_last
  29. end
  30. end
  31. if not some_path.is_empty and then (some_path.last /= '/' and then some_path.last /= ':') then
  32. some_path.extend('/')
  33. end
  34. end
  35. to_subdirectory_with (parent_path, entry_name: STRING) is
  36. do
  37. inspect
  38. parent_path.last
  39. when '/' then
  40. if entry_name.first = '/' then
  41. parent_path.remove_last
  42. end
  43. when ':' then
  44. else
  45. if entry_name.first /= '/' then
  46. parent_path.add_last('/')
  47. end
  48. end
  49. parent_path.append(entry_name)
  50. parent_path.extend_unless('/')
  51. end
  52. to_file_path_with (parent_path, file_name: STRING) is
  53. do
  54. inspect
  55. parent_path.last
  56. when ':' then
  57. when '/' then
  58. if file_name.first = '/' then
  59. parent_path.remove_last
  60. end
  61. else
  62. if file_name.first /= '/' then
  63. parent_path.extend('/')
  64. end
  65. end
  66. parent_path.append(file_name)
  67. end
  68. to_subpath_with (parent_path, subpath: STRING) is
  69. do
  70. if parent_path.last /= ':' then
  71. parent_path.extend_unless('/')
  72. end
  73. parent_path.append(subpath)
  74. end
  75. to_directory_path (path: STRING) is
  76. do
  77. path.extend_unless('/')
  78. end
  79. to_short_name_in (buffer, path: STRING) is
  80. local
  81. i: INTEGER
  82. do
  83. buffer.copy(path)
  84. if buffer.last = '/' then
  85. buffer.remove_last
  86. end
  87. i := buffer.last_index_of('/')
  88. if i >= 0 then
  89. buffer.shrink(i + 1, buffer.count)
  90. end
  91. end
  92. feature {ANY}
  93. can_map_drive (source_notation: DIRECTORY_NOTATION; drive: STRING): BOOLEAN is
  94. do
  95. --|*** We (c/sh)ould do better than nothing... <24/03/2005>
  96. end
  97. to_root (source_notation: DIRECTORY_NOTATION; drive: STRING) is
  98. do
  99. check
  100. False
  101. end
  102. end
  103. to_default_root (directory: STRING) is
  104. do
  105. not_yet_implemented
  106. end
  107. to_current_directory (directory: STRING) is
  108. do
  109. not_yet_implemented
  110. end
  111. feature {ANY}
  112. is_case_sensitive: BOOLEAN is True
  113. is_valid_path, is_valid_directory_path (path: STRING): BOOLEAN is
  114. do
  115. --|*** Not nearly strict enough <FM-24/03/2003>
  116. Result := not path.is_empty
  117. end
  118. is_valid_file_name (name: STRING): BOOLEAN is
  119. do
  120. --|*** Not nearly strict enough <FM-24/03/2003>
  121. Result := not name.is_empty
  122. end
  123. is_absolute_path (path: STRING): BOOLEAN is
  124. do
  125. not_yet_implemented
  126. end
  127. feature {DIRECTORY_NOTATION}
  128. to_notation (path: STRING; destination_notation: DIRECTORY_NOTATION): STRING is
  129. do
  130. not_yet_implemented
  131. end
  132. end -- class AMIGA_DIRECTORY_NOTATION
  133. --
  134. -- Copyright (c) 2009 by all the people cited in the AUTHORS file.
  135. --
  136. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  137. -- of this software and associated documentation files (the "Software"), to deal
  138. -- in the Software without restriction, including without limitation the rights
  139. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  140. -- copies of the Software, and to permit persons to whom the Software is
  141. -- furnished to do so, subject to the following conditions:
  142. --
  143. -- The above copyright notice and this permission notice shall be included in
  144. -- all copies or substantial portions of the Software.
  145. --
  146. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  147. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  148. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  149. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  150. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  151. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  152. -- THE SOFTWARE.