PageRenderTime 17ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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