176 ^ 'st%1%2' |
176 ^ 'st%1%2' |
177 |
177 |
178 "Created: 30.1.1998 / 12:09:18 / dq" |
178 "Created: 30.1.1998 / 12:09:18 / dq" |
179 ! ! |
179 ! ! |
180 |
180 |
|
181 !PCFilename methodsFor:'converting'! |
|
182 |
|
183 makeLegalFilename |
|
184 "convert the receivers name to be a legal filename. |
|
185 This removes/replaces invalid characters and/or compresses |
|
186 the name as required by Win95-WinNT." |
|
187 |
|
188 |srchStart| |
|
189 |
|
190 "/ there may be only one colon in the name |
|
191 "/ (and if present, it must be the second character) |
|
192 |
|
193 ((nameString size >= 2) |
|
194 and:[(nameString at:2) == $:]) ifTrue:[ |
|
195 srchStart := 3. |
|
196 ] ifFalse:[ |
|
197 srchStart := 1 |
|
198 ]. |
|
199 |
|
200 "/ replace colons by underscore |
|
201 "/ may need more to convert - time will show |
|
202 |
|
203 (nameString indexOfAny:#($:) startingAt:srchStart) ~~ 0 ifTrue:[ |
|
204 nameString := nameString copy. |
|
205 nameString replaceAny:#($:) with:$_ from:srchStart to:(nameString size). |
|
206 ]. |
|
207 ^ self |
|
208 |
|
209 " |
|
210 'hello world' asFilename makeLegalFilename |
|
211 'hello:world' asFilename makeLegalFilename |
|
212 'hello::world' asFilename makeLegalFilename |
|
213 'c:hello::world' asFilename makeLegalFilename |
|
214 " |
|
215 |
|
216 "Modified: / 27.8.1998 / 12:52:03 / cg" |
|
217 ! ! |
|
218 |
181 !PCFilename methodsFor:'file operations'! |
219 !PCFilename methodsFor:'file operations'! |
182 |
220 |
183 renameTo:newName |
221 renameTo:newName |
184 "rename the file - the argument must be convertable to a String. |
222 "rename the file - the argument must be convertable to a String. |
185 Raise an error if not successful. |
223 Raise an error if not successful. |