class: Filename
authorClaus Gittinger <cg@exept.de>
Sat, 08 Nov 2014 10:05:49 +0100
changeset 16999 4d5ceea1cea6
parent 16998 54ee26519396
child 17000 28e08401d7ae
class: Filename added: #possiblyQuotedPathname:
Filename.st
--- a/Filename.st	Sat Nov 08 01:21:35 2014 +0100
+++ b/Filename.st	Sat Nov 08 10:05:49 2014 +0100
@@ -1004,6 +1004,26 @@
     "
 !
 
+possiblyQuotedPathname:aPath
+    "return a filename path usable as command line argument,
+     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
+
+
+    "
+     Filename possiblyQuotedPathname:'/tmp/bla'   
+     Filename possiblyQuotedPathname:'/tmp directory/bla'   
+     Filename possiblyQuotedPathname:'/tmp directory/bla file'   
+    "
+!
+
 suggest:aFilenameString 
     "return a fileNamestring based on the argument, 
      which is legal on the current platform."
@@ -6047,11 +6067,11 @@
 !Filename class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.426 2014-07-21 11:28:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.427 2014-11-08 09:05:49 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.426 2014-07-21 11:28:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Filename.st,v 1.427 2014-11-08 09:05:49 cg Exp $'
 ! !