#REFACTORING by cg
class: Filename
changed:
#isAbsolute
#nameWithSpecialExpansions:
#osNameForFile
#possiblyQuotedPathname:
--- a/Filename.st Thu Apr 28 21:50:08 2016 +0200
+++ b/Filename.st Thu Apr 28 22:43:37 2016 +0200
@@ -982,36 +982,36 @@
|dir user cutIdx idx userInfo|
- (aString startsWith:'~') ifFalse:[
- ^ aString.
+ (aString startsWith:$~) ifFalse:[
+ ^ aString.
].
aString size > 1 ifTrue:[
- idx := aString indexOf:self separator.
- idx == 0 ifTrue:[
- "aString is '~user'"
- user := aString copyFrom:2.
- cutIdx := aString size + 1.
- ] ifFalse:[
- "aString is '~user/something'"
- user := aString copyFrom:2 to:(idx - 1).
- cutIdx := idx.
- ].
- user notEmpty ifTrue:[
- userInfo := OperatingSystem userInfoOf:user.
- userInfo notNil ifTrue:[
- dir := userInfo at:#dir ifAbsent:nil.
- ].
- dir isNil ifTrue:[
+ idx := aString indexOf:self separator.
+ idx == 0 ifTrue:[
+ "aString is '~user'"
+ user := aString copyFrom:2.
+ cutIdx := aString size + 1.
+ ] ifFalse:[
+ "aString is '~user/something'"
+ user := aString copyFrom:2 to:(idx - 1).
+ cutIdx := idx.
+ ].
+ user notEmpty ifTrue:[
+ userInfo := OperatingSystem userInfoOf:user.
+ userInfo notNil ifTrue:[
+ dir := userInfo at:#dir ifAbsent:nil.
+ ].
+ dir isNil ifTrue:[
"/ ('Filename [info]: unknown user: ' , user) infoPrintCR.
- ^ aString
- ].
- ].
+ ^ aString
+ ].
+ ].
].
dir isNil ifTrue:[
- "aString is '~' or '~/'"
- dir := OperatingSystem getHomeDirectory.
- cutIdx := 2.
+ "aString is '~' or '~/'"
+ dir := OperatingSystem getHomeDirectory.
+ cutIdx := 2.
].
^ dir , (aString copyFrom:cutIdx)
@@ -1049,10 +1049,10 @@
by quoting in double quotes if there are any embedded special characters.
On Unix systems, special characters might also be prefixed by a backslash character."
- (aPath startsWith:'"') ifFalse:[
- (aPath includes:Character space) ifTrue:[
- ^ '"',aPath,'"'
- ].
+ (aPath startsWith:$") ifFalse:[
+ (aPath includes:Character space) ifTrue:[
+ ^ '"',aPath,'"'
+ ].
].
^ aPath
@@ -5076,7 +5076,7 @@
"return true, if the receiver represents an absolute pathname
(in contrast to one relative to the current directory)."
- ((nameString startsWith:self species separator) or:[nameString startsWith:'~']) ifTrue:[^ true].
+ ((nameString startsWith:self species separator) or:[nameString startsWith:$~]) ifTrue:[^ true].
^ self isVolumeAbsolute
"
@@ -5879,8 +5879,8 @@
"internal - return the OS's name for the receiver to
access it as a file."
- (nameString startsWith:'~') ifFalse:[
- ^ nameString.
+ (nameString startsWith:$~) ifFalse:[
+ ^ nameString.
].
^ self species nameWithSpecialExpansions:nameString.