aboutsummaryrefslogtreecommitdiff
path: root/stage1
diff options
context:
space:
mode:
authorJan Christopher Vogt <oss.nsp@cvogt.org>2017-03-12 15:36:14 -0400
committerGitHub <noreply@github.com>2017-03-12 15:36:14 -0400
commit8fd9b9e01d763734953f722e1ba33c5025d53e63 (patch)
tree1f9d4c0d56308c436c50579131c5576386d7f249 /stage1
parentedb87b008ebed7a4b9d34bb04a4436b5d106a9e3 (diff)
parent485c9fe90ef2b09043ff1303135e8f2b77970845 (diff)
downloadcbt-8fd9b9e01d763734953f722e1ba33c5025d53e63.tar.gz
cbt-8fd9b9e01d763734953f722e1ba33c5025d53e63.tar.bz2
cbt-8fd9b9e01d763734953f722e1ba33c5025d53e63.zip
Merge pull request #425 from cvogt/writeIfChanged
writeIfChanged helper method
Diffstat (limited to 'stage1')
-rw-r--r--stage1/Stage1Lib.scala2
1 files changed, 2 insertions, 0 deletions
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala
index f5bcb63..d99354c 100644
--- a/stage1/Stage1Lib.scala
+++ b/stage1/Stage1Lib.scala
@@ -55,6 +55,8 @@ class Stage1Lib( logger: Logger ) extends BaseLib{
def green(string: String) = scala.Console.GREEN++string++scala.Console.RESET
def write(file: File, content: String, options: OpenOption*): File = Stage0Lib.write(file, content, options:_*)
+ def writeIfChanged(file: File, content: String, options: OpenOption*): File =
+ if( !file.exists || content != file.readAsString ) write(file, content, options:_*) else file
def addHttpCredentials( connection: HttpURLConnection, credentials: String ): Unit = {
val encoding = new sun.misc.BASE64Encoder().encode(credentials.getBytes)