/[eiffelstudio]/FreeELKS/trunk/library/kernel/path_name.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/kernel/path_name.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91424 - (show annotations)
Tue Oct 26 18:39:32 2004 UTC (15 years, 3 months ago) by manus_eiffel
File size: 5483 byte(s)
Initial revision

1 indexing
2 description: "Path name abstraction"
3 status: "See notice at end of class"
4 date: "$Date$"
5 revision: "$Revision$"
6
7 deferred class PATH_NAME
8
9 inherit
10 STRING
11 rename
12 make as string_make,
13 make_from_string as string_make_from_string,
14 extend as string_extend
15 export
16 {PATH_NAME} all
17 {ANY} is_empty, empty, to_c, wipe_out, out, string, twin, prunable
18 undefine
19 new_string
20 redefine
21 is_equal
22 end
23
24 feature -- Initialization
25
26 make is
27 -- Create path name object.
28 do
29 string_make (0)
30 end
31
32 make_from_string (p: STRING) is
33 -- Create path name object and initialize it with the
34 -- path name `p'
35 require
36 path_not_void: p /= Void
37 do
38 string_make (p.count)
39 append (p)
40 ensure
41 valid_file_name: is_valid
42 end
43
44 feature -- Comparison
45
46 is_equal (other: like Current): BOOLEAN is
47 -- Is the path name equal to `other'?
48 local
49 o_area: like area
50 do
51 if other = Current then
52 Result := True
53 elseif other.count = count then
54 o_area := other.area
55 Result := eif_path_name_compare ($area, $o_area, count)
56 end
57 end
58
59 feature -- Status report
60
61 is_directory_name_valid (dir_name: STRING): BOOLEAN is
62 -- Is `dir_name' a valid subdirectory part for the operating system?
63 require
64 exists: dir_name /= Void
65 local
66 any: ANY
67 do
68 any := dir_name.to_c
69 Result := eif_is_directory_name_valid ($any)
70 end
71
72 is_volume_name_valid (vol_name: STRING): BOOLEAN is
73 -- Is `vol_name' a valid volume name for the operating system?
74 require
75 exists: vol_name /= Void
76 local
77 any: ANY
78 do
79 any := vol_name.to_c
80 Result := eif_is_volume_name_valid ($any)
81 end
82
83 is_valid: BOOLEAN is
84 -- Is the path name valid for the operating system?
85 deferred
86 end
87
88 feature -- Status setting
89
90 set_volume (volume_name: STRING) is
91 -- Set the volume part of the path name to `volume_name'.
92 require
93 string_exists: volume_name /= Void
94 valid_volume_name: is_volume_name_valid (volume_name)
95 empty_path_name: is_empty
96 do
97 append (volume_name)
98 ensure
99 valid_file_name: is_valid
100 end
101
102 extend, set_subdirectory (directory_name: STRING) is
103 -- Append the subdirectory `directory_name' to the path name.
104 require
105 string_exists: directory_name /= Void
106 valid_directory_name: is_directory_name_valid (directory_name)
107 local
108 new_size: INTEGER
109 str1, str2: ANY
110 do
111 new_size := count + directory_name.count + 5
112 if capacity < new_size then
113 resize (new_size)
114 end
115 str1 := to_c
116 str2 := directory_name.to_c
117 eif_append_directory ($Current, $str1, $str2)
118 ensure
119 valid_file_name: is_valid
120 end
121
122 set_directory (directory_name: STRING) is
123 -- Set the absolute directory part of the path name to `directory_name'.
124 require
125 string_exists: directory_name /= Void
126 valid_directory_name: is_directory_name_valid (directory_name)
127 local
128 new_size: INTEGER
129 str1, str2: ANY
130 do
131 new_size := count + directory_name.count + 5
132 if capacity < new_size then
133 resize (new_size)
134 end
135 str1 := to_c
136 str2 := directory_name.to_c
137 eif_set_directory ($Current, $str1, $str2)
138 ensure
139 valid_file_name: is_valid
140 end
141
142 extend_from_array (directories: ARRAY [STRING]) is
143 -- Append the subdirectories from `directories' to the path name.
144 require
145 array_exists: directories /= Void and then not (directories.is_empty)
146 local
147 i, nb: INTEGER
148 do
149 from
150 i := directories.lower
151 nb := directories.upper
152 until
153 i > nb
154 loop
155 extend (directories.item (i))
156 i := i + 1
157 end
158 ensure
159 valid_file_name: is_valid
160 end
161
162 feature {NONE} -- Externals
163
164 eif_is_volume_name_valid (p: POINTER): BOOLEAN is
165 external
166 "C (EIF_CHARACTER *): EIF_BOOLEAN | %"eif_path_name.h%""
167 end
168
169 eif_is_directory_name_valid (p: POINTER): BOOLEAN is
170 external
171 "C (EIF_CHARACTER *): EIF_BOOLEAN | %"eif_path_name.h%""
172 end
173
174 eif_append_directory (s, p, v: POINTER) is
175 external
176 "C (EIF_REFERENCE, EIF_CHARACTER *, EIF_CHARACTER *) | %"eif_path_name.h%""
177 end
178
179 eif_set_directory (s, p, v: POINTER) is
180 external
181 "C (EIF_REFERENCE, EIF_CHARACTER *, EIF_CHARACTER *) | %"eif_path_name.h%""
182 end
183
184 eif_path_name_compare (s, t: POINTER; length: INTEGER): BOOLEAN is
185 external
186 "C (EIF_CHARACTER *, EIF_CHARACTER *, EIF_INTEGER): EIF_BOOLEAN | %"eif_path_name.h%""
187 end
188
189 eif_volume_name (s: POINTER): STRING is
190 external
191 "C (EIF_CHARACTER *): EIF_REFERENCE | %"eif_path_name.h%""
192 end
193
194 eif_extracted_paths (s: POINTER): ARRAY [STRING] is
195 external
196 "C (EIF_CHARACTER *): EIF_REFERENCE | %"eif_path_name.h%""
197 end
198
199 indexing
200
201 library: "[
202 EiffelBase: Library of reusable components for Eiffel.
203 ]"
204
205 status: "[
206 Copyright 1986-2001 Interactive Software Engineering (ISE).
207 For ISE customers the original versions are an ISE product
208 covered by the ISE Eiffel license and support agreements.
209 ]"
210
211 license: "[
212 EiffelBase may now be used by anyone as FREE SOFTWARE to
213 develop any product, public-domain or commercial, without
214 payment to ISE, under the terms of the ISE Free Eiffel Library
215 License (IFELL) at http://eiffel.com/products/base/license.html.
216 ]"
217
218 source: "[
219 Interactive Software Engineering Inc.
220 ISE Building
221 360 Storke Road, Goleta, CA 93117 USA
222 Telephone 805-685-1006, Fax 805-685-6869
223 Electronic mail <info@eiffel.com>
224 Customer support http://support.eiffel.com
225 ]"
226
227 info: "[
228 For latest info see award-winning pages: http://eiffel.com
229 ]"
230
231 end -- class PATH_NAME
232
233

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23