Gary,

Seeing that code reminds me of something in my backup system.  My move to Linux 
was not complete without it, and Pharo plus OS Process does the job fairly 
well.  One quirk involves spaces and ()[] in file names; there are probably 
others I have yet to find.  For the cp command, I look for these characters and 
wrap the file name in double quotes to allow the copy to work.

Perhaps there is room for this in each of the file directory classes, and for 
an option to detect problems and not fix them.  In my case, the file needs to 
be copied; I just need to do what one  would do from a terminal to get it to 
work, and that will arise elsewhere.

Bill


________________________________________
From: [email protected] 
[[email protected]] On Behalf Of Gary Chambers 
[[email protected]]
Sent: Tuesday, December 07, 2010 11:40 AM
To: [email protected]
Subject: Re: [Pharo-project] Bad characters in update package names

After a bit of digging the following was found:
http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

Assuming we are not concerned with allowing ascii 0..31 in alternate data
streams
(an interesting concept I have used, though rather esoteric) then the
following should do:

DosFileDirectory>>
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]]

Regards, Gary


Reply via email to