CharacterArray.st
changeset 16757 da377b8c79f5
parent 16738 bd9416219f7c
child 16759 347181805b43
--- a/CharacterArray.st	Fri Jul 11 00:59:35 2014 +0200
+++ b/CharacterArray.st	Fri Jul 11 01:57:07 2014 +0200
@@ -326,7 +326,6 @@
     "
 ! !
 
-
 !CharacterArray class methodsFor:'pattern matching'!
 
 matchEscapeCharacter
@@ -724,7 +723,6 @@
     ^ self == CharacterArray
 ! !
 
-
 !CharacterArray methodsFor:'Compatibility-ANSI'!
 
 addLineDelimiters
@@ -3305,6 +3303,21 @@
     "Created: / 20-09-2010 / 21:42:55 / cg"
 !
 
+asUnixFilenameString
+    "return a new string consisting of receiver's characters
+     with all \-characters replaced by /-characters.
+     If there are no backslashes, return the original"
+
+    (self includes:$\) ifFalse:[^ self].
+    ^ self copyReplaceAll:$\ with:$/
+
+    "
+     'hello\world' asUnixFilenameString
+    "
+
+    "Modified: / 18.7.1998 / 22:53:02 / cg"
+!
+
 asUppercase
     "return a copy of myself in uppercase letters"
 
@@ -4805,7 +4818,6 @@
 ! !
 
 
-
 !CharacterArray methodsFor:'padded copying'!
 
 centerPaddedTo:newSize
@@ -5434,7 +5446,6 @@
     "Modified: 17.4.1997 / 12:50:23 / cg"
 ! !
 
-
 !CharacterArray methodsFor:'special string converting'!
 
 expandPlaceholders:escapeCharacter with:argArrayOrDictionary
@@ -5815,9 +5826,11 @@
 !
 
 withCRs
-    "return a new string consisting of receivers characters
-     with all \-characters replaced by cr-characters."
-
+    "return a new string consisting of receiver's characters
+     with all \-characters replaced by cr-characters.
+     If there are no backslashes, return the original"
+
+    (self includes:$\) ifFalse:[^ self].
     ^ self copyReplaceAll:$\ with:(Character cr)
 
     "
@@ -6381,7 +6394,6 @@
     "
 ! !
 
-
 !CharacterArray methodsFor:'substring searching'!
 
 findRangeOfString:subString
@@ -6968,11 +6980,11 @@
 !CharacterArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.537 2014-07-10 12:23:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.538 2014-07-10 23:57:07 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.537 2014-07-10 12:23:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.538 2014-07-10 23:57:07 cg Exp $'
 ! !