@@ -99,99 +99,6 @@ function create_verify_dir($prefix, $basename, $cp = 65001)
99
99
}
100
100
}
101
101
102
- function create_data ($ id , $ item = "" , $ cp = 65001 )
103
- {
104
- $ prefix = dirname (__FILE__ ) . DIRECTORY_SEPARATOR . $ id ;
105
-
106
- if (!is_dir ($ prefix )) {
107
- mkdir ($ prefix );
108
- }
109
-
110
- /* Using a UTF-8 encoded filenames if !zend.multibyte, otherwise files in retrospective charset. */
111
- switch ($ id ) {
112
-
113
- case "file_mb3 " :
114
- $ content = "<?php
115
-
116
- echo \"hello there from the include \n\"; " ;
117
- create_verify_file ($ prefix , "českýtestování.inc " , $ content );
118
- break ;
119
-
120
- case "bug71509 " :
121
- $ content = "that's my file with swedish filename
122
- " ;
123
- create_verify_file ($ prefix , $ item , $ content );
124
- break ;
125
-
126
- case "file_mb4 " :
127
- create_verify_file ($ prefix , "š.txt " , "" );
128
- break ;
129
-
130
- case "file_cp1252 " :
131
- $ content = "hallo
132
- " ;
133
- create_verify_file ($ prefix , "tschüß " , $ content );
134
- break ;
135
-
136
- case "file2_cp1252 " :
137
- create_verify_file ($ prefix , $ item , "hola " );
138
- break ;
139
-
140
- case "file2_mb " :
141
- create_verify_file ($ prefix , "Ελλάδα.txt " , "" );
142
- break ;
143
-
144
- case "file_cp1251 " :
145
- create_verify_file ($ prefix , $ item , "opened an utf8 filename for reading " , $ cp );
146
- break ;
147
-
148
- case "file_cp1255 " :
149
- case "file_cp1254 " :
150
- case "file_cp1253 " :
151
- case "file_kartuli " :
152
- case "file_cp1250 " :
153
- case "file_cp1256 " :
154
- case "file_cp874 " :
155
- case "file_big5 " :
156
- case "file_cp936 " :
157
- case "file_cp932 " :
158
- case "file_eucjp " :
159
- case "file_mb " :
160
- $ content = "reading file wihh multibyte filename
161
- " ;
162
- create_verify_file ($ prefix , $ item , $ content , $ cp );
163
- break ;
164
-
165
- case "dir_mb " :
166
- create_verify_dir ($ prefix , "テストマルチバイト・パス42 " );
167
- break ;
168
-
169
- case "dir_cp1255 " :
170
- case "dir_cp1254 " :
171
- case "dir_cp1253 " :
172
- case "dir_kartuli " :
173
- case "dir_cp1250 " :
174
- case "dir_cp1256 " :
175
- case "dir_cp874 " :
176
- case "dir_cp932 " :
177
- case "dir_cp936 " :
178
- case "dir_eucjp " :
179
- case "dir2_cp1252 " :
180
- case "dir_cp1252 " :
181
- case "dir_cp1251 " :
182
- case "dir_big5 " :
183
- case "dir " :
184
- create_verify_dir ($ prefix , $ item , $ cp );
185
- break ;
186
-
187
- case "file " :
188
- create_verify_file ($ prefix , $ item , "" , $ cp );
189
- break ;
190
- }
191
-
192
- return $ prefix ;
193
- }
194
-
195
102
function remove_data ($ id , $ dir = NULL )
196
103
{
197
104
if (!$ dir ) {
@@ -212,3 +119,31 @@ function remove_data($id, $dir = NULL)
212
119
rmdir ($ dir );
213
120
}
214
121
}
122
+
123
+ function create_data ($ id , $ item = "" , $ cp = 65001 , $ utf8 = true )
124
+ {
125
+ if ($ utf8 ) {
126
+ /* Keep this file ASCII, so zend.multibyte related stuff can be tasted as well. */
127
+ include dirname (__FILE__ ) . DIRECTORY_SEPARATOR . "util_utf8.inc " ;
128
+ return create_data_from_utf8 ($ id , $ item , $ cp );
129
+ } else {
130
+
131
+ $ prefix = dirname (__FILE__ ) . DIRECTORY_SEPARATOR . $ id ;
132
+
133
+ if (!is_dir ($ prefix )) {
134
+ mkdir ($ prefix );
135
+ }
136
+
137
+ if (0 === strpos ($ id , "dir " )) {
138
+ create_verify_dir ($ prefix , $ item , $ cp );
139
+ } else if (0 === strpos ($ id , "file " )) {
140
+ /* a bit unhandy, but content can be put from outside, if needed */
141
+ create_verify_file ($ prefix , $ item , "dummy content " , $ cp );
142
+ } else {
143
+ echo "Item has either to start with \"dir \" or \"file \"" ;
144
+ }
145
+ }
146
+
147
+ return $ prefix ;
148
+ }
149
+
0 commit comments