PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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