Status: Accepted
Owner: stephane.ducasse
Labels: Milestone-1.2
New issue 3386 by stephane.ducasse: DosFileDirectory>> checkName: aFileName
fixErrors: fixing
http://code.google.com/p/pharo/issues/detail?id=3386DosFileDirectory>>
checkName: aFileName fixErrors: fixing
"Check if the file name contains any invalid characters"
| fName badChars hasBadChars |
fName := super checkName: aFileName fixErrors: fixing.
badChars := (#( $: $< $> $| $/ $\ $? $* $"), ((0 to: 31) collect: [:n | n
asCharacter])) asSet.
hasBadChars := fName includesAnyOf: badChars.
(hasBadChars and:[fixing not]) ifTrue:[^self error:'Invalid file name'].
hasBadChars ifFalse:[^ fName].
^ fName collect:
[:char | (badChars includes: char)
ifTrue:[$#]
ifFalse:[char]]