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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 indexing
2 description: "File name abstraction"
3 status: "See notice at end of class"
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 FILE_NAME
9
10 inherit
11 PATH_NAME
12
13 create
14 make, make_from_string, make_temporary_name
15
16 create {FILE_NAME}
17 string_make
18
19 feature {NONE} -- Initialization
20
21 make_temporary_name is
22 -- Create a temporary filename.
23 local
24 p: POINTER
25 do
26 p := c_tempnam (p, p)
27 make_from_c (p)
28 p.memory_free
29 end
30
31 feature -- Status report
32
33 is_valid: BOOLEAN is
34 -- Is the file name valid for the operating system?
35 local
36 any: ANY
37 do
38 any := to_c
39 Result := eif_is_file_valid ($any)
40 end
41
42 is_file_name_valid (f_name: STRING): BOOLEAN is
43 -- Is `f_name' a valid file name part for the operating system?
44 local
45 any: ANY
46 do
47 any := f_name.to_c
48 Result := eif_is_file_name_valid ($any)
49 end
50
51 is_extension_valid (ext: STRING): BOOLEAN is
52 -- Is `ext' a valid extension for the operating system?
53 local
54 any: ANY
55 do
56 any := ext.to_c
57 Result := eif_is_extension_valid ($any)
58 end
59
60 feature -- Status setting
61
62 set_file_name (file_name: STRING) is
63 -- Set the value of the file name part.
64 require
65 string_exists: file_name /= Void
66 valid_file_name: is_file_name_valid (file_name)
67 local
68 new_size: INTEGER
69 str1, str2: ANY
70 do
71 new_size := count + file_name.count + 5
72 if capacity < new_size then
73 resize (new_size)
74 end
75 str1 := to_c
76 str2 := file_name.to_c
77 eif_append_file_name ($Current, $str1, $str2)
78 ensure
79 valid_file_name: is_valid
80 end
81
82 add_extension (ext: STRING) is
83 -- Append the extension `ext' to the file name
84 require
85 string_exists: ext /= Void
86 non_empty_extension: not ext.is_empty
87 valid_extension: is_extension_valid (ext)
88 do
89 append_character ('.')
90 append (ext)
91 end
92
93 feature {NONE} -- Implementation
94
95 new_string (n: INTEGER): like Current is
96 -- New instance of current with space for at least `n' characters.
97 do
98 create Result.string_make (n)
99 end
100
101 feature {NONE} -- Externals
102
103 eif_append_file_name (s, p, v: POINTER) is
104 external
105 "C (EIF_REFERENCE, EIF_CHARACTER *, EIF_CHARACTER *) | %"eif_path_name.h%""
106 end
107
108 eif_is_file_name_valid (p: POINTER): BOOLEAN is
109 external
110 "C (EIF_CHARACTER *): EIF_BOOLEAN | %"eif_path_name.h%""
111 end
112
113 eif_is_extension_valid (p: POINTER): BOOLEAN is
114 external
115 "C (EIF_CHARACTER *): EIF_BOOLEAN | %"eif_path_name.h%""
116 end
117
118 eif_is_file_valid (p: POINTER): BOOLEAN is
119 external
120 "C (EIF_CHARACTER *): EIF_BOOLEAN | %"eif_path_name.h%""
121 end
122
123 c_tempnam (d, n: POINTER): POINTER is
124 external
125 "C (char *, char *): EIF_POINTER | <stdio.h>"
126 alias
127 "tempnam"
128 end
129
130 indexing
131
132 library: "[
133 EiffelBase: Library of reusable components for Eiffel.
134 ]"
135
136 status: "[
137 Copyright 1986-2001 Interactive Software Engineering (ISE).
138 For ISE customers the original versions are an ISE product
139 covered by the ISE Eiffel license and support agreements.
140 ]"
141
142 license: "[
143 EiffelBase may now be used by anyone as FREE SOFTWARE to
144 develop any product, public-domain or commercial, without
145 payment to ISE, under the terms of the ISE Free Eiffel Library
146 License (IFELL) at http://eiffel.com/products/base/license.html.
147 ]"
148
149 source: "[
150 Interactive Software Engineering Inc.
151 ISE Building
152 360 Storke Road, Goleta, CA 93117 USA
153 Telephone 805-685-1006, Fax 805-685-6869
154 Electronic mail <info@eiffel.com>
155 Customer support http://support.eiffel.com
156 ]"
157
158 info: "[
159 For latest info see award-winning pages: http://eiffel.com
160 ]"
161
162 end -- class FILE_NAME
163
164

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23