diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-17 03:36:49 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-17 03:41:37 -0400 |
commit | ec1ab4fe8b25fdc6462dcf07727233b80563285a (patch) | |
tree | d9326a69cd0da30e87d02256fc9493b3b495c5ba /stage1 | |
parent | b9c20082bcbd231eb67c3ded0d3fe6674c8c55b7 (diff) | |
download | cbt-ec1ab4fe8b25fdc6462dcf07727233b80563285a.tar.gz cbt-ec1ab4fe8b25fdc6462dcf07727233b80563285a.tar.bz2 cbt-ec1ab4fe8b25fdc6462dcf07727233b80563285a.zip |
Add string quoting helpers
Diffstat (limited to 'stage1')
-rw-r--r-- | stage1/cbt.scala | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/stage1/cbt.scala b/stage1/cbt.scala index cb6cb10..5f8f2b5 100644 --- a/stage1/cbt.scala +++ b/stage1/cbt.scala @@ -20,6 +20,10 @@ object `package`{ private val lib = new BaseLib + implicit class CbtStringExtensions(string: String){ + def escape = string.replace("\\","\\\\").replace("\"","\\\"") + def quote = s""""$escape"""" + } implicit class PathExtensionMethods( path: Path ){ def /(s: String): Path = path.resolve(s) def ++( s: String ): Path = { @@ -64,6 +68,7 @@ object `package`{ def lastModifiedRecursive = listRecursive.map(_.lastModified).max def readAsString = new String( readAllBytes( file.toPath ) ) + def quote = s"new _root_.java.io.File(${string.quote})" } implicit class URLExtensionMethods( url: URL ){ def ++( s: String ): URL = new URL( url.toString ++ s ) |