From e8b0d49a9cf8eeb95e2e41555d12f43724e417f1 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Wed, 1 Mar 2017 00:39:04 +0000 Subject: add / helper also for Path anticipating migration to nio --- stage1/cbt.scala | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'stage1/cbt.scala') diff --git a/stage1/cbt.scala b/stage1/cbt.scala index 44506d2..ea3237d 100644 --- a/stage1/cbt.scala +++ b/stage1/cbt.scala @@ -18,6 +18,16 @@ object `package`{ val sonatypeSnapshots = sonatypeBase ++ "snapshots" private val lib = new BaseLib + + implicit class PathExtensionMethods( path: Path ){ + def /(s: String): Path = path.resolve(s) + def ++( s: String ): Path = { + if(s endsWith "/") throw new Exception( + """Trying to append a String that ends in "/" to a Path would loose the trailing "/". Use .stripSuffix("/") if you need to.""" + ) + Paths.get( path.toString ++ s ) + } + } implicit class FileExtensionMethods( file: File ){ def ++( s: String ): File = { if(s endsWith "/") throw new Exception( -- cgit v1.2.3