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

http://github.com/tybor/Liberty · Specman e · 81 lines · 48 code · 8 blank · 25 comment · 6 complexity · 272cf030dc38c72002fded32e1ca81b6 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class WINDOWS_DIRECTORY_NOTATION
  5. -- The Windows like file path notation looks like:
  6. -- C:\LibertyEiffel\sys\system.se
  7. inherit
  8. PATH_NAME_NOTATION
  9. feature {ANY}
  10. is_current_directory (path: STRING): BOOLEAN
  11. do
  12. if path.compare(once ".") = 0 or else path.compare(once ".\") = 0 then
  13. Result := True
  14. elseif path.is_empty then
  15. elseif path.first /= '\' then
  16. Result := path.occurrences('.') + path.occurrences('\') = path.count and not path.has_substring("..")
  17. end
  18. end
  19. is_parent_directory (path: STRING): BOOLEAN
  20. local
  21. pos: INTEGER
  22. do
  23. if path.compare(once "..") = 0 or else path.compare(once "..\") = 0 then
  24. Result := True
  25. elseif path.is_empty then
  26. elseif path.first /= '\' then
  27. Result := path.occurrences('.') + path.occurrences('\') = path.count and path.has_substring("..")
  28. if Result then
  29. pos := path.first_substring_index("..")
  30. Result := Result and path.substring_index("..", pos + 2) = 0
  31. end
  32. end
  33. end
  34. to_directory_path (path: STRING)
  35. do
  36. from
  37. until path.is_empty or else path.last /= '\'
  38. loop
  39. path.remove_last
  40. end
  41. end
  42. feature {ANY}
  43. is_case_sensitive: BOOLEAN False
  44. feature {}
  45. tmp1: MICROSOFT_PATH_NAME
  46. once
  47. create Result.make_empty
  48. end
  49. tmp2: MICROSOFT_PATH_NAME
  50. once
  51. create Result.make_empty
  52. end
  53. end -- class WINDOWS_DIRECTORY_NOTATION
  54. --
  55. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  56. --
  57. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  58. -- of this software and associated documentation files (the "Software"), to deal
  59. -- in the Software without restriction, including without limitation the rights
  60. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  61. -- copies of the Software, and to permit persons to whom the Software is
  62. -- furnished to do so, subject to the following conditions:
  63. --
  64. -- The above copyright notice and this permission notice shall be included in
  65. -- all copies or substantial portions of the Software.
  66. --
  67. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  68. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  69. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  70. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  71. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  72. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  73. -- THE SOFTWARE.