--- a/src/Pure/General/ssh.scala Mon Oct 10 22:20:00 2016 +0200
+++ b/src/Pure/General/ssh.scala Tue Oct 11 09:32:56 2016 +0200
@@ -277,6 +277,21 @@
val channel = session.openChannel(kind).asInstanceOf[ChannelSftp]
new Sftp(this, kind, options, channel)
}
+
+
+ /* tmp dirs */
+
+ def rm_tree(remote_dir: String): Unit =
+ execute("rm -r -f " + File.bash_string(remote_dir)).check
+
+ def tmp_dir(): String =
+ execute("mktemp -d -t tmp.XXXXXXXXXX").check.out
+
+ def with_tmp_dir[A](body: String => A): A =
+ {
+ val remote_dir = tmp_dir()
+ try { body(remote_dir) } finally { rm_tree(remote_dir) }
+ }
}
}